Working version
This commit is contained in:
parent
b7d463f0ec
commit
f358e3c86a
@ -108,6 +108,12 @@ class GC(Cell):
|
||||
if(output != None):
|
||||
[x,y],result,houses_list = output[0], output[1], output[2]
|
||||
self.moves.extend(result[1:])
|
||||
for i in range(len(dump_list)):
|
||||
available_movement = check_moves(environment, x, y)
|
||||
output = BestFS(environment, available_movement, [[x,y]], dump_list)
|
||||
if(output != None):
|
||||
[x,y],result,dump_list = output[0], output[1], output[2]
|
||||
self.moves.extend(result[1:])
|
||||
self.moves.reverse()
|
||||
|
||||
def make_actions_from_list(self,environment):
|
||||
|
@ -18,10 +18,6 @@ def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
||||
|
||||
x, y = gc_moveset[-1][0], gc_moveset[-1][1]
|
||||
|
||||
#if depth exceeded, return
|
||||
if(depth > 15 or len(available_movement) == 0):
|
||||
return
|
||||
|
||||
#calculate distance to the nearest object
|
||||
min_distance_goal = CalculateDistance([x,y], object_list)
|
||||
print(depth,min_distance_goal)
|
||||
@ -33,6 +29,10 @@ def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
||||
object_list.remove([cell,min_distance_goal[0]])
|
||||
return([x, y], gc_moveset, object_list)
|
||||
|
||||
#if depth exceeded, return
|
||||
if(depth > 15 or len(available_movement) == 0):
|
||||
return
|
||||
|
||||
#set preffered directions based on the closest object
|
||||
preffered_directions = []
|
||||
discouraged_directions = []
|
||||
@ -67,6 +67,8 @@ def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
||||
print("After sorting: "+str(available_movement))
|
||||
|
||||
for direction in available_movement:
|
||||
print("HH")
|
||||
print(depth,direction)
|
||||
x_next, y_next = movement(grid,x,y)[0][direction]
|
||||
available_movement_next = check_moves(grid, x_next,y_next,direction)
|
||||
gc_moveset_next = gc_moveset.copy()
|
||||
|
Loading…
Reference in New Issue
Block a user