Index

A B C D E F G H I L M N O P R S T V W 
All Classes and Interfaces|All Packages|Constant Field Values|Serialized Form

A

a5 - package a5
Assignment 5
a5.ai - package a5.ai
This package contains the components of an AI algorithm based on minimax search.
a5.logic - package a5.logic
This package manages game states and maintains game logic for running (m, n, k)-games.
a5.ui - package a5.ui
This package defines players that interact with either a human player or an AI algorithm to generate the next move.
a5.util - package a5.util
Enums and classes that define constants and utility methods for other packages to use for convenience.
activateTranspositionTable() - Method in class a5.ai.Minimax
Effect: Turn on the use of a transposition table.
add(GameState, int, int) - Method in class a5.ai.TranspositionTable
Effect: Add a new entry in the transposition table for a given state and depth, or overwrite the existing entry for this state with the new depth and value.
advanceTurn() - Method in class a5.logic.MNKGame
Effect: advance the game turn by one.
AI - Enum constant in enum class a5.util.PlayerType
 
AI2 - Enum constant in enum class a5.util.PlayerType
 
AIPlayer<GameState> - Class in a5.ui
A computer-driven player that uses minimax search to find good moves.
AIPlayer(GameState, GameModel<GameState, Position>, boolean, boolean, boolean, int) - Constructor for class a5.ui.AIPlayer
 
applyMove(Pente, Position) - Method in class a5.ai.PenteModel
 
applyMove(Position) - Method in class a5.logic.Pente
Returns: a new game state representing the state of the game after the current player takes a move p.
applyMove(Position) - Method in class a5.logic.TicTacToe
Returns: a new game state representing the state of the game after the current player takes a move p.
applyMove(TicTacToe, Position) - Method in class a5.ai.TicTacToeModel
 
applyMove(GameState, Move) - Method in interface a5.ai.GameModel
Returns: a new game state representing the state of the game after the current player takes a move.
ASK_MOVE - Static variable in class a5.ui.HumanPlayer
 

B

board() - Method in class a5.logic.MNKGame
Returns: the board state.
Board - Class in a5.logic
A mutable representation of an m-by-n board in which each cell can be occupied by a player or be empty
Board(int, int) - Constructor for class a5.logic.Board
Creates a new rowSize-by-colSize board.
Board(Board) - Constructor for class a5.logic.Board
Creates a new board that deep copies a provided board.
boardValue() - Method in class a5.util.PlayerRole
 

C

capturedPairsNo(PlayerRole) - Method in class a5.logic.Pente
Returns: the number of captured pairs by playerRole.
cast(Maybe<U>) - Static method in class cms.util.maybe.Maybe
Convert a Maybe<U> to a Maybe<T>, when T is a supertype of U.
changePlayer() - Method in class a5.logic.MNKGame
Effect: change the current player to be the next.
cms.util - package cms.util
Utilities originally developed for the CMS (CMSX) project.
cms.util.maybe - package cms.util.maybe
Support for the type Maybe<T>
col() - Method in class a5.logic.Position
Returns: the column
colSize() - Method in class a5.logic.Board
 
colSize() - Method in class a5.logic.MNKGame
Returns: the number of columns of the board.
countToWin() - Method in class a5.logic.MNKGame
Returns: the number of consecutive stones (k) to win.
create() - Method in exception cms.util.FastException
Create a FastException
create() - Method in exception cms.util.maybe.NoMaybeValue
 
currentPlayer() - Method in class a5.logic.MNKGame
Returns: the current player.
currentPlayerToString(PlayerRole, Map<PlayerRole, Player>) - Static method in class a5.Main
Returns: a string presenting the current player.
currentTurn() - Method in class a5.logic.MNKGame
Returns: number of the current turn.
customFillInStackTrace() - Method in exception cms.util.FastException
Effect: Fill in the stack trace like a normal (expensive) exception.

D

depth() - Method in interface a5.ai.TranspositionTable.StateInfo
The depth to which the game tree was searched to determine the value.
displayLine(String) - Static method in class a5.Main
Print out one message in one line.
DRAW - Enum constant in enum class a5.util.GameResult
 

E

endMessage(GameResult) - Static method in class a5.Main
Returns: a string presenting the game result.
equals(Object) - Method in class a5.logic.Board
Board equality is determined using state equality.
equals(Object) - Method in class a5.logic.MNKGame
Although MNKGame is a mutable abstraction, equality is defined in terms of the state of the object.
equals(Object) - Method in class a5.logic.Pente
 
equals(Object) - Method in class a5.logic.Position
Equality is state equality.
erase(Position) - Method in class a5.logic.Board
Effect: set the cell at position p to empty.
evaluate(Pente) - Method in class a5.ai.PenteModel
This heuristic evaluation look for number of consecutive unblocked stones of both players, and calculate a weighted sum of these numbers and number of captured pairs of both players.
evaluate(TicTacToe) - Method in class a5.ai.TicTacToeModel
 
evaluate(GameState) - Method in interface a5.ai.GameModel
Returns: the heuristic evaluation of a state of a two-player game, as a value between WIN and -WIN.

F

FastException - Exception in cms.util
An exception that is fast to throw but doesn't have very good debugging support unless its withStackTrace() method is used explicitly.
FastException() - Constructor for exception cms.util.FastException
Initialize a FastException
fillInStackTrace() - Method in exception cms.util.FastException
There is no meaningful stack trace for this exception because it is supposed to always be handled.
findBestMove(GameState, int) - Method in class a5.ai.Minimax
Returns: the best move from the given state that can be found by searching for up to a given amount of time.
FIRST_PLAYER - Static variable in class a5.util.PlayerRole
 
FIRST_PLAYER_WON - Enum constant in enum class a5.util.GameResult
 
from(T) - Static method in class cms.util.maybe.Maybe
Create a Maybe from a possibly null value v.
fromOptional(Optional<T>) - Static method in class cms.util.maybe.Maybe
Create a Maybe from an Optional value.
fromString(String) - Static method in enum class a5.util.GameType
Returns: the type of game whose name matches.
fromString(String) - Static method in enum class a5.util.PlayerType
Returns: the type of player whose name matches.

G

GameModel<GameState,Move> - Interface in a5.ai
An abstract, immutable representation of a two-player game.
GameResult - Enum Class in a5.util
An enum representing the result of a game.
gameSettingToStrings(GameType, PlayerType, PlayerType) - Static method in class a5.Main
Returns: a string presenting the game setting.
gameType() - Method in class a5.logic.MNKGame
Returns: the type of this game.
gameType() - Method in class a5.logic.Pente
 
gameType() - Method in class a5.logic.TicTacToe
 
GameType - Enum Class in a5.util
An enum representing the type of game.
get() - Method in class cms.util.maybe.Maybe
Returns the contained value, if present.
get(Position) - Method in class a5.logic.Board
Returns: the board state of a cell.
getInfo(GameState) - Method in class a5.ai.TranspositionTable
Returns: the information in the transposition table for a given game state, package in an Optional.
getOptional(Optional<T>) - Static method in class cms.util.maybe.Maybe
Get the value in an Optional, if present; otherwise throw the checked exception NoMaybeValue.

H

hasEnded() - Method in class a5.logic.MNKGame
Checks if there are enough consecutive stones in a row so that the game ends.
hasEnded() - Method in class a5.logic.Pente
 
hasEnded(Pente) - Method in class a5.ai.PenteModel
 
hasEnded(TicTacToe) - Method in class a5.ai.TicTacToeModel
 
hasEnded(GameState) - Method in interface a5.ai.GameModel
Returns: a boolean indicating whether the game has ended.
hashCode() - Method in class a5.logic.Board
 
hashCode() - Method in class a5.logic.MNKGame
 
hashCode() - Method in class a5.logic.Pente
 
hashCode() - Method in class a5.logic.Position
 
HUMAN - Enum constant in enum class a5.util.PlayerType
 
HumanPlayer<GameState> - Class in a5.ui
A human player
HumanPlayer(GameState, GameModel<GameState, Position>, InputStream) - Constructor for class a5.ui.HumanPlayer
 

I

INVALID_MOVE_POSITION - Static variable in class a5.ui.HumanPlayer
 
isPresent() - Method in class cms.util.maybe.Maybe
Returns whether a value is contained in this Maybe.
iterator() - Method in class cms.util.maybe.Maybe
Provide an iterator that yields either one T or none, depending.

L

legalMoves() - Method in class a5.logic.MNKGame
Returns: a set of legal moves.
legalMoves(Pente) - Method in class a5.ai.PenteModel
 
legalMoves(TicTacToe) - Method in class a5.ai.TicTacToeModel
 
legalMoves(GameState) - Method in interface a5.ai.GameModel
Returns: the set of legal moves in the state s for the player whose move it is.

M

main(String[]) - Static method in class a5.Main
The main method to run a game.
Main - Class in a5
The main program for Assignment 5.
Main() - Constructor for class a5.Main
 
makeMove(Position) - Method in class a5.logic.MNKGame
Effect: place a stone as the current player at p, and advance to the next turn Checks: p is a valid position to place a stone, that is, 0 <= p.rowNo() < rowSize(), 0 <= p.colNo() < colSize(), and p is empty on board.
makeMove(Position) - Method in class a5.logic.Pente
 
makeMove(Position) - Method in class a5.logic.TicTacToe
 
MAX_TRANSPOSITION_TABLE_SIZE - Static variable in class a5.ai.Minimax
When to flush the table and start over
Maybe<T> - Class in cms.util.maybe
An object that may contain a value of type T.
Maybe() - Constructor for class cms.util.maybe.Maybe
Do nothing.
Minimax<GameState,Move> - Class in a5.ai
Implementation of minimax search with alpha-beta pruning.
Minimax(GameModel<GameState, Move>) - Constructor for class a5.ai.Minimax
Create a new minimax AI search engine.
Minimax.OutOfTime - Exception in a5.ai
An exception signifying that the search algorithm ran out of time.
MNKGame - Class in a5.logic
A running (m, n, k) game.
MNKGame(int, int, int) - Constructor for class a5.logic.MNKGame
 
MNKGame(MNKGame) - Constructor for class a5.logic.MNKGame
Create a game copy.

N

nextMove() - Method in class a5.ui.AIPlayer
Search the best next move, within time limit.
nextMove() - Method in class a5.ui.HumanPlayer
Ask the user to input the next move.
nextMove() - Method in interface a5.ui.Player
Returns: the next move of this player, if there is one.
nextPlayer() - Method in class a5.util.PlayerRole
Returns: the role of the next player when this is the current player.
NoMaybeValue - Exception in cms.util.maybe
A checked exception that forces the programmer to handle the possibility of empty maybes.
NoMaybeValue() - Constructor for exception cms.util.maybe.NoMaybeValue
 
none() - Static method in class cms.util.maybe.Maybe
Returns an empty Maybe.

O

onBoard(Position) - Method in class a5.logic.Board
Returns: true if p is within the board.
options() - Static method in enum class a5.util.GameType
Returns: a string representing a list of all valid game types.
options() - Static method in enum class a5.util.PlayerType
Returns: a string representing a list of all valid player types.
orElse(T) - Method in class cms.util.maybe.Maybe
Returns the contained value, if any; otherwise, returns other.
orElseGet(Supplier<T>) - Method in class cms.util.maybe.Maybe
Returns the contained value, if any; otherwise, returns other.get().
orElseMaybe(Supplier<Maybe<T>>) - Method in class cms.util.maybe.Maybe
Returns this if a value is contained; otherwise, returns other.get().
orElseThrow(E) - Method in class cms.util.maybe.Maybe
Returns the contained value, if any; otherwise, throws the specified exception.
OutOfTime() - Constructor for exception a5.ai.Minimax.OutOfTime
 

P

Pente - Class in a5.logic
A Pente game, where players take turns to place stones on board.
Pente() - Constructor for class a5.logic.Pente
Create an 8-by-8 Pente game.
Pente(Pente) - Constructor for class a5.logic.Pente
Creates: a copy of the game state.
PENTE - Enum constant in enum class a5.util.GameType
 
PenteModel - Class in a5.ai
A model for Pente and Position satisfying the constraints of GameModel.
PenteModel() - Constructor for class a5.ai.PenteModel
 
place(Position, PlayerRole) - Method in class a5.logic.Board
Effect: place a stone as currentPlayer on board at position p.
Player - Interface in a5.ui
A game player.
PlayerRole - Class in a5.util
A class representing player roles.
PlayerType - Enum Class in a5.util
An enum representing the type of player.
Position - Class in a5.logic
An immutable position (row, column) on the board.
Position(int, int) - Constructor for class a5.logic.Position
Creates: the position (row, column).

R

result() - Method in class a5.logic.MNKGame
Returns: The result of the game.
row() - Method in class a5.logic.Position
Returns: the row
rowSize() - Method in class a5.logic.Board
 
rowSize() - Method in class a5.logic.MNKGame
Returns: the number of rows of the board.

S

search(GameState, int, int, int) - Method in class a5.ai.Minimax
Returns: the optimal minimax value of the current game state, within the range from min to max.
SECOND_PLAYER - Static variable in class a5.util.PlayerRole
 
SECOND_PLAYER_WON - Enum constant in enum class a5.util.GameResult
 
setAlphaBetaPruning(boolean) - Method in class a5.ai.Minimax
Effect: Set whether alpha-beta pruning is used.
setResult(GameResult) - Method in class a5.logic.MNKGame
Set the result of the game.
setShowSearchInfo(boolean) - Method in class a5.ai.Minimax
Effect: Set whether search info is printed.
size() - Method in class a5.ai.TranspositionTable
The number of entries in the transposition table.
some(T) - Static method in class cms.util.maybe.Maybe
Creates a Maybe from a non-null argument.
stateEqual(MNKGame) - Method in class a5.logic.MNKGame
Returns: true if the two games have equivalent state for the purpose of deciding future moves.
stateEqual(Pente) - Method in class a5.logic.Pente
Returns: true if the two games have the same state.

T

theException - Static variable in exception cms.util.maybe.NoMaybeValue
 
then(Function<T, U>) - Method in class cms.util.maybe.Maybe
If a value v is present, returns a Maybe containing f(v), which must be non-null.
thenDo(Consumer<T>) - Method in class cms.util.maybe.Maybe
Call cons on the contained value, if any.
thenElse(Consumer<T>, Runnable) - Method in class cms.util.maybe.Maybe
If a value is contained, run consThen on the value; otherwise run procElse
thenMaybe(Function<T, Maybe<U>>) - Method in class cms.util.maybe.Maybe
If a value v is present, returns f(v).
TIC_TAC_TOE - Enum constant in enum class a5.util.GameType
 
TicTacToe - Class in a5.logic
The classic game of Tic-Tac-Toe.
TicTacToe() - Constructor for class a5.logic.TicTacToe
 
TicTacToeModel - Class in a5.ai
A model for TicTacToe and Position satisfying the constraints of GameModel.
TicTacToeModel() - Constructor for class a5.ai.TicTacToeModel
 
toOptional() - Method in class cms.util.maybe.Maybe
Create an Optional from a Maybe
toString() - Method in class a5.logic.MNKGame
 
toString() - Method in class a5.logic.Pente
 
toString() - Method in class a5.logic.Position
 
toString() - Method in enum class a5.util.GameType
 
toString() - Method in enum class a5.util.PlayerType
 
TranspositionTable<GameState> - Class in a5.ai
A transposition table for an arbitrary game.
TranspositionTable.StateInfo - Interface in a5.ai
Information about a game state, for use by clients.

V

validPos(Position) - Method in class a5.logic.Board
Returns: true if p is a valid cell to place stones.
value() - Method in interface a5.ai.TranspositionTable.StateInfo
The heuristic value of this game state.
valueOf(String) - Static method in enum class a5.util.GameResult
Returns the enum constant of this class with the specified name.
valueOf(String) - Static method in enum class a5.util.GameType
Returns the enum constant of this class with the specified name.
valueOf(String) - Static method in enum class a5.util.PlayerType
Returns the enum constant of this class with the specified name.
values() - Static method in enum class a5.util.GameResult
Returns an array containing the constants of this enum class, in the order they are declared.
values() - Static method in enum class a5.util.GameType
Returns an array containing the constants of this enum class, in the order they are declared.
values() - Static method in enum class a5.util.PlayerType
Returns an array containing the constants of this enum class, in the order they are declared.

W

WELCOME_MSG - Static variable in class a5.Main
The message the program shows to welcome the player.
WIN - Static variable in interface a5.ai.GameModel
 
withStackTrace() - Method in exception cms.util.FastException
Effect: fills in the stack trace of this exception.
WRONG_MOVE_FORMAT - Static variable in class a5.ui.HumanPlayer
 
A B C D E F G H I L M N O P R S T V W 
All Classes and Interfaces|All Packages|Constant Field Values|Serialized Form