Empirical
|
Class for othello games of a specific size. More...
#include <Othello.h>
Classes | |
struct | Index |
Public Types | |
using | this_t = Othello_Game< BOARD_SIZE > |
using | board_t = std::array< Player, NUM_CELLS > |
enum | Player { NONE =0, DARK, LIGHT } |
enum | Facing { N, NE, E, SE, S, SW, W, NW } |
Public Member Functions | |
Othello_Game () | |
~Othello_Game () | |
void | Reset () |
Reset the board to the starting condition. More... | |
constexpr size_t | GetBoardWidth () const |
size_t | GetNumCells () const |
Player | GetCurPlayer () const |
Player | GetOpponent (Player player) const |
Get opponent ID of give player ID. More... | |
bool | IsValidPlayer (Player player) const |
Is the given player ID a valid player? More... | |
auto | BuildNeighbors () |
Index | GetNeighbor (Index id, Facing dir) const |
Player | GetPosOwner (Index id) const |
Get the value (light, dark, or open) at a position on the board. More... | |
board_t & | GetBoard () |
const board_t & | GetBoard () const |
bool | IsValidMove (Player player, Index pos) |
Is given move valid? More... | |
bool | IsOver () const |
emp::vector< Index > | GetFlipList (Player player, Index pos) |
size_t | GetFlipCount (Player player, Index pos) |
Count the number of positions that would flip if we placed a piece at a specific location. More... | |
bool | HasValidFlips (Player player, Index pos) |
Are there any valid flips from this position? More... | |
emp::vector< Index > | GetMoveOptions (Player player) |
Get a list of valid move options for given player. More... | |
emp::vector< Index > | GetMoveOptions () |
GetMoveOptions() without a specified player used current player. More... | |
bool | HasMoveOptions (Player player) |
Determine if there are any move options for given player. More... | |
double | GetScore (Player player) |
Get the current score for a given player. More... | |
size_t | CountFrontierPos (Player player) |
Count the number of empty squares adjacent to a player's pieces (frontier size) More... | |
bool | IsAdjacentTo (Index pos, Player owner) |
Is position given by ID adjacent to the given owner? More... | |
void | SetPos (Index pos, Player player) |
Set board position (ID) to given space value. More... | |
void | SetPositions (emp::vector< Index > ids, Player player) |
Set positions given by ids to be owned by the given player. More... | |
void | SetBoard (const board_t &other_board) |
void | SetBoard (const this_t &other_othello) |
Set current board to be the same as board from other othello game. More... | |
void | SetCurPlayer (Player player) |
Set the current player. More... | |
bool | DoNextMove (Index pos) |
bool | DoMove (Player player, Index pos) |
void | DoFlips (Player player, Index pos) |
NOTE: does not check for move validity. More... | |
void | Print (std::ostream &os=std::cout, std::string dark_token="D", std::string light_token="L", std::string open_space="O") |
Print board state to given ostream. More... | |
Static Public Member Functions | |
static constexpr Index | GetIndex (size_t x, size_t y) |
Static Public Attributes | |
static constexpr size_t | NUM_CELLS = BOARD_SIZE * BOARD_SIZE |
static constexpr size_t | NUM_DIRECTIONS = 8 |
Number of neighbors each board space has. More... | |
Static Protected Member Functions | |
static size_t | GetNeighborIndex (Index pos, Facing dir) |
Internal function for accessing the neighbors vector. More... | |
Protected Attributes | |
std::array< Facing, NUM_DIRECTIONS > | ALL_DIRECTIONS |
emp::vector< Index > | neighbors |
bool | over = false |
Is the game over? More... | |
Player | cur_player |
Who is the current player set to move next? More... | |
board_t | game_board |
Game board. More... | |
Class for othello games of a specific size.
using emp::Othello_Game< BOARD_SIZE >::board_t = std::array<Player, NUM_CELLS> |
using emp::Othello_Game< BOARD_SIZE >::this_t = Othello_Game<BOARD_SIZE> |
|
inherited |
|
inherited |
|
inline |
|
inline |
|
inline |
|
inline |
Count the number of empty squares adjacent to a player's pieces (frontier size)
|
inline |
NOTE: does not check for move validity.
|
inline |
Do move (at pos) for specified player. Return bool whether player can go again. After making move, update current player. NOTE: Does not verify validity. Will switch cur_player from player to Opp(player) if opponent has a move to make.
|
inline |
Do current player's move (moveID). Return bool indicating whether current player goes again. (false=new cur player or game over)
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Count the number of positions that would flip if we placed a piece at a specific location.
|
inline |
Get positions that would flip if a player (player) made a particular move (pos). Note: May be called before or after piece is placed.
|
inlinestatic |
|
inline |
Get a list of valid move options for given player.
|
inline |
GetMoveOptions() without a specified player used current player.
|
inline |
Get location adjacent to ID in direction dir. GetNeighbor function is save with garbage ID values.
|
inlinestaticprotected |
Internal function for accessing the neighbors vector.
|
inline |
|
inline |
Get opponent ID of give player ID.
|
inline |
Get the value (light, dark, or open) at a position on the board.
|
inline |
Get the current score for a given player.
|
inline |
Determine if there are any move options for given player.
|
inline |
Are there any valid flips from this position?
|
inline |
Is position given by ID adjacent to the given owner?
|
inline |
|
inline |
Is given move valid?
|
inline |
Is the given player ID a valid player?
|
inline |
Print board state to given ostream.
|
inline |
Reset the board to the starting condition.
|
inline |
Configure board as given by copy_board input. copy_board size must match game_board's size.
|
inline |
Set current board to be the same as board from other othello game.
|
inline |
Set the current player.
|
inline |
Set board position (ID) to given space value.
|
inline |
Set positions given by ids to be owned by the given player.
|
protected |
|
protected |
Who is the current player set to move next?
|
protected |
Game board.
|
protected |
|
static |
|
staticinherited |
Number of neighbors each board space has.
|
protected |
Is the game over?