diff --git a/classes/ai.py b/classes/ai.py index beeadca..a7d34c9 100644 --- a/classes/ai.py +++ b/classes/ai.py @@ -54,11 +54,11 @@ class AI: if keys[pygame.K_DOWN]: self.saper.move(0) elif keys[pygame.K_UP]: - self.saper.move(180) + self.saper.move() elif keys[pygame.K_LEFT]: - self.saper.move(270) + self.saper.rotate("left") elif keys[pygame.K_RIGHT]: - self.saper.move(90) + self.saper.rotate("right") def chaos_controls(self): dir = randrange(4) @@ -75,8 +75,13 @@ class AI: def way_controls(self): if len(self.the_way)>0: way = self.the_way.pop(0) - self.saper.rotate(way) - self.saper.move() + if way=="move": + self.saper.move() + elif way=="left" or way=="right": + self.saper.rotate(way) + else: + self.saper.rotate(way) + self.saper.move() elif len(self.current_map.mines)!=0: self.bfs() diff --git a/classes/bfs.py b/classes/bfs.py index a02c4c3..3c3482b 100644 --- a/classes/bfs.py +++ b/classes/bfs.py @@ -14,9 +14,9 @@ class BFS: def successor(self, current_position): new_nodes = [] neighbours_list = self.agent.sensor(current_position[0], current_position[1]) - print(neighbours_list[0]) - print(neighbours_list[1]) - print(neighbours_list[2]) + #print(neighbours_list[0]) + #print(neighbours_list[1]) + #print(neighbours_list[2]) if neighbours_list[1][0] not in ['wall', 'cliff_south', 'cliff_east', 'cliff_north', 'cliff_west']: @@ -60,13 +60,13 @@ class BFS: #print(f'my parent is {tmp_node[1].get_parent()}') tmp_node_position = tmp_node[1].get_position() - print(f'Position of our node {tmp_node_position[:2]}') + #print(f'Position of our node {tmp_node_position[:2]}') visited_position.append(tmp_node_position[:2]) #print(f'visited position: {visited_position}') if tmp_node_position[:2] == goaltest: - print(' we find node') + #print(' we find node') # print(visited_position) #print(fringe) @@ -84,12 +84,12 @@ class BFS: explored.append(tmp_node) neighbours_list_of_our_node = self.successor(tmp_node_position[:2]) - print(neighbours_list_of_our_node) + #print(neighbours_list_of_our_node) for node_ in neighbours_list_of_our_node: # jesli pozucja wezla nie jest w fringe i nie jest w explored if [node_[0], node_[1]] not in visited_position and node_[0] >= 0 and node_[1] >=0: counter += 1 - print([node_[0], node_[1]]) + #print([node_[0], node_[1]]) x = node.Node(tmp_node, None, [node_[0], node_[1]]) # action heapq.heappush(fringe, (counter, x)) # time.sleep(0.5) diff --git a/classes/minesweeper.py b/classes/minesweeper.py index e591683..415897e 100644 --- a/classes/minesweeper.py +++ b/classes/minesweeper.py @@ -272,6 +272,11 @@ class Minesweeper: dirr=270 elif dir=="E": dirr=90 + + elif dir=="left": + dirr = (self.rotation_degrees+90) % 360 + elif dir=="right": + dirr = (self.rotation_degrees-90) % 360 else: return