Exemplo n.º 1
0
  private void advancedStrategy(
      Agent a) { // afstand wordt bevoordeeld tov padlengte omwille van complexiteit

    if (a.getCarrying() > -1) {
      a.calcPath(
          calcXFromCoor(a.getCampLocation()),
          calcYFromCoor(a.getCampLocation())); // if carrying a Tilia, go to camp
    } else { // go pick up a tilia closest to position
      int coin = 0;
      if (a.isRed()) {
        if (coins_red.size() >= 1) {
          coin = coins_red.extractMin().getlocation();
        }

      } else {
        if (coins_blue.size() >= 1) {
          coin = coins_blue.extractMin().getlocation();
        }
      }
      if (coin == 0) {
        coin = a.getCampLocation();
      }
      a.calcPath(calcXFromCoor(coin), calcYFromCoor(coin));
    }
  }
Exemplo n.º 2
0
  private void simpleAStarStrategy(final Agent a) {

    if (a.getCarrying() > -1) {
      a.calcPath(
          calcXFromCoor(a.getCampLocation()),
          calcYFromCoor(a.getCampLocation())); // if carrying a Tilia, go to camp
    } else { // go pick up a random tilia
      ArrayList<Integer> coins = new ArrayList<Integer>(coinLocations.keySet());
      int coin;

      if (coins.size() > 1) {
        coin = coins.get(new Random().nextInt(coinLocations.size() - 1));
      } else if (coins.size() == 1) {
        coin = coins.get(0);
      } else {
        coin = a.getCampLocation();
      }
      a.calcPath(calcXFromCoor(coin), calcYFromCoor(coin));
    }
  }
Exemplo n.º 3
0
  private void hierarchicalStrategy(Agent a) {

    if (a.getCarrying() > -1) {
      a.calcPath(
          calcXFromCoor(a.getCampLocation()),
          calcYFromCoor(a.getCampLocation())); // if carrying a Tilia, go to camp
    } else { // go pick up a tilia closest to position
      int coin = 0;
      if (a.isRed()) {
        if (coins_red.size() >= 1) {
          coin = coins_red.extractMin().getlocation();
        }

      } else {
        if (coins_blue.size() >= 1) {
          coin = coins_blue.extractMin().getlocation();
        }
      }
      if (coin == 0) {
        coin = a.getCampLocation();
      }
      a.calcPath(calcXFromCoor(coin), calcYFromCoor(coin));
    }
  }