Example #1
0
    def moveGoodForPlayer(self, player_id, move):
        if not self.moveValidForPlayer(player_id, move):
            return False

        player = self.players[player_id]
        playerGrid = list(util.coordToGrid(player.x, player.y))

        distance = Direction.distances[move]
        playerGrid[0] += distance[0]
        playerGrid[1] += distance[1]

        if not Map.gridInMap(*playerGrid):
            return False

        grid = self.game_map.grids[util.gridToPos(*playerGrid)]
        return grid.canPass()
Example #2
0
def find_successors(game_map, gridX, gridY):
    successors = []
    for direction in Direction.ALL:
        if direction == Direction.STOP:
            continue
        distance = Direction.distances[direction]
        newX = gridX + distance[0]
        newY = gridY + distance[1]
        if not Map.gridInMap(newX, newY):
            continue

        newPos = util.gridToPos(newX, newY)
        if game_map.grids[newPos].isWall():
            continue

        successors.append((direction, newPos))
    return successors