2
0
forked from s444420/AL-2020

create addShelf method in Field class

This commit is contained in:
shaaqu 2020-05-18 17:33:48 +02:00
parent dfe2e50414
commit 8ec5e96e8c
3 changed files with 24 additions and 8 deletions

View File

@ -2,10 +2,9 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment=""> <list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/shelf.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/wozek.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/wozek.iml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/field.py" beforeDir="false" afterPath="$PROJECT_DIR$/field.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/shelf.py" beforeDir="false" afterPath="$PROJECT_DIR$/shelf.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -123,8 +122,16 @@
<workItem from="1589745409339" duration="739000" /> <workItem from="1589745409339" duration="739000" />
<workItem from="1589752301424" duration="1007000" /> <workItem from="1589752301424" duration="1007000" />
<workItem from="1589753322316" duration="835000" /> <workItem from="1589753322316" duration="835000" />
<workItem from="1589814601057" duration="822000" /> <workItem from="1589814601057" duration="1397000" />
</task> </task>
<task id="LOCAL-00001" summary="create Shelf">
<created>1589815443652</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1589815443652</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -143,6 +150,10 @@
</map> </map>
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="create Shelf" />
<option name="LAST_COMMIT_MESSAGE" value="create Shelf" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/AL_2020$main.coverage" NAME="main Coverage Results" MODIFIED="1589754127142" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/AL_2020$main.coverage" NAME="main Coverage Results" MODIFIED="1589754127142" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/wozek$main.coverage" NAME="main Coverage Results" MODIFIED="1589556038208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/wozek$main.coverage" NAME="main Coverage Results" MODIFIED="1589556038208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />

View File

@ -1,4 +1,5 @@
import pygame import pygame
from shelf import Shelf
class Field: class Field:
@ -14,6 +15,7 @@ class Field:
self.is_occupied_by_agent = is_occupied_by_agent self.is_occupied_by_agent = is_occupied_by_agent
self.cost_of_travel = cost_of_travel self.cost_of_travel = cost_of_travel
self.neighbors = [] self.neighbors = []
self.shelves = []
# Te parametry są potrzebne do algorytmu A* # Te parametry są potrzebne do algorytmu A*
self.g = 0 self.g = 0
@ -42,3 +44,7 @@ class Field:
self.neighbors.append(board[self.y - 1][self.x]) self.neighbors.append(board[self.y - 1][self.x])
if self.y < 9 and board[self.y + 1][self.x].is_shelf == False: if self.y < 9 and board[self.y + 1][self.x].is_shelf == False:
self.neighbors.append(board[self.y + 1][self.x]) self.neighbors.append(board[self.y + 1][self.x])
def addShelf(self):
shelf = Shelf(len(self.shelves)+1)
self.shelves.append(shelf)

View File

@ -1,12 +1,11 @@
import pygame import pygame
class Shelf: class Shelf:
def __init__(self, id, field): def __init__(self, id):
self.id = id self.id = id
self.field = field
self.products = [] self.products = []
def addProduct(self, sweet): def addProduct(self, sweet):
self.products.append(sweet) self.products.append(sweet)