示例#1
0
 /*
  * Use a FortifyArmiesDecision to make this choice
  * @see riskarena.RiskBot#fortifyTerritory(int)
  */
 public void fortifyTerritory(int num_to_place) {
   eval.refresh(
       "fortifyTerritory() in Awesome"); // The game state has changed since last updating the
                                         // evaluator
   ArrayList<ArmyChange> choices = fortifier.decideAll(num_to_place);
   attackDecider.initTurn(); // New attack targets are chosen when new territories are being placed
   for (ArmyChange choice : choices) {
     to_game.sendInt(choice.ID());
     to_game.sendInt(choice.amount());
   }
 }
示例#2
0
 /*
  * @see riskarena.RiskBot#fortifyPosition()
  */
 public void fortifyPosition() {
   eval.refresh(
       "fortifyPosition() in Awesome"); // The game state has changed since last updating the
                                        // evaluator
   for (Integer i : posFortifier.decide()) {
     to_game.sendInt(i);
   }
 }
示例#3
0
  /*
   * Claim an unclaimed territory. At the moment this functionality is the same as
   * the Dumb player, and evaluation isn't used.
   * @see riskarena.RiskBot#claimTerritory()
   */
  public void claimTerritory() {
    CountryInfo[] countries = risk_info.getCountryInfo();
    int num_conts = risk_info.getNumContinents();

    // Calculate the percentages of territory ownership for each continent of:
    // taken by me [contID][0], taken by some enemy [contID][1], and unclaimed [contID][2]
    int counts[][] = new int[num_conts][3];
    for (int i = 0; i < num_conts; i++) {
      Arrays.fill(counts[i], 0);
    }
    for (int i = 0; i < countries.length; i++) {
      int counts_index = !countries[i].isTaken() ? 2 : 0;
      if (counts_index == 0) counts_index = countries[i].getPlayer() == risk_info.me() ? 0 : 1;
      counts[countries[i].getCont()][counts_index] += 1;
    }
    double ratios[][] = new double[num_conts][3];
    for (int i = 0; i < num_conts; i++) {
      for (int j = 0; j < 3; j++) {
        ratios[i][j] = ((double) counts[i][j]) / (counts[i][0] + counts[i][1] + counts[i][2]);
      }
    }

    int targetCont = -1; // Search for a target of interest
    double highest = -1.0;
    for (int i = 0; i < ratios.length; i++) {
      // Skip filled continents and ones already mostly claimed by others
      if (ratios[i][2] < .0000001 || ratios[i][1] > .2) continue;
      if (ratios[i][0] > highest) {
        highest = ratios[i][0];
        targetCont = i;
      }
    }
    // If no target continent was decided, choose the one with the lowest ratio of enemy territories
    if (targetCont == -1) {
      double lowest = 2.0;
      for (int i = 0; i < ratios.length; i++) {
        if (ratios[i][2] < .0000001) continue;
        if (ratios[i][1] < lowest) {
          lowest = ratios[i][1];
          targetCont = i;
        }
      }
    }
    for (int i = 0; i < countries.length; i++) {
      if (!countries[i].isTaken() && countries[i].getCont() == targetCont) {
        to_game.sendInt(i);
        return;
      }
    }
  }
示例#4
0
 /*
  * Choose the first possible card set given
  * @see riskarena.RiskBot#chooseCardSet(int[][])
  */
 public void chooseCardSet(int[][] possible_sets) {
   to_game.sendInt(0);
 }
示例#5
0
 /*
  * Yes, always choose to turn in a set when given a choice
  * @see riskarena.RiskBot#chooseToTurnInSet()
  */
 public void chooseToTurnInSet() {
   to_game.sendInt(1);
 }
示例#6
0
 /*
  * After a victory, always choose to occupy the gained territory with as many armies as possible
  * @see riskarena.RiskBot#fortifyAfterVictory(int, int, int, int)
  */
 public void fortifyAfterVictory(int attacker, int defender, int min, int max) {
   // Consider attacking again with the victorious army
   attackDecider.notifyOfVictory(attacker, defender);
   card.setVictory(true);
   to_game.sendInt(afterVictory.decide(attacker, defender, min, max));
 }
示例#7
0
 /*
  * Called to send the decision of which territory to attack (if any).
  * @see riskarena.RiskBot#launchAttack()
  */
 public void launchAttack() {
   eval.refresh("launchAttack() in Awesome"); // Refresh the evaluation of the game state
   for (Integer toSend : attackDecider.decide()) {
     to_game.sendInt(toSend);
   }
 }