checkpoint
This commit is contained in:
parent
5257a3ec30
commit
05eaa8f396
@ -4,37 +4,20 @@ from DataModels.House import House
|
||||
from DataModels.Dump import Dump
|
||||
from config import GRID_WIDTH, GRID_HEIGHT
|
||||
|
||||
# PODAC TUTAJ X I Y DO MOVEMENT (ZAIMPORTOWAC TO NAJPIERW)
|
||||
|
||||
|
||||
class GC(Cell):
|
||||
def __init__(self, x, y, max_rubbish, yellow=0, green=0, blue=0):
|
||||
Cell.__init__(self, x, y, max_rubbish, yellow, green, blue)
|
||||
|
||||
def movement(self, environment, x = None ,y = None):
|
||||
if((x,y) == (None, None)):
|
||||
x = self.x
|
||||
y = self.y
|
||||
|
||||
movement = {
|
||||
"right": (x + 1, y) if x + 1 < GRID_WIDTH and type(environment[x + 1][y]) == Road else (x, y),
|
||||
"left": (x - 1, y) if x - 1 >= 0 and type(environment[x - 1][y]) == Road else (x, y),
|
||||
"down": (x, y + 1) if y + 1 < GRID_HEIGHT and type(environment[x][y + 1]) == Road else (x, y),
|
||||
"up": (x, y - 1) if y - 1 >= 0 and type(environment[x][y - 1]) == Road else (x, y)
|
||||
}
|
||||
|
||||
forbidden_movement = {
|
||||
"right": "left",
|
||||
"left": "right",
|
||||
"up": "down",
|
||||
"down": "up"
|
||||
}
|
||||
|
||||
return (movement, forbidden_movement)
|
||||
|
||||
def check_moves(self, direction, environment, x = None, y = None):
|
||||
if((x,y) == (None, None)):
|
||||
x = self.x
|
||||
y = self.y
|
||||
|
||||
print(environment)
|
||||
|
||||
return ([dir for dir in self.movement(environment)[0] if self.movement(environment)[0][dir] != (x,y) and dir != self.movement(environment)[1][direction]])
|
||||
|
||||
def move(self, direction, environment):
|
||||
|
@ -1,2 +1,9 @@
|
||||
def DFS(grid, avaliable_movement, starting_point):
|
||||
x, y = starting_point
|
||||
def DFS(grid, avaliable_movement, gc_moveset):
|
||||
if(moveset[-1] == (1,4) or len(avaliable_movement) == 0):
|
||||
return gc_moveset
|
||||
|
||||
x,y = gc_moveset[-1]
|
||||
move = avaliable_movement.pop()
|
||||
|
||||
## TUTAJ ZAIMPORTOWAC MOVEMENT
|
||||
|
16
utilities.py
Normal file
16
utilities.py
Normal file
@ -0,0 +1,16 @@
|
||||
def movement(environment, x ,y):
|
||||
movement = {
|
||||
"right": (x + 1, y) if x + 1 < GRID_WIDTH and type(environment[x + 1][y]) == Road else (x, y),
|
||||
"left": (x - 1, y) if x - 1 >= 0 and type(environment[x - 1][y]) == Road else (x, y),
|
||||
"down": (x, y + 1) if y + 1 < GRID_HEIGHT and type(environment[x][y + 1]) == Road else (x, y),
|
||||
"up": (x, y - 1) if y - 1 >= 0 and type(environment[x][y - 1]) == Road else (x, y)
|
||||
}
|
||||
|
||||
forbidden_movement = {
|
||||
"right": "left",
|
||||
"left": "right",
|
||||
"up": "down",
|
||||
"down": "up"
|
||||
}
|
||||
|
||||
return (movement, forbidden_movement)
|
Loading…
Reference in New Issue
Block a user