public class Backgammon
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Board |
board |
protected Dice |
dice |
protected int |
player |
protected Player[] |
players |
Constructor and Description |
---|
Backgammon(Player player1,
Player player2)
Builds a new backgammon instance, given the two players
to play the game between.
|
Modifier and Type | Method and Description |
---|---|
Board |
getCurrentBoard()
Returns the current board.
|
int |
getCurrentPlayer()
Returns the current player, either Board.BLACK or Board.WHITE
|
Dice |
getDice()
Returns the current dice
|
Move[] |
getMoves()
Returns a list of all of the possible moves which the player
can currently make
|
boolean |
isGameOver()
Returns whether or not the game is over
|
void |
print(java.io.PrintStream out)
Prints out a gnubg-style text board.
|
void |
print(java.io.PrintStream out,
Board board)
Prints out a gnubg-style text board.
|
void |
reset()
Resets this backgammon instance to the initial state, with
a new board and the black player's move
|
Player |
run()
Runs a game of backgammon, and does not return until the game
is over.
|
protected Board board
protected Dice dice
protected int player
protected Player[] players
public Player run()
public void reset()
public int getCurrentPlayer()
public Move[] getMoves()
public Dice getDice()
public Board getCurrentBoard()
public boolean isGameOver()
public void print(java.io.PrintStream out)
out
- The output stream to write the board topublic void print(java.io.PrintStream out, Board board)
out
- The output stream to write the board toboard
- The board