13 package host.labyrinth;
33 super(name, champion, board, row, column);
44 super(name, champion, board, tileId);
80 for (
int o =0 ; o<opps.length; ++o) {
81 if (opps[o][0] == pos.
getId())
94 double evaluate (
int currentPos,
int direction) {
109 double[] eval =
new double[N];
110 int [] eval_dir =
new int[N];
112 for (
int i =0, dir = dirs.
get() ; dir !=
Const.
EOR ; dir = dirs.
get(), ++i) {
114 eval[i] =
evaluate(currentPos, dir);
116 eval[i] = Double.NEGATIVE_INFINITY;
130 return new_pos.
getId();
157 int supplyFlag =0, moveFlag =1;
172 if (s >= 0 && s < smin) smin = s;
173 if (o >= 0 && o < omin) omin = o;
177 ret[0], dir, moveFlag, supplyFlag,
189 if (!
path.isEmpty()) {
190 Integer[] last =
path.get(
path.size()-1);
191 String who = String.format(
"%12s",
name);
192 System.out.print(who +
": score[" +
score +
"]" +
", dice =" + last[1] +
", tileId =" + last[0] +
" (" +
Position.
toRow(last[0]) +
", " +
Position.
toCol(last[0]) +
")");
194 System.out.println(
" *Can not move.");
195 else if (last[3] != 0)
196 System.out.println(
" *Found a supply.");
198 System.out.println(
"");
200 if (last[8] !=
Const.
noSupply) System.out.println(
" supply distance =" + last[8]);
201 else System.out.println(
" supply distance = blind");
202 if (last[9] !=
Const.
noOpponent) System.out.println(
" opponent distance =" + last[9]);
203 else System.out.println(
" opponent distance = blind");
211 String who = String.format(
"%12s",
name);
212 System.out.println();
213 System.out.println(who +
": score[" +
score +
"]");
236 double M = Double.NEGATIVE_INFINITY;
238 for (
int i =0; i < N ; ++i) {
244 return eval_dir[M_idx];
254 for (
int i =0 ; i<N ; ++i)
255 if (eval[i] != 0 && eval[i] != Double.NEGATIVE_INFINITY)
This class represents the game's player who cheats.
static final int RIGHT
East direction.
int [][] getOpponentMoves(int playerId)
Boards utility to give access to other player moves.
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.
int getNextMove(int currentPos)
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
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
Helper C++ like enumerator class for direction ranged loops.
int getId()
Read access to id coordinate.
static final int moveItems
The number of items return by move()
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 y
The row coordinate of the player on the board.
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 int get(int fromId, int toId)
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.
static final int Begin
Iterator style begin of range direction (starting north)
ArrayList< Integer[]> path
our history.
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.