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.Road import Road
|
||||||
from DataModels.House import House
|
from DataModels.House import House
|
||||||
from DataModels.Dump import Dump
|
from DataModels.Dump import Dump
|
||||||
<<<<<<< Updated upstream
|
|
||||||
from config import GRID_WIDTH, GRID_HEIGHT, DELAY, CLOSE_ON_END
|
from config import GRID_WIDTH, GRID_HEIGHT, DELAY, CLOSE_ON_END
|
||||||
from utilities import movement, check_moves, save_moveset
|
from utilities import movement, check_moves, save_moveset
|
||||||
from vowpal_utils import parse_list, MAP_CONTENT
|
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.DFS import DFS
|
||||||
from Traversal.BestFS import BestFS
|
from Traversal.BestFS import BestFS
|
||||||
from Traversal.BFS import BFS
|
from Traversal.BFS import BFS
|
||||||
@ -63,11 +58,7 @@ class GC(Cell):
|
|||||||
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||||
elif mode == "BFS":
|
elif mode == "BFS":
|
||||||
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||||
<<<<<<< Updated upstream
|
|
||||||
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||||
=======
|
|
||||||
whole_result.extend(result)
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
element_list.append(house)
|
element_list.append(house)
|
||||||
|
|
||||||
MAP_CONTENT[house.y][house.x] = 'V'
|
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)
|
dump,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
||||||
elif mode == "BFS":
|
elif mode == "BFS":
|
||||||
dump,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
dump,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
||||||
<<<<<<< Updated upstream
|
|
||||||
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||||
element_list.append(dump)
|
element_list.append(dump)
|
||||||
=======
|
|
||||||
whole_result.extend(result)
|
|
||||||
element_list.append(dump)
|
|
||||||
self.moves.extend(parse_list(element_list))
|
|
||||||
for x in element_list:
|
for x in element_list:
|
||||||
x.unvisited = True
|
x.unvisited = True
|
||||||
>>>>>>> Stashed changes
|
|
||||||
self.moves.reverse()
|
self.moves.reverse()
|
||||||
save_moveset(self.moves)
|
save_moveset(self.moves)
|
||||||
|
|
||||||
@ -148,9 +133,5 @@ class GC(Cell):
|
|||||||
self.collect(environment)
|
self.collect(environment)
|
||||||
self.moves.pop()
|
self.moves.pop()
|
||||||
return
|
return
|
||||||
<<<<<<< Updated upstream
|
direction = self.moves.pop()
|
||||||
self.move(self.moves[-1],environment)
|
self.move(direction,environment)
|
||||||
self.moves.pop()
|
|
||||||
=======
|
|
||||||
move(self.moves.pop(),enviromnent)
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
|
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)])
|
||||||
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]])
|
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):
|
def save_moveset(moveset):
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
path = '\moveset_data.json'
|
path = '\moveset_data.json'
|
||||||
@ -51,13 +51,3 @@ def save_moveset(moveset):
|
|||||||
f.seek(0)
|
f.seek(0)
|
||||||
json.dump(results, f, indent=1)
|
json.dump(results, f, indent=1)
|
||||||
f.close()
|
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