/** * @file Player.java * * @author * Anastasia Foti AEM:8959 * * * @author * Christos Choutouridis AEM:8997 * */ package host.labyrinth; import java.util.ArrayList; //import java.util.Arrays; /** * @brief * This class represents the game's player who cheats. */ class HeuristicPlayer extends Player { /** @name Constructors */ /** @{ */ public HeuristicPlayer(String name, boolean champion, Board board, int row, int column) { super(name, champion, board, row, column); path = new ArrayList(); } public HeuristicPlayer(String name, boolean champion, Board board, int tileId) { super(name, champion, board, tileId); path = new ArrayList(); } /** @} */ /** @name Board's main application interface */ /** @{ */ /** * Utility to get the distance of a possible supply in some direction * @param currentPos The current position of the player * @param direction The direction to check * @return The distance or Const.noSupply */ int supplyInDirection(int currentPos, int direction) { Position pos = new Position(Position.toRow(currentPos), Position.toCol(currentPos)); for (int i=0 ; board.isWalkable(pos.getId(), direction) && i M) { M = eval[i]; M_idx = i; } } return eval_dir[M_idx]; } boolean isUnevaluated (double[] eval, int N) { for (int i =0 ; i *
  • int[0]: The tileId of the final player's position. *
  • int[1]: The row of the final player's position. *
  • int[2]: The column of the final player's position. *
  • int[3]: The supplyId in case player picked one (Const.noSupply otherwise). * */ int[] move(int id) { // Initialize return array with the current data int[] ret = new int[Const.moveItems]; ret[0] = getNextMove(id); ret[1] = y = Position.toRow(ret[0]); ret[2] = x = Position.toCol(ret[0]); int supplyFlag = 0; // In case of a champion player, try also to pick a supply if (champion && (ret[3] = board.tryPickSupply(ret[0])) != Const.noSupply) { ++score; // keep score ++supplyFlag; System.out.println(name + ":\t*Found a supply. [score: " + score + "]"); } board.updateMove(ret, playerId); // Update supply and opponent distance int dir = Direction.get(id, ret[0]); int smin =DirRange.End, omin =DirRange.End; for (int d = DirRange.Begin ; d path; /**< our history * The integer[] format is: * { dice, tookSupply, SupplyDistance, OpponentDistance} */ /** @} */ }