Exemple #1
0
  def startTurn(self):
    from GameObject import Player
    from GameObject import Mappable
    from GameObject import Plant
    from GameObject import Mutation

    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.plants = [Plant(library.getPlant(self.connection, i)) for i in xrange(library.getPlantCount(self.connection))]
    BaseAI.mutations = [Mutation(library.getMutation(self.connection, i)) for i in xrange(library.getMutationCount(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
Exemple #2
0
  def startTurn(self):
    from GameObject import Player
    from GameObject import Mappable
    from GameObject import Plant
    from GameObject import Mutation

    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.plants = [Plant(library.getPlant(self.connection, i)) for i in xrange(library.getPlantCount(self.connection))]
    BaseAI.mutations = [Mutation(library.getMutation(self.connection, i)) for i in xrange(library.getMutationCount(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
Exemple #3
0
    def startTurn(self):
        from GameObject import Plant

        BaseAI.plants = [Plant(library.getPlant(i)) for i in xrange(library.getPlantCount())]

        if not self.initialized:
            self.initialized = True
            self.init()
        BaseAI.iteration += 1;
        return self.run()