13 package host.labyrinth;
15 import java.util.ArrayList;
49 this.
path =
new ArrayList<Integer[]>();
72 this.
path =
new ArrayList<Integer[]>();
107 int supplyFlag =0, moveFlag =0;
141 if (!
path.isEmpty()) {
142 Integer[] last =
path.get(
path.size()-1);
143 String who = String.format(
"%12s",
name);
144 System.out.print(who +
": score[" +
score +
"]" +
", dice =" + last[1] +
", tileId =" + last[0] +
" (" +
Position.
toRow(last[0]) +
", " +
Position.
toCol(last[0]) +
")");
146 System.out.println(
" *Can not move.");
147 else if (last[3] != 0)
148 System.out.println(
" *Found a supply.");
150 System.out.println(
"");
197 assert (x >= 0 && x<
Session.
boardSize) :
"X(column) coordinate must be in the range [0, Session.boardSize)";
201 assert (y >= 0 && y<
Session.
boardSize) :
"Y(row) coordinate must be in the range [0, Session.boardSize)";
226 protected ArrayList<Integer[]>
path;
static final int RIGHT
East direction.
static final int MOVE_DICE
The index of dice information.
void setBoard(Board board)
This class is the representation of the games's board.
Class to hold constant values for entire application.
ArrayList< Integer[]> getPath()
void setChampion(boolean champion)
void setName(String name)
int playerCol()
Utility to access player's column position (column coordinate)
void setDirCounter(int[] dirCounter)
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 playerTileId()
Utility to access player's tileID.
int x
The column coordinate of the player on the board.
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.
Player(String name, boolean champion, Board board, int row, int column)
Create a new player and put him at the row-column coordinates.
void setPath(ArrayList< Integer[]> path)
int [] move(int id)
Player's move.
void statistics()
Prints round information for the player.
static final int MOVE_DATA_SIZE
Helper variables to keep track of the move() return values.
void final_statistics()
Prints final statistics for the player.
Helper C++ like enumerator class for direction ranged loops.
int getId()
Read access to id coordinate.
static final int MOVE_ROW
The index of row information.
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.
static int toRow(int id)
Takes Id coordinate and return the corresponding row coordinate.
int score
The current score of the player.
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. ...
int generatePlayerId()
Utility function to create player IDs.
static final int NONE
No direction.
int dice()
A plain fair dice functionality provided by the board.
static final int noSupply
Number to indicate the absent of supply.
static int toID(int row, int col)
Takes row and column coordinates and return the calculated Id coordinate.
Application wide object to hold settings like values for the session.
static int boardSize
Default board's size (if no one set it via command line)
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.
static final int MOVE_COLUMN
The index of column information.
int playerRow()
Utility to access player's row position (row coordinate)
ArrayList< Integer[]> path
our history.
int tryPickSupply(int tileId)
Try to pick supply from a tile.
int playerId
The unique identifier of the player.
Player(String name, boolean champion, Board board, int tileId)
Create a new player and put him at the row-column coordinates.