GC now recognizes houses as he passes
This commit is contained in:
parent
b93d49fa96
commit
e2e09e4537
@ -38,10 +38,7 @@ class GC(Cell):
|
||||
for cell in row:
|
||||
goal = []
|
||||
if type(cell) == House and cell.container.is_full():
|
||||
goal.append([cell.x-1, cell.y])
|
||||
goal.append([cell.x+1, cell.y])
|
||||
goal.append([cell.x, cell.y-1])
|
||||
goal.append([cell.x, cell.y+1])
|
||||
goal.append([cell.x, cell.y])
|
||||
if len(self.moves) == 0:
|
||||
x = self.x
|
||||
y = self.y
|
||||
|
@ -9,3 +9,8 @@ class House(Cell):
|
||||
self.container.yellow, self.container.green, self.container.blue = collector.container.add(
|
||||
[self.container.yellow, self.container.green, self.container.blue])
|
||||
self.update_image()
|
||||
|
||||
def is_empty(self):
|
||||
if(self.container.yellow == self.container.green == self.container.blue == 0):
|
||||
return True
|
||||
else: return False
|
||||
|
@ -1,7 +1,29 @@
|
||||
from utilities import movement,check_moves
|
||||
from DataModels.House import House
|
||||
def DFS(grid, avaliable_movement, gc_moveset,goal):
|
||||
print(gc_moveset)
|
||||
if(gc_moveset[-1] in goal or len(avaliable_movement) == 0):
|
||||
print("Moveset: "+str(gc_moveset))
|
||||
|
||||
possible_goals = []
|
||||
a = gc_moveset[-1][0]
|
||||
b = gc_moveset[-1][1]
|
||||
possible_goals.append([a+1,b])
|
||||
possible_goals.append([a-1,b])
|
||||
possible_goals.append([a,b+1])
|
||||
possible_goals.append([a,b-1])
|
||||
|
||||
house_in_area = False
|
||||
|
||||
for location in possible_goals:
|
||||
try:
|
||||
if(type(grid[location[0]][location[1]]) == House):
|
||||
house_in_area = True
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
print(str(house_in_area) + " possible goals: " + str(possible_goals) + " gc_moveset: " + str(gc_moveset[-1]))
|
||||
|
||||
if(house_in_area or len(avaliable_movement) == 0):
|
||||
print("Do zwrocenia: ",gc_moveset)
|
||||
return gc_moveset
|
||||
x,y = gc_moveset[-1]
|
||||
|
Loading…
Reference in New Issue
Block a user