Пример #1
0
  @Override
  /** */
  public List<AttackTransferMove> getAttackTransferMoves(BotState state, Long timeOut) {
    return MovesCalculator.getCalculatedMoves().attackTransferMoves;

    /*List<AttackTransferMove> attackTransferMoves = new ArrayList<AttackTransferMove>();
     String myName = state.getMyPlayerName();
     String expression = argExpression;//"((0-(allegiance)+(1/(0-(superRegionAllegianceScore))/(1/(SuperRegionScore)*Math.sqrt(numFromSoldiers))))+superRegionAllegianceScore)";
    // String expression = "0-(Math.exp((numFromSoldiers+allegiance)))";
     int maxmoves = 10;

     try {
         engine.eval("function tree(SuperRegionScore, numFromSoldiers, numToSoldiers, superRegionAllegianceScore, regionNeighbourAllegianceScore,  allegiance) { return " + expression + "}");
         for (Region fromRegion : state.getVisibleMap().getRegions()) {
             if (fromRegion.ownedByPlayer(myName) && fromRegion.getArmies() > 6) {
                 HashMap<Region, Double> scoredRegions = new HashMap<>();

                 for (Region possibleToRegion : fromRegion.getNeighbors()) {
                     scoredRegions.put(possibleToRegion, (Double) engine.eval("tree("
                             + getSuperRegionScore(possibleToRegion, state) + ","
                             + getNumSoldiers(fromRegion, state) + "," +
                             + getNumSoldiers(possibleToRegion, state) + ","
                             + getSuperRegionAllegianceScore(possibleToRegion, state) + ","
                             + getRegionNeighbourAllegianceScore(possibleToRegion, state) + ","
                             + getAllegiance(possibleToRegion, state) + ");"));
                 }
                 attackTransferMoves.add(new AttackTransferMove(myName, fromRegion, getMaxFromHashMap(scoredRegions).getKey(), fromRegion.getArmies() - 1));
             }
         }
     } catch (ScriptException e) {
         e.printStackTrace();
     }
     return attackTransferMoves;*/
  }
Пример #2
0
  @Override
  /**
   * This method is called for at first part of each round. This example puts two armies on random
   * regions until he has no more armies left to place.
   *
   * @return The list of PlaceArmiesMoves for one round
   */
  public List<PlaceArmiesMove> getPlaceArmiesMoves(BotState state, Long timeOut) {

    HistoryTracker.botState = state;
    Debug.printDebugOutputBeginTurn();
    OpponentDeploymentGuesser.guessOpponentDeployment();
    FogRemover.removeFog();
    HistoryTracker.botState.workingMap = HistoryTracker.botState.getVisibleMap().getMapCopy();
    DistanceCalculator.calculateDistanceToBorder();
    SuperRegionValueCalculator.calculateSuperRegionValues();
    RegionValueCalculator.calculateRegionValues();
    MovesCalculator.calculateMoves(argExpression);
    Debug.printDebugOutput();
    HistoryTracker.botState.lastVisibleMap = HistoryTracker.botState.getVisibleMap().getMapCopy();
    return MovesCalculator.getCalculatedMoves().getPlaceArmiesMoves();

    /*        HashMap<Region, Double> scoredRegions = new HashMap<>();
    ArrayList<PlaceArmiesMove> placeArmiesMoves = new ArrayList<PlaceArmiesMove>();
    String myName = state.getMyPlayerName();

    String expression = "Math.sqrt(0-((Math.sqrt(1/((superRegionAllegianceScore*superRegionAllegianceScore)))/(SuperRegionScore*Math.sqrt((numFromSoldiers+Math.sqrt(AvgNeighbourScore)))))))";
    try {
        engine.eval("function tree(AvgNeighbourScore, SuperRegionScore, numFromSoldiers, superRegionAllegianceScore, regionNeighbourAllegianceScore) { return " + expression + "}");
        for (Region region : state.getVisibleMap().getRegions()) {
            if (region.ownedByPlayer(myName))
                scoredRegions.put(region, (Double) engine.eval("tree("
                        + getAvgNeighbourScore(region, state) + ","
                        + getSuperRegionScore(region, state) + ","
                        + getNumSoldiers(region, state) + ","
                        + getSuperRegionAllegianceScore(region, state) + ","
                        + getRegionNeighbourAllegianceScore(region, state) + ");"));
        }
    } catch (ScriptException e) {
        e.printStackTrace();
    }
    int availableUnits = state.getStartingArmies();
    int firstArmy, secondArmy = 0;

    if (availableUnits % 2 == 0) {
        firstArmy = availableUnits / 2;
        secondArmy = availableUnits / 2;
    } else {
        firstArmy = (availableUnits + 1) / 2;
        secondArmy = (availableUnits - 1) / 2;
    }

    //place first half of units
    Region bestRegion = getMaxFromHashMap(scoredRegions).getKey();
    placeArmiesMoves.add(new PlaceArmiesMove(myName, bestRegion, firstArmy));
    scoredRegions.remove(bestRegion);
    //place second half
    placeArmiesMoves.add(new PlaceArmiesMove(myName, getMaxFromHashMap(scoredRegions).getKey(), secondArmy));

    return placeArmiesMoves;*/
  }