Exemplo n.º 1
0
  /**
   * Check if agent can do this action
   *
   * @note Cheating prevention
   */
  private ActionResult checkActions(int agId, int moves, boolean finishedOk) {
    if (agId < 3) {
      if (((aMoves -= moves) < 0) || (leftMoves[agId] -= moves) < 0) {
        logger.warning(
            "Error " + model.getAgNameBasedOnId(agId) + " trying to run more steps than alowed!!!");
        return ActionResult.ERROR;
      }
      if (aMoves == 0) {
        logger.info("Team A finished round");
      }
      if ((nMoves -= moves) <= 0) {
        logger.info("Round finished");
        initMoves();
        return ActionResult.ROUND_FINISHED;
      }
    } else {
      if (((bMoves -= moves) < 0) || (leftMoves[agId] -= moves) < 0) {
        logger.warning(
            "Error " + model.getAgNameBasedOnId(agId) + " trying to run more steps than alowed!!!");
        return ActionResult.ERROR;
      }
      if (bMoves == 0) {
        logger.info("Team B finished round");
      }
      if ((nMoves -= moves) <= 0) {
        logger.info("Round finished");
        initMoves();
        return ActionResult.ROUND_FINISHED;
      }
    }

    if (finishedOk) {
      return ActionResult.OK;
    } else {
      return ActionResult.MISTAKE;
    }
  }
Exemplo n.º 2
0
 private WorldModel(int w, int h, int nbAgs) {
   super(w, h, nbAgs);
   agCapacity[0] = 5;
   agCapacity[1] = 3;
   agCapacity[2] = 1;
   agCapacity[3] = 5;
   agCapacity[4] = 3;
   agCapacity[5] = 1;
   carryingGold[0] = 0;
   carryingGold[1] = 0;
   carryingGold[2] = 0;
   carryingGold[3] = 0;
   carryingGold[4] = 0;
   carryingGold[5] = 0;
   carryingWood[0] = 0;
   carryingWood[1] = 0;
   carryingWood[2] = 0;
   carryingWood[3] = 0;
   carryingWood[4] = 0;
   carryingWood[5] = 0;
   initMoves();
 }