コード例 #1
0
def canEnemyBotSeePath(instance, bot, command):
    enemyRange = instance.level.firingDistance
    ourDestination = command.target[0]
    #TODO improve to a path.
    points = visibility.line(bot.position, ourDestination)
    for enemyBot in instance.game.enemyTeam.members:
        count = 0
        for point in points:
            if count%7 == 0 and sightCheck2(instance, enemyBot, point) == True:
                print 'THEY SEE'
                return 1
    return 0
コード例 #2
0
ファイル: arlecks.py プロジェクト: alexschlueter/arlecksbot
 def updateWeights(self, bot, sneakW, normalW):
     first = bot.position + self.level.firingDistance * self.angledVector(bot.facingDirection, self.level.fieldOfViewAngles[BotInfo.STATE_DEFENDING] / 2)
     second = bot.position + self.level.firingDistance * self.angledVector(bot.facingDirection, self.level.fieldOfViewAngles[BotInfo.STATE_DEFENDING] / -2)
     nodes = []
     for box in line(bot.position, first):
         nodes.append(self.getNodeIndex(Vector2(box[0], box[1])))
             #sys.stdout.write(str(box) + '\n')
             
     for box in line(bot.position, second):
         nodes.append(self.getNodeIndex(Vector2(box[0], box[1])))
     for box in line(first, second):
         nodes.append(self.getNodeIndex(Vector2(box[0], box[1])))
             
     for a, b in self.graphSneak.edges_iter(nodes):
         #sys.stdout.write(str(edge) + ' ')
         #sys.stdout.write(str(Vector2(a % self.graphNormal.graph["map_width"], int(a / self.graphNormal.graph["map_width"]))) + ' ' + str(Vector2(b % self.graphNormal.graph["map_width"], int(b / self.graphNormal.graph["map_width"]))) + '\n')
         self.graphSneak[a][b]['weight'] = sneakW
     for a, b in self.graphNormal.edges_iter(nodes):
         #sys.stdout.write(str(edge) + ' ')
         #sys.stdout.write(str(Vector2(a % self.graphNormal.graph["map_width"], int(a / self.graphNormal.graph["map_width"]))) + ' ' + str(Vector2(b % self.graphNormal.graph["map_width"], int(b / self.graphNormal.graph["map_width"]))) + '\n')
         self.graphNormal[a][b]['weight'] = normalW
     return nodes