Example #1
0
  def startTurn(self):
    from GameObject import Player
    from GameObject import Mappable
    from GameObject import PumpStation
    from GameObject import Unit
    from GameObject import Tile
    from GameObject import UnitType

    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(self.connection))]
    BaseAI.mappables = [Mappable(library.getMappable(self.connection, i)) for i in xrange(library.getMappableCount(self.connection))]
    BaseAI.pumpStations = [PumpStation(library.getPumpStation(self.connection, i)) for i in xrange(library.getPumpStationCount(self.connection))]
    BaseAI.units = [Unit(library.getUnit(self.connection, i)) for i in xrange(library.getUnitCount(self.connection))]
    BaseAI.tiles = [Tile(library.getTile(self.connection, i)) for i in xrange(library.getTileCount(self.connection))]
    BaseAI.unitTypes = [UnitType(library.getUnitType(self.connection, i)) for i in xrange(library.getUnitTypeCount(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
Example #2
0
  def startTurn(self):
    from GameObject import Player
    from GameObject import Mappable
    from GameObject import Tile
    from GameObject import Trap
    from GameObject import Thief
    from GameObject import ThiefType
    from GameObject import TrapType

    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(self.connection))]
    BaseAI.mappables = [Mappable(library.getMappable(self.connection, i)) for i in xrange(library.getMappableCount(self.connection))]
    BaseAI.tiles = [Tile(library.getTile(self.connection, i)) for i in xrange(library.getTileCount(self.connection))]
    BaseAI.traps = [Trap(library.getTrap(self.connection, i)) for i in xrange(library.getTrapCount(self.connection))]
    BaseAI.thiefs = [Thief(library.getThief(self.connection, i)) for i in xrange(library.getThiefCount(self.connection))]
    BaseAI.thiefTypes = [ThiefType(library.getThiefType(self.connection, i)) for i in xrange(library.getThiefTypeCount(self.connection))]
    BaseAI.trapTypes = [TrapType(library.getTrapType(self.connection, i)) for i in xrange(library.getTrapTypeCount(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
Example #3
0
  def startTurn(self):
    from GameObject import Base
    from GameObject import Player
    from GameObject import Tile
    from GameObject import Virus

    BaseAI.bases = [Base(library.getBase(self.connection, i)) for i in xrange(library.getBaseCount(self.connection))]
    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(self.connection))]
    BaseAI.tiles = [Tile(library.getTile(self.connection, i)) for i in xrange(library.getTileCount(self.connection))]
    BaseAI.viruses = [Virus(library.getVirus(self.connection, i)) for i in xrange(library.getVirusCount(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
Example #4
0
  def startTurn(self):
    from GameObject import Pirate
    from GameObject import Player
    from GameObject import Port
    from GameObject import Ship
    from GameObject import Tile
    from GameObject import Treasure

    BaseAI.pirates = [Pirate(library.getPirate(self.connection, i)) for i in xrange(library.getPirateCount(self.connection))]
    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(self.connection))]
    BaseAI.ports = [Port(library.getPort(self.connection, i)) for i in xrange(library.getPortCount(self.connection))]
    BaseAI.ships = [Ship(library.getShip(self.connection, i)) for i in xrange(library.getShipCount(self.connection))]
    BaseAI.tiles = [Tile(library.getTile(self.connection, i)) for i in xrange(library.getTileCount(self.connection))]
    BaseAI.treasures = [Treasure(library.getTreasure(self.connection, i)) for i in xrange(library.getTreasureCount(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
Example #5
0
  def startTurn(self):
    from GameObject import Player
    from GameObject import Mappable
    from GameObject import Droid
    from GameObject import Tile
    from GameObject import ModelVariant

    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(self.connection))]
    BaseAI.mappables = [Mappable(library.getMappable(self.connection, i)) for i in xrange(library.getMappableCount(self.connection))]
    BaseAI.droids = [Droid(library.getDroid(self.connection, i)) for i in xrange(library.getDroidCount(self.connection))]
    BaseAI.tiles = [Tile(library.getTile(self.connection, i)) for i in xrange(library.getTileCount(self.connection))]
    BaseAI.modelVariants = [ModelVariant(library.getModelVariant(self.connection, i)) for i in xrange(library.getModelVariantCount(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