Graphsearch and successor - version 1.1
This commit is contained in:
parent
4a2696bd89
commit
3f96e3279a
@ -180,16 +180,34 @@ def MouseClickEvent(event):
|
|||||||
|
|
||||||
node = nd.Node()
|
node = nd.Node()
|
||||||
if len(fringe) == 0:
|
if len(fringe) == 0:
|
||||||
node.state.coord = field.small_field_canvas.coords(player.image_canvas_id)
|
node.state.coord = start_position
|
||||||
node.state.direction = "east"
|
node.state.direction = "east"
|
||||||
else:
|
else:
|
||||||
node = fringe[len(fringe) - 1]
|
# ZLE - NAPRAWIC
|
||||||
|
states = []
|
||||||
|
for k in range(0, len(fringe)):
|
||||||
|
new_state = fringe[k].state.coord
|
||||||
|
states.append(new_state)
|
||||||
|
index = states.index(start_position)
|
||||||
|
start_node = fringe[index]
|
||||||
|
|
||||||
|
node.state.coord = start_node.state.coord
|
||||||
|
node.state.direction = start_node.state.direction
|
||||||
|
|
||||||
fringe.clear()
|
fringe.clear()
|
||||||
explored.clear()
|
explored.clear()
|
||||||
|
|
||||||
fringe = nd.graphsearch(fringe, explored, node.state, end_state_coord)
|
fringe = nd.graphsearch(fringe, explored, node.state, end_state_coord)
|
||||||
|
|
||||||
|
states = []
|
||||||
|
for k in range(0, len(fringe)):
|
||||||
|
new_state = [fringe[k].state.coord, fringe[k].state.direction]
|
||||||
|
states.append(new_state)
|
||||||
|
for i in range(0, len(states)):
|
||||||
|
if states[i] in states[i + 1:]:
|
||||||
|
print("\nDooble element: {}\n".format(states[i]))
|
||||||
|
|
||||||
|
print("\nLista fringe nie zawiera powtorzen!\n")
|
||||||
for i in range(0, len(fringe)):
|
for i in range(0, len(fringe)):
|
||||||
print('Node{} = State: {} {}, Parent: {} {}, Action: {}'.format(i + 1, fringe[i].state.coord, fringe[i].state.direction, fringe[i].parent.coord, fringe[i].parent.direction, fringe[i].action))
|
print('Node{} = State: {} {}, Parent: {} {}, Action: {}'.format(i + 1, fringe[i].state.coord, fringe[i].state.direction, fringe[i].parent.coord, fringe[i].parent.direction, fringe[i].action))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user