Exemplo n.º 1
0
 def navigateTo(self, x, y, closeEnough=0):
     self.__waypoints = pathfinder.planPath(self.suit.getCurrentPos(),
                                            (x, y), closeEnough)
     if self.__waypoints:
         self.__walkToNextWaypoint()
         return True
     return False
 def navigateTo(self, x, y, closeEnough=0):
     self.__waypoints = pathfinder.planPath(self.suit.getCurrentPos(),
                                            (x, y), closeEnough)
     if self.__waypoints:
         self.__walkToNextWaypoint()
         return True
     else:
         return False
Exemplo n.º 3
0
def planPathTo():
    fromPos = getattr(base.localAvatar, '_planPos', None)
    if not fromPos:
        return 'No planFrom point set!'
    toPos = base.localAvatar.getPos()
    path = pathfinder.planPath((fromPos.getX(), fromPos.getY()),
                               (toPos.getX(), toPos.getY()))
    if path is None:
        return 'Pathfinding failed -- no path exists.'
    segs = LineSegs('plannedPath')
    segs.setColor(1, 1, 0)
    segs.moveTo(fromPos.getX(), fromPos.getY(), LINK_HEIGHT - 0.1)
    for x, y in path:
        segs.drawTo(x, y, LINK_HEIGHT - 0.1)

    for np in render.findAllMatches('**/plannedPath'):
        np.removeNode()

    render.attachNewNode(segs.create())
    return 'Set planned path "to".'
def planPathTo():
    fromPos = getattr(base.localAvatar, '_planPos', None)
    if not fromPos:
        return 'No planFrom point set!'

    toPos = base.localAvatar.getPos()

    path = pathfinder.planPath((fromPos.getX(), fromPos.getY()),
                               (toPos.getX(), toPos.getY()))
    if path is None:
        return 'Pathfinding failed -- no path exists.'

    segs = LineSegs('plannedPath')
    segs.setColor(1, 1, 0)

    segs.moveTo(fromPos.getX(), fromPos.getY(), LINK_HEIGHT-0.1)
    for x, y in path:
        segs.drawTo(x, y, LINK_HEIGHT-0.1)

    for np in render.findAllMatches('**/plannedPath'):
        np.removeNode()
    render.attachNewNode(segs.create())
    return "Set planned path \"to\"."
Exemplo n.º 5
0
#!/usr/bin/env python2

# This is a "pathfinding daemon" for parallelism in the invasion.
import sys
from InvasionPathDataAI import pathfinder

while True:
    navFrom, navTo, radius = input()
    path = pathfinder.planPath(navFrom, navTo, radius)
    print path
    sys.stdout.flush()