Example #1
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
Example #2
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
Example #3
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 #4
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 #5
0
  def startTurn(self):
    from GameObject import Mappable
    from GameObject import Creature
    from GameObject import Plant
    from GameObject import Player

    BaseAI.mappables = [Mappable(library.getMappable(self.connection, i)) for i in xrange(library.getMappableCount(self.connection))]
    BaseAI.creatures = [Creature(library.getCreature(self.connection, i)) for i in xrange(library.getCreatureCount(self.connection))]
    BaseAI.plants = [Plant(library.getPlant(self.connection, i)) for i in xrange(library.getPlantCount(self.connection))]
    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(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 #6
0
  def startTurn(self):
    from GameObject import Mappable
    from GameObject import Tile
    from GameObject import Species
    from GameObject import Fish
    from GameObject import Player

    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.speciesList = [Species(library.getSpecies(self.connection, i)) for i in xrange(library.getSpeciesCount(self.connection))]
    BaseAI.fishes = [Fish(library.getFish(self.connection, i)) for i in xrange(library.getFishCount(self.connection))]
    BaseAI.players = [Player(library.getPlayer(self.connection, i)) for i in xrange(library.getPlayerCount(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