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 0d34f9c..ce47030 100644 Binary files a/__pycache__/definitions.cpython-37.pyc and b/__pycache__/definitions.cpython-37.pyc differ diff --git a/__pycache__/fringe.cpython-37.pyc b/__pycache__/fringe.cpython-37.pyc new file mode 100644 index 0000000..099c725 Binary files /dev/null and b/__pycache__/fringe.cpython-37.pyc differ 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}