Exemplo n.º 1
0
double VillageControl::Villain::getTriggerValue(const Trigger& trigger, const VillageControl* self) const {
  double powerMaxProb = 1.0 / 10000; // rather small chance that they attack just because you are strong
  double victimsMaxProb = 1.0 / 500;
  double populationMaxProb = 1.0 / 500;
  double goldMaxProb = 1.0 / 500;
  double stolenMaxProb = 1.0 / 300;
  double entryMaxProb = 1.0 / 20.0;
  switch (trigger.getId()) {
    case AttackTriggerId::TIMER: 
      return collective->getTime() >= trigger.get<int>() ? 0.05 : 0;
    case AttackTriggerId::ROOM_BUILT: 
      return collective->getSquares(trigger.get<SquareType>()).size() *
          getRoomProb(trigger.get<SquareType>().getId());
    case AttackTriggerId::POWER: 
      return powerMaxProb * powerClosenessFun(self->getCollective()->getDangerLevel(), collective->getDangerLevel());
    case AttackTriggerId::SELF_VICTIMS:
      return victimsMaxProb * victimsFun(self->victims.count(collective) ? self->victims.at(collective) : 0, 0);
    case AttackTriggerId::ENEMY_POPULATION:
      return populationMaxProb * populationFun(
          collective->getCreatures(MinionTrait::FIGHTER).size(), trigger.get<int>());
    case AttackTriggerId::GOLD:
      return goldMaxProb * goldFun(collective->numResource(Collective::ResourceId::GOLD), trigger.get<int>());
    case AttackTriggerId::STOLEN_ITEMS:
      return stolenMaxProb 
          * stolenItemsFun(self->stolenItemCount.count(collective) ? self->stolenItemCount.at(collective) : 0);
    case AttackTriggerId::ENTRY:
      return entryMaxProb * self->entries.count(collective);
  }
  return 0;
}
Exemplo n.º 2
0
double VillageControl::Villain::getTriggerValue(const Trigger& trigger, const VillageControl* self) const {
  double powerMaxProb = 1.0 / 10000; // rather small chance that they attack just because you are strong
  double victimsMaxProb = 1.0 / 500;
  double populationMaxProb = 1.0 / 500;
  double goldMaxProb = 1.0 / 1000;
  double stolenMaxProb = 1.0 / 300;
  double entryMaxProb = 1.0 / 20.0;
  double finishOffMaxProb = 1.0 / 1000;
  double proximityMaxProb = 1.0 / 5000;
  if (Collective* collective = self->getEnemyCollective())
    switch (trigger.getId()) {
      case AttackTriggerId::TIMER: 
        return collective->getGlobalTime() >= trigger.get<int>() ? 0.05 : 0;
      case AttackTriggerId::ROOM_BUILT: 
        return collective->getSquares(trigger.get<SquareType>()).size() *
          getRoomProb(trigger.get<SquareType>().getId());
      case AttackTriggerId::POWER: 
        return powerMaxProb *
            powerClosenessFun(self->getCollective()->getDangerLevel(), collective->getDangerLevel());
      case AttackTriggerId::FINISH_OFF:
        return finishOffMaxProb * getFinishOffProb(self->maxEnemyPower, collective->getDangerLevel(),
            self->getCollective()->getDangerLevel());
      case AttackTriggerId::SELF_VICTIMS:
        return victimsMaxProb * victimsFun(self->victims, 0);
      case AttackTriggerId::ENEMY_POPULATION:
        return populationMaxProb * populationFun(
            collective->getCreatures(MinionTrait::FIGHTER).size(), trigger.get<int>());
      case AttackTriggerId::GOLD:
        return goldMaxProb * goldFun(collective->numResource(Collective::ResourceId::GOLD), trigger.get<int>());
      case AttackTriggerId::STOLEN_ITEMS:
        return stolenMaxProb 
          * stolenItemsFun(self->stolenItemCount);
      case AttackTriggerId::ENTRY:
        return entryMaxProb * self->entries;
      case AttackTriggerId::PROXIMITY:
        if (!collective->getGame()->isSingleModel() &&
            collective->getGame()->getModelDistance(collective, self->getCollective()) <= 1)
          return proximityMaxProb;
        else
          return 0;
    }
  return 0;
}