public class Board
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
BOARD_HEIGHT |
static int |
BOARD_WIDTH |
Constructor and Description |
---|
Board(java.lang.String diceFilename,
Dictionary dict)
Creates a new board, given a dice file and dictionary.
|
Modifier and Type | Method and Description |
---|---|
int |
computerMove(java.util.Set<java.lang.String> playerMove,
java.util.Set<java.lang.String> computerMove)
Returns the score for the computer move, and (in the output parameter computerMove)
the set of moves that the computer makes.
|
char |
pieceAt(int x,
int y)
Returns the character on the top of the piece at the x,y location
|
int |
playerMove(java.lang.String playerInput,
java.util.Set<java.lang.String> moves)
Check a string of player moves, to see which ones are legal.
|
void |
shuffle()
Shuffles the board
|
boolean |
validGuess(java.lang.String guess)
Returns true if the guess is valid (in the dictionary and on the board, length greater than
or equal to 3)
|
public static final int BOARD_WIDTH
public static final int BOARD_HEIGHT
public Board(java.lang.String diceFilename, Dictionary dict) throws java.io.IOException
diceFilename
- file containing a description of the dicedict
- The dictionary to use for checking word validityjava.io.IOException
- an IO exception if there is a problem with file dictpublic void shuffle()
public char pieceAt(int x, int y)
x
- The x location of the piece to checky
- The y location of the piece to checkpublic boolean validGuess(java.lang.String guess)
guess
- The guess to checkpublic int playerMove(java.lang.String playerInput, java.util.Set<java.lang.String> moves)
playerInput
- An input parameter, passing in a string of words separated by "\n"
that the player is guessingmoves
- An output parameter, returning the legal words in the string playerInputpublic int computerMove(java.util.Set<java.lang.String> playerMove, java.util.Set<java.lang.String> computerMove)
playerMove
- The set of all words in the players guesscomputerMove
- An output parameter, the moves made by the computer. This should
be a set of all words that can be found in the board that are not in the set playerMove