(self, client_connection)
Use Dijkstra's algorithm to find the optimal sequence of motions.

        :param client_connection: If another pathfinding request is waiting on this
            connection, exit (returning None) as soon as possible. This cancels the
            pathfinding, moving on to the new request immediately.
Use Dijkstra's algorithm to find the optimal sequence of motions.
Use Dijkstra s algorithm to find the optimal sequence of motions .
def find_path(self, client_connection):
        """
        Use Dijkstra's algorithm to find the optimal sequence of motions.

        :param client_connection: If another pathfinding request is waiting on this
            connection, exit (returning None) as soon as possible. This cancels the
            pathfinding, moving on to the new request immediately.
        """
        while len(self._open_queue) > 0 and not client_connection.poll():
            current_node_key, current_distance = self._open_queue.popitem()
            current_node = self._open_nodes.pop(current_node_key)
            self._closed_nodes.add(current_node_key)

            if current_node.is_target():
                return current_node.reconstruct_path()

            for node in current_node.get_neighbours():
                if node.key in self._closed_nodes:
                    continue

                new_distance = current_distance + current_node.motion_weight(
                    node.came_by_motion
                )
                if (
                    node.key not in self._open_nodes
                    or new_distance < self._open_queue[node.key]
                ):
                    node.set_came_from(current_node)
                    self._open_nodes[node.key] = node
                    self._open_queue[node.key] = new_distance
def find_path ( self , client_connection ) : while len ( self . _open_queue ) > 0 and not client_connection . poll ( ) : current_node_key , current_distance = self . _open_queue . popitem ( ) current_node = self . _open_nodes . pop ( current_node_key ) self . _closed_nodes . add ( current_node_key ) if current_node . is_target ( ) : return current_node . reconstruct_path ( ) for node in current_node . get_neighbours ( ) : if node . key in self . _closed_nodes : continue new_distance = current_distance + current_node . motion_weight ( node . came_by_motion ) if ( node . key not in self . _open_nodes or new_distance < self . _open_queue [ node . key ] ) : node . set_came_from ( current_node ) self . _open_nodes [ node . key ] = node self . _open_queue [ node . key ] = new_distance