Naprawiono bledy z rozwiazywania konfliktow
This commit is contained in:
parent
113b8ebea9
commit
6fbd5c76d0
@ -2,14 +2,9 @@ from DataModels.Cell import Cell
|
||||
from DataModels.Road import Road
|
||||
from DataModels.House import House
|
||||
from DataModels.Dump import Dump
|
||||
<<<<<<< Updated upstream
|
||||
from config import GRID_WIDTH, GRID_HEIGHT, DELAY, CLOSE_ON_END
|
||||
from utilities import movement, check_moves, save_moveset
|
||||
from vowpal_utils import parse_list, MAP_CONTENT
|
||||
=======
|
||||
from config import GRID_WIDTH, GRID_HEIGHT, DELAY
|
||||
from utilities import movement, check_moves, parse_list
|
||||
>>>>>>> Stashed changes
|
||||
from Traversal.DFS import DFS
|
||||
from Traversal.BestFS import BestFS
|
||||
from Traversal.BFS import BFS
|
||||
@ -63,11 +58,7 @@ class GC(Cell):
|
||||
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||
elif mode == "BFS":
|
||||
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||
<<<<<<< Updated upstream
|
||||
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||
=======
|
||||
whole_result.extend(result)
|
||||
>>>>>>> Stashed changes
|
||||
element_list.append(house)
|
||||
|
||||
MAP_CONTENT[house.y][house.x] = 'V'
|
||||
@ -79,16 +70,10 @@ class GC(Cell):
|
||||
dump,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
||||
elif mode == "BFS":
|
||||
dump,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
||||
<<<<<<< Updated upstream
|
||||
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||
element_list.append(dump)
|
||||
=======
|
||||
whole_result.extend(result)
|
||||
element_list.append(dump)
|
||||
self.moves.extend(parse_list(element_list))
|
||||
for x in element_list:
|
||||
x.unvisited = True
|
||||
>>>>>>> Stashed changes
|
||||
self.moves.reverse()
|
||||
save_moveset(self.moves)
|
||||
|
||||
@ -148,9 +133,5 @@ class GC(Cell):
|
||||
self.collect(environment)
|
||||
self.moves.pop()
|
||||
return
|
||||
<<<<<<< Updated upstream
|
||||
self.move(self.moves[-1],environment)
|
||||
self.moves.pop()
|
||||
=======
|
||||
move(self.moves.pop(),enviromnent)
|
||||
>>>>>>> Stashed changes
|
||||
direction = self.moves.pop()
|
||||
self.move(direction,environment)
|
||||
|
12
utilities.py
12
utilities.py
@ -23,7 +23,7 @@ def check_moves(environment, x,y,direction=None):
|
||||
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y)])
|
||||
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y) and dir != movement(environment,x,y)[1][direction]])
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
|
||||
def save_moveset(moveset):
|
||||
if platform.system() == 'Windows':
|
||||
path = '\moveset_data.json'
|
||||
@ -51,13 +51,3 @@ def save_moveset(moveset):
|
||||
f.seek(0)
|
||||
json.dump(results, f, indent=1)
|
||||
f.close()
|
||||
=======
|
||||
def parse_list(whole_result):
|
||||
moves = []
|
||||
parser = {[0,1]:"up",[0,-1]:"down",[1,0]:"right",[-1,0]:"left"}
|
||||
for x in len(whole_result)-1:
|
||||
x_subtraction = whole_result[x+1][0]-whole_result[x][0]
|
||||
y_subtraction = whole_result[x+1][1]-whole_result[x][1]
|
||||
moves.append(parser[[x_subtraction,y_subtraction]])
|
||||
return moves
|
||||
>>>>>>> Stashed changes
|
||||
|
Loading…
Reference in New Issue
Block a user