From 36be402ae378fb1e8b94af26bcf2a050c2af9fcb Mon Sep 17 00:00:00 2001 From: Tomasz Adamczyk Date: Fri, 9 Apr 2021 16:35:09 +0200 Subject: [PATCH] fringe --- .idea/workspace.xml | 26 +++++++++++------------ __pycache__/definitions.cpython-37.pyc | Bin 3400 -> 3400 bytes __pycache__/fringe.cpython-37.pyc | Bin 0 -> 988 bytes definitions.py | 2 +- fringe.py | 7 +++++++ graph.py | 5 +++++ harvest.py | 28 +++++++++++++++++++++++++ istate.py | 17 +++++++++++++++ py.py | 2 ++ 9 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 __pycache__/fringe.cpython-37.pyc create mode 100644 fringe.py create mode 100644 graph.py create mode 100644 harvest.py create mode 100644 istate.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a992cfd..4635301 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,11 +2,10 @@ + - - @@ -112,22 +112,22 @@ \ No newline at end of file diff --git a/__pycache__/definitions.cpython-37.pyc b/__pycache__/definitions.cpython-37.pyc index 0d34f9c86670be340507ccc64399d4afedab458e..ce470302e9848e7ca174f6c932767176f0aa5b85 100644 GIT binary patch delta 163 zcmX>hbwY~QiIhbwY~QiI;fdECg%W2>B&=o zq|D?!%#xC_QJN{NQCcZ1QQ9eTQ93EIQMxJeQFLh&xd0JiIC_J?KP>W5Q2nAp|c_-G}cMW>Shxh?#1pI$(9?G{17P9 z@Pn?U%3q*jX4iMI14zti9=DJAzL}l3L-URS1AdKq zC8i9-DT{*?*Ed1N1$KPgnp=;?uiFS*#yT-ZO{qL@LG~v;R z_8*Y8gCwH&A@6p#Ac?#y?lA^b+&8}B-#PD|Lpb0jR8^%5h&_R(|3zhUeV@Wu0m!;s z7anb}c(N{h>%dl*J0hcw2p|!h2{F0FCG?(2P?gm`y8e{gZ9krE zJi%X%PU470q)@q*vKdO5moU#L9!dFmt}?%4sKsVLhRQTMWFC^C=iV?h4W^wUH|-IR ag#X++4!rXlcU%fLM$sz||C%ybRQ4NjT*zSn literal 0 HcmV?d00001 diff --git a/definitions.py b/definitions.py index 2ee2ec4..5fcd617 100644 --- a/definitions.py +++ b/definitions.py @@ -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')) diff --git a/fringe.py b/fringe.py new file mode 100644 index 0000000..3819806 --- /dev/null +++ b/fringe.py @@ -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 \ No newline at end of file diff --git a/graph.py b/graph.py new file mode 100644 index 0000000..1f2091e --- /dev/null +++ b/graph.py @@ -0,0 +1,5 @@ +@staticmethod +def graphsearch(fringe, explored, istate, succ, goaltest): + fringe.add_to_fringe(istate) + while True: + \ No newline at end of file diff --git a/harvest.py b/harvest.py new file mode 100644 index 0000000..1e036bb --- /dev/null +++ b/harvest.py @@ -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)) diff --git a/istate.py b/istate.py new file mode 100644 index 0000000..e073d68 --- /dev/null +++ b/istate.py @@ -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 \ No newline at end of file diff --git a/py.py b/py.py index 1f3464d..f383ff2 100644 --- a/py.py +++ b/py.py @@ -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}