コード例 #1
0
ファイル: AI.java プロジェクト: hcodename47/open-ig
 @Override
 public void onResearchStateChange(ResearchType rt, ResearchState state) {
   // if the user switched to this guy.
   if (state == ResearchState.COMPLETE) {
     if (rt.category.main != ResearchMainCategory.BUILDINGS) {
       p.addProductionHistory(rt);
     }
   }
 }
コード例 #2
0
ファイル: AI.java プロジェクト: hcodename47/open-ig
  @Override
  public ResponseMode diplomacy(
      Player other, NegotiateType about, ApproachType approach, Object argument) {
    DiplomaticRelation r = w.getRelation(p, other);
    if (r == null || !r.full) {
      return ResponseMode.NO;
    }

    //		PlayerStrength senderStrength = getStrength(other);

    PlanetStatistics ownStats = p.getPlanetStatistics(null);

    //		PlanetStatistics senderStas = computeVisibleStats(other);

    double rnd = ModelUtils.random();
    double rel = r.value;

    Trait t = other.traits.trait(TraitKind.DIPLOMACY);
    if (t != null) {
      rel = rel * (1 + t.value / 100);
      rel = Math.min(100, Math.max(0, rel));
    }

    switch (about) {
      case DIPLOMATIC_RELATIONS:
        if (rnd < rel / 100 && rel < p.warThreshold + 10) {
          return ResponseMode.MAYBE;
        } else if (rnd < rel / 100) {
          return ResponseMode.YES;
        }
        break;
      case ALLY:
        Player p3 = (Player) argument;
        if (p3.group == p.group) {
          return ResponseMode.NO;
        }
        DiplomaticRelation r2 = w.getRelation(p, p3);
        if (r2 != null) {
          if (rnd < 0.5 && rel >= p.warThreshold + 35 && r2.value < rel) {
            return ResponseMode.YES;
          }
        }
        break;
      case DARGSLAN:
        if (rnd < rel / 100 && rel >= 75 && !p.id.equals("Dargslan")) {
          return ResponseMode.YES;
        }
        break;
      case MONEY:
        if (rnd < rel / 100 || p.money() < 100000) {
          return ResponseMode.YES;
        }
        break;
      case SURRENDER:
        if (rnd < 0.1 && ownStats.planetCount < 2 && rel < p.warThreshold) {
          return ResponseMode.YES;
        }
        break;
      case TRADE:
        if (rnd < rel / 100) {
          return ResponseMode.YES;
        }
        break;
      default:
    }
    return ResponseMode.NO;
  }