Empirical
|
Class for size-8 othello games. More...
#include <Othello8.h>
Classes | |
struct | Board |
struct | Index |
Public Types | |
enum | Player { DARK =0, LIGHT =1, NONE } |
enum | Facing { N, NE, E, SE, S, SW, W, NW } |
using | this_t = Othello8 |
Public Member Functions | |
Othello8 () | |
~Othello8 () | |
void | Reset () |
Reset the board to the starting condition. More... | |
size_t | GetNumCells () const |
Player | GetCurPlayer () const |
size_t | GetHash () 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... | |
Index | GetNeighbor (Index id, Facing dir) |
Player | GetPosOwner (Index id) const |
Get the value (light, dark, or open) at a position on the board. More... | |
Board & | GetBoard () |
const Board & | GetBoard () const |
bool | IsValidMove (Player player, Index pos) |
Is given move valid? More... | |
bool | IsOver () const |
void | SetupCache () |
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 | ClearPos (Index pos) |
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 &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 constexpr size_t | GetBoardWidth () |
Static Public Attributes | |
static constexpr size_t | NUM_DIRECTIONS = 8 |
Number of neighbors each board space has. More... | |
static constexpr size_t | BOARD_SIZE = 8 |
Size of a side of the board. More... | |
static constexpr size_t | NUM_CELLS = 64 |
Number of cells on total board. More... | |
Protected Types | |
using | flip_list_t = emp::vector< Index > |
Static Protected Member Functions | |
static const auto & | ALL_DIRECTIONS () |
All eight cardinal directions. More... | |
static size_t | GetNeighborIndex (Index pos, Facing dir) |
Internal function for accessing the neighbors vector. More... | |
static const auto & | NEIGHBORS () |
Precalculated neighbors. More... | |
Protected Attributes | |
bool | over = false |
Is the game over? More... | |
Player | cur_player |
Who is the current player set to move next? More... | |
Board | game_board |
Game board. More... | |
std::array< flip_list_t, NUM_CELLS > | light_flips |
std::array< flip_list_t, NUM_CELLS > | dark_flips |
bool | cache_ok |
Class for size-8 othello games.
NOTE: This game could be made more black-box.
|
protected |
using emp::Othello8::this_t = Othello8 |
|
inline |
|
inline |
|
inlinestaticprotected |
All eight cardinal directions.
|
inline |
|
inline |
Count the number of empty squares adjacent to a player's pieces (frontier size)
NOTE: does not check for move validity.
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 |
|
inlinestatic |
|
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.
|
inline |
|
inlinestatic |
|
inline |
Get a list of valid move options for given player.
|
inline |
GetMoveOptions() without a specified player used current player.
Get location adjacent to ID in direction dir. GetNeighbor function is save with garbage ID values.
Internal function for accessing the neighbors vector.
|
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.
Are there any valid flips from this position?
Is position given by ID adjacent to the given owner?
|
inline |
|
inline |
Is the given player ID a valid player?
|
inlinestaticprotected |
Precalculated neighbors.
|
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.
Set board position (ID) to given space value.
|
inline |
Set positions given by ids to be owned by the given player.
|
inline |
|
static |
Size of a side of the board.
|
protected |
|
protected |
Who is the current player set to move next?
|
protected |
|
protected |
Game board.
|
protected |
|
static |
Number of cells on total board.
|
static |
Number of neighbors each board space has.
|
protected |
Is the game over?