13 package host.labyrinth;
92 double evaluate (
int currentPos,
int direction) {
114 double[] eval =
new double[N];
115 int [] eval_dir =
new int[N];
117 for (
int i =0, dir = dirs.
get() ; dir !=
Const.
EOR ; dir = dirs.
get(), ++i) {
119 eval[i] =
evaluate(currentPos, dir);
121 eval[i] = Double.NEGATIVE_INFINITY;
163 int supplyFlag =0, moveFlag =1;
177 if (s >= 0 && s < smin) smin = s;
178 if (o >= 0 && o < omin) omin = o;
194 if (!
path.isEmpty()) {
195 Integer[] last =
path.get(
path.size()-1);
196 String who = String.format(
"%12s",
name);
197 System.out.print(who +
": score[" +
score +
"]" +
", dice =" + last[1] +
", tileId =" + last[0] +
" (" +
Position.
toRow(last[0]) +
", " +
Position.
toCol(last[0]) +
")");
199 System.out.println(
" *Can not move.");
200 else if (last[3] != 0)
201 System.out.println(
" *Found a supply.");
203 System.out.println(
"");
205 if (last[8] !=
Const.
noSupply) System.out.println(
" supply =" + last[8]);
206 else System.out.println(
" supply = blind");
207 if (last[9] !=
Const.
noOpponent) System.out.println(
" opponent =" + last[9]);
208 else System.out.println(
" opponent = blind");
216 String who = String.format(
"%12s",
name);
217 System.out.println();
218 System.out.println(who +
": score[" +
score +
"]");
241 double M = Double.NEGATIVE_INFINITY;
243 for (
int i =0; i < N ; ++i) {
249 return eval_dir[M_idx];
259 for (
int i =0 ; i<N ; ++i)
260 if (eval[i] != 0 && eval[i] != Double.NEGATIVE_INFINITY)
This class represents the game's player who cheats.
static final int RIGHT
East direction.
static final int MOVE_DICE
The index of dice information.
This class is the representation of the games's board.
Class to hold constant values for entire application.
Helper C++-like enumerator class to hold direction.
boolean champion
Champion indicate a player who plays against the Minotaur.
static final int End
Iterator style end of range direction (one place after the last)
int x
The column coordinate of the player on the board.
static final int Step
Step for iterator style direction.
static final int MOVE_TILE_ID
Index of the tileId information of the move.
This class represents the game's player.
Board board
Reference to the session's boards.
int supplyInDirection(int currentPos, int direction)
Utility to get the distance of a possible supply in some direction.
int [] move(int id)
HeuristicPlayer's move.
void final_statistics()
Prints final statistics for the player.
static final double opponentFactor
Parameters to control move evaluation.
HeuristicPlayer(String name, boolean champion, Board board, int tileId)
Create a new player and put him at the row-column coordinates.
static final double supplyFactor
supply distance factor
Helper C++ like enumerator class for direction ranged loops.
int getId()
Read access to id coordinate.
static final int viewDistance
The max distance of the Heuristic player's ability to see.
int opponetInDirection(int currentPos, int direction)
Utility to get the distance of a possible opponent in some direction.
int getRow()
Read access to virtual row coordinate.
int y
The row coordinate of the player on the board.
int getCol()
Read access to virtual column coordinate.
double evaluate(int currentPos, int direction)
This is the main move evaluation function.
HeuristicPlayer(String name, boolean champion, Board board, int row, int column)
Create a new player and put him at the row-column coordinates.
static int toRow(int id)
Takes Id coordinate and return the corresponding row coordinate.
int score
The current score of the player.
static final int EOR
Number to indicate the End Of Range.
static int toCol(int id)
Takes Id coordinate and return the corresponding column coordinate.
An Application wide board position implementation holding just the id coordinate. ...
void statistics()
Prints round information for the player.
int directionOfMax(double[] eval, int[] eval_dir, int N)
A small utility to extract the direction of maximum evaluation result.
static final int noSupply
Number to indicate the absent of supply.
boolean isUnevaluated(double[] eval, int N)
A small utility to check if there is at least one evaluation result in the eval array.
Class to create ranges of numbers.
boolean hasSupply(int tileId)
Utility function to check if there is a supply on the tile or not.
boolean isWalkable(int tileId, int direction)
Predicate to check if a direction is Walkable.
static final int LEFT
West direction.
static final int UP
North direction.
static final int noOpponent
Number to indicate the absent of supply.
void updateMove(int[] m, int playerId)
Utility to update the moves of each player.
String name
The name of the player.
static final int DOWN
South direction.
int [] getNextMove(int currentPos)
Selects the best possible move to return.
static final int Begin
Iterator style begin of range direction (starting north)
ArrayList< Integer[]> path
our history.
int [] getOpponentMove(int playerId)
Boards utility to give access to other player moves.
int tryPickSupply(int tileId)
Try to pick supply from a tile.
int playerId
The unique identifier of the player.
Class to create shuffled ranges of numbers.
int get()
Extract and return the first item from the range.