Пример #1
0
  def startTurn(self):
    from GameObject import Bot
    from GameObject import Frame
    from GameObject import Wall
    from GameObject import Type

    BaseAI.bots = [Bot(library.getBot(self.connection, i)) for i in xrange(library.getBotCount(self.connection))]
    BaseAI.frames = [Frame(library.getFrame(self.connection, i)) for i in xrange(library.getFrameCount(self.connection))]
    BaseAI.walls = [Wall(library.getWall(self.connection, i)) for i in xrange(library.getWallCount(self.connection))]
    BaseAI.types = [Type(library.getType(self.connection, i)) for i in xrange(library.getTypeCount(self.connection))]

    if not self.initialized:
      self.initialized = True
      self.init()
    BaseAI.iteration += 1;
    if self.runGenerator:
      try:
        return self.runGenerator.next()
      except StopIteration:
        self.runGenerator = None
    r = self.run()
    if hasattr(r, '__iter__'):
      self.runGenerator = r
      return r.next()
    return self.run()
Пример #2
0
 def startTurn(self):
   from gameObjects import Wall, Crate, Weapon, Human, Zombie, Airstrike, Spawnzone
   
   BaseAI.walls = [Wall(library.getWalls(i)) for i in xrange(library.getWallCount())]
   BaseAI.crates = [Crate(library.getCrates(i)) for i in xrange(library.getCrateCount())]
   BaseAI.weapons = [Weapon(library.getWeapons(i)) for i in xrange(library.getWeaponCount())]
   BaseAI.humans = [Human(library.getHumans(i)) for i in xrange(library.getHumanCount())]
   BaseAI.zombies = [Zombie(library.getZombies(i)) for i in xrange(library.getZombieCount())]
   BaseAI.airstrikes = [Airstrike(library.getAirstrikes(i)) for i in xrange(library.getAirstrikeCount())]
   BaseAI.spawnzones = [Spawnzone(library.getSpawnzones(i)) for i in xrange(library.getSpawnzoneCount())]
   
   if self.turnNum() == 1:
     self.init()
     if not library.isHuman():
       return 1
   if library.isHuman():
     return self.runHuman()
   else:
     return self.runZombie()
Пример #3
0
    def startTurn(self):
        from GameObject import Bot
        from GameObject import Frame
        from GameObject import Wall
        from GameObject import Type

        BaseAI.bots = [
            Bot(library.getBot(self.connection, i))
            for i in xrange(library.getBotCount(self.connection))
        ]
        BaseAI.frames = [
            Frame(library.getFrame(self.connection, i))
            for i in xrange(library.getFrameCount(self.connection))
        ]
        BaseAI.walls = [
            Wall(library.getWall(self.connection, i))
            for i in xrange(library.getWallCount(self.connection))
        ]
        BaseAI.types = [
            Type(library.getType(self.connection, i))
            for i in xrange(library.getTypeCount(self.connection))
        ]

        if not self.initialized:
            self.initialized = True
            self.init()
        BaseAI.iteration += 1
        if self.runGenerator:
            try:
                return self.runGenerator.next()
            except StopIteration:
                self.runGenerator = None
        r = self.run()
        if hasattr(r, '__iter__'):
            self.runGenerator = r
            return r.next()
        return r