This commit is contained in:
Tomasz Adamczyk 2021-04-09 16:35:09 +02:00
parent a357b56d58
commit 36be402ae3
9 changed files with 73 additions and 14 deletions

View File

@ -2,11 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/graph.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/definitions.py" beforeDir="false" afterPath="$PROJECT_DIR$/definitions.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/map.py" beforeDir="false" afterPath="$PROJECT_DIR$/map.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/minecart_command_block.png" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -105,6 +104,7 @@
<workItem from="1617794241086" duration="273000" />
<workItem from="1617966682687" duration="4169000" />
<workItem from="1617972419025" duration="598000" />
<workItem from="1617973153919" duration="5668000" />
</task>
<servers />
</component>
@ -112,22 +112,22 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617973021898">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617978874344">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617973021898">
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617978874344" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617978874344">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617973021898">
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617978874344" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617978874343">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617973021898">
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617978874343" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617978874344">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617978874344" />
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1617385468328">
<screen x="0" y="0" width="1920" height="1080" />
</state>
@ -144,12 +144,12 @@
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468328" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617972418605">
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617973162746">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617972418605" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617973162746" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617972977225" 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/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617977810609" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

Binary file not shown.

View File

@ -30,7 +30,7 @@ FARMLAND_DRY = pygame.image.load(os.path.join('resources', 'farmland_dry.png'))
FARMLAND_DRY = pygame.transform.scale(FARMLAND_DRY, (BLOCK_SIZE, BLOCK_SIZE))
FARMLAND_WET = pygame.image.load(os.path.join('resources', 'farmland_wet.png'))
FARMLAND_WET = pygame.transform.scale(FARMLAND_WET, (BLOCK_SIZE, BLOCK_SIZE))
FPS = 1
FPS = 20
POTATOES_GROW_TIME = 5
POTATOES_MAXIMUM_STATE = POTATOES_GROW_TIME * 3 + 1
POTATOES_STAGE_0 = pygame.image.load(os.path.join('resources', 'potatoes_stage_0.png'))

7
fringe.py Normal file
View File

@ -0,0 +1,7 @@
class Fringe: #kolejka zawierająca akcje oraz pola do odwiedzenia
def __init__(self, fringe):
self.fringe = fringe
def get_fringe(self):
return self.fringe
def set_fringe(self, fringe):
self.fringe = fringe

5
graph.py Normal file
View File

@ -0,0 +1,5 @@
@staticmethod
def graphsearch(fringe, explored, istate, succ, goaltest):
fringe.add_to_fringe(istate)
while True:

28
harvest.py Normal file
View File

@ -0,0 +1,28 @@
import definitions
class Harvest: #lista dojrzałych roślin
def __init__(self, harvest):
self.harvest = harvest
def get_harvest(self):
return self.harvest
def set_harvest(self, harvest):
self.harvest = harvest
def add_to_harvest(self, value):
self.harvest.append(value)
def remove_element_from_harvest(self, value): #usuwa element z listy o wartości value
self.harvest.remove(value)
def find_grown_plants(self, map1): #szuka, na których polach są dojrzałe rośliny
for i in range(definitions.WIDTH_AMOUNT):
for j in range(definitions.HEIGHT_AMOUNT):
field = map1.get_fields()[i][j]
if (i * definitions.BLOCK_SIZE,
j * definitions.BLOCK_SIZE) not in self.harvest and field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() > 0 and field.get_plant().get_state() == definitions.BEETROOTS_MAXIMUM_STATE:
self.add_to_harvest((i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE))
elif (i * definitions.BLOCK_SIZE,
j * definitions.BLOCK_SIZE) not in self.harvest and field.get_plant().get_name() == "carrot" and field.get_plant().get_state() > 0 and field.get_plant().get_state() == definitions.CARROTS_MAXIMUM_STATE:
self.add_to_harvest((i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE))
elif (i * definitions.BLOCK_SIZE,
j * definitions.BLOCK_SIZE) not in self.harvest and field.get_plant().get_name() == "potato" and field.get_plant().get_state() > 0 and field.get_plant().get_state() == definitions.POTATOES_MAXIMUM_STATE:
self.add_to_harvest((i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE))
elif (i * definitions.BLOCK_SIZE,
j * definitions.BLOCK_SIZE) not in self.harvest and field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
self.add_to_harvest((i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE))

17
istate.py Normal file
View File

@ -0,0 +1,17 @@
class Istate: #stan początkowy traktora
def __init__(self, direction, x, y):
self.direction = direction
self.x = x
self.y = y
def get_direction(self):
return self.direction
def set_x(self, direction):
self.direction = direction
def get_x(self):
return self.x
def set_x(self, x):
self.x = x
def get_y(self):
return self.y
def set_y(self, y):
self.y = y

2
py.py
View File

@ -1,4 +1,5 @@
import definitions
import fringe
import map
import plant
import pygame
@ -7,6 +8,7 @@ import tractor
pygame.display.set_caption("Smart Tractor")
def main():
#tworzenie podstawowych obiektów
fringe1 = fringe.Fringe([])
map1 = map.Map([])
map1.create_base_map()
amount_of_seeds_dict = {"beetroot": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "carrot": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "potato": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "wheat": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE}