#include <old_board.h>
Public Member Functions | |
| void | initNewGame () |
| Public wrapper around init(newGame=true). | |
| bool | initFromRecord (const char *fn) |
| Inits board from a game record in file. | |
| bool | initFromPosition (const char *fn) |
| Inits board from a position in file. | |
| bool | initFromPositionCompactString (const string &s) |
| Inits board from compact string. | |
| Step | findMCstep () |
| Step generation for Monte Carlo playouts. | |
| void | findMCmoveAndMake () |
| Move generation in Monte Carlo playouts. | |
| bool | operator== (const OB_Board &board) const |
| Equality operator. | |
| bool | makeStepTryCommitMove (const Step &) |
| Wraper for makeStep with commiting. | |
| void | makeMove (const string &move) |
| Performs whole move. | |
| void | makeMoveNoCommit (const Move &move) |
| Making whole move. | |
| void | makeMove (const Move &move) |
| Making whole move. | |
| void | commitMove () |
| Commits the move. | |
| void | updateWinner () |
| Updates winner of the game. | |
| bool | quickGoalCheck (ob_player_t player, int stepLimit, Move *move=NULL) const |
| Quick check for goal. | |
| bool | quickGoalCheck (Move *move=NULL) const |
| Quick check for goal. | |
| Move | tracebackFlagBoard (const FlagBoard &flagBoard, int win_square, ob_player_t player) const |
| Traceback on flag board. | |
| int | filterRepetitions (StepArray &, int) const |
| Repetition check. | |
| bool | isSetupPhase () const |
| Setup pieces phase test. | |
| ob_player_t | getPlayerToMove () const |
| Actual player getter. | |
| ob_player_t | getPlayerToMoveAfterStep (const Step &step) const |
| Next step's player getter. | |
| string | toString () const |
| String representation of board. | |
| string | MovetoStringWithKills (const Move &m) const |
| Print of move with kills. | |
| bool | checkKillForward (ob_square_t from, ob_square_t to, KillInfo *killInfo=NULL) const |
| Forward check. | |
| u64 | calcAfterStepSignature (const Step &step) const |
| Calculater signature for one step forward. | |
| int | generateAllStepsNoPass (ob_player_t, StepArray &) const |
| Step generation. | |
| int | generateAllSteps (ob_player_t, StepArray &) const |
| Step generation. | |
| void | generateStepsForPiece (ob_square_t square, StepArray &steps, uint &stepsNum) const |
| Step generation for one piece. | |
| void | getHeuristics (const StepArray &steps, uint stepsNum, HeurArray &heurs) const |
| Knowledge for steps. | |
| u64 | getSignature () const |
| ob_player_t | getWinner () const |
| ob_player_t | gameOver () const |
| There is a winner. | |
| bool | canContinue (const Move &move) const |
| Continue check. | |
| bool | canPass () const |
| Checks pass validity. | |
| Step | lastStep () const |
| Last step getter. | |
Private Member Functions | |
| void | init (bool newGame=false) |
| General init - nullifies variables. | |
| bool | initFromPositionStream (istream &ss) |
| Inits board from position stream. | |
| void | afterPositionLoad () |
| After load from position actions. | |
| ob_player_t | sideCharToPlayer (char side) const |
| Side character to player. | |
| recordAction_e | parseRecordActionToken (const string &token, ob_player_t &player, ob_piece_t &piece, ob_square_t &from, ob_square_t &to) |
| Parsing single token for init from game record. | |
| PiecePair | parsePieceChar (char pieceChar) |
| Parsing piece char (e.g. | |
| void | initZobrist () const |
| Init zobrist table. | |
| void | makeSignature () |
| Take (hopefully) unique signature of position - u64 number. | |
| void | makeStep (const Step &step) |
| Making the step. | |
| bool | findRandomStep (Step &) const |
| "Random" step generator. | |
| Step | chooseStepWithKnowledge (StepArray &steps, uint stepsNum) const |
| Knowledge integration into steps. | |
| float | evaluateStep (const Step &step) const |
| Evaluates one step. | |
| bool | checkKill (ob_square_t square) |
| Kill checker. | |
| void | performKill (ob_square_t trapPos) |
| Performs kill. | |
| bool | stepIsVirtualPass (Step &) const |
| Virtual pass check. | |
| bool | stepIsThirdRepetition (const Step &) const |
| Third repetition check. | |
| bool | hasFriend (ob_square_t) const |
| Has a friend test. | |
| bool | hasFriend (ob_square_t, ob_player_t owner) const |
| Has a friend test. | |
| bool | hasTwoFriends (ob_square_t, ob_player_t) const |
| Two friends test. | |
| bool | hasStrongerEnemy (ob_square_t) const |
| Has stronger enemy test. | |
| bool | hasStrongerEnemy (ob_square_t, ob_player_t owner, ob_piece_t piece) const |
| Has stronger enemy test. | |
| bool | isFrozen (ob_square_t) const |
| Frozen check. | |
| uint | getStepCount () const |
| u64 | getPreMoveSignature () const |
| void | setSquare (ob_square_t, ob_player_t, ob_piece_t) |
| Sets square and updates signature. | |
| void | clearSquare (ob_square_t) |
| Clears square and update signature. | |
| string | allStepsToString () const |
| void | dumpAllSteps () const |
| void | dump () const |
Private Attributes | |
| board_t | board_ |
| bool | frozenBoard_ [OB_SQUARE_NUM] |
| PieceArray | pieceArray [2] |
| uint | rabbitsNum [2] |
| StepArray | stepArray |
| uint | stepArrayLen |
| u64 | signature_ |
| u64 | preMoveSignature_ |
| Step | lastStep_ |
| Last made step. | |
| uint | moveCount_ |
| uint | stepCount_ |
| ob_player_t | toMove_ |
| uint | toMoveIndex_ |
| ob_player_t | winner_ |
Static Private Attributes | |
| static bool | classInit = false |
| static ThirdRep * | thirdRep_ |
Friends | |
| class | Eval |
Crucial building block of the whole program.
| void OB_Board::afterPositionLoad | ( | ) | [private] |
After load from position actions.
Signature gest created. PieceArray is filled.
| bool OB_Board::canContinue | ( | const Move & | move | ) | const |
Continue check.
| move | to be made from given position. |
| bool OB_Board::canPass | ( | ) | const |
Checks pass validity.
stepsNum must be > 0 and third repetition is not allowed
| bool OB_Board::checkKill | ( | ob_square_t | square | ) | [private] |
Kill checker.
Checks whether kill is happening in the vicinity of given square.
| bool OB_Board::checkKillForward | ( | ob_square_t | from, | |
| ob_square_t | to, | |||
| KillInfo * | killInfo = NULL | |||
| ) | const |
Forward check.
Checking whether step defined by from, to is causing a kill i.e. suicide, being pushed/pulled to trap, stops protecting piece on the trap. This function causes no board update and is used in class StepWithKills.
| Step OB_Board::chooseStepWithKnowledge | ( | StepArray & | steps, | |
| uint | stepsNum | |||
| ) | const [private] |
Knowledge integration into steps.
| steps | Generated steps - some is selected from these according to "knowledge". | |
| stepsNum | Size of steps. |
| void OB_Board::commitMove | ( | ) |
Commits the move.
Handles switching the sides, updating preMoveSignature.
| float OB_Board::evaluateStep | ( | const Step & | step | ) | const [private] |
Evaluates one step.
In this play game knowledge is applied.
| int OB_Board::filterRepetitions | ( | StepArray & | steps, | |
| int | stepsNum | |||
| ) | const |
Repetition check.
Takes step array and filters out illegal moves considering: 1) virtual pass repetition 2) 3 moves same position repetition
| Step OB_Board::findMCstep | ( | ) |
Step generation for Monte Carlo playouts.
Generates (random) step with some restrictions ( i.e. no pass in the first step ). Random step is generated either by calling findRandomStep method or ( if the former one is unsuccessfull ) by generating all steps and selecting one in random.
| bool OB_Board::findRandomStep | ( | Step & | step | ) | const [private] |
"Random" step generator.
Generates random step ( random type, from, to, ... ) and returns it if it's correctness is verified (might try to generate the step more times).
| int OB_Board::generateAllSteps | ( | ob_player_t | player, | |
| StepArray & | steps | |||
| ) | const |
Step generation.
Wrapper around previous function with added step Pass.
| int OB_Board::generateAllStepsNoPass | ( | ob_player_t | player, | |
| StepArray & | steps | |||
| ) | const |
Step generation.
Generates all (syntatically) legal steps from the position EXCEPT from Pass. Doesn't check 3 - repetitions rule / virtual pass.
| void OB_Board::generateStepsForPiece | ( | ob_square_t | square, | |
| StepArray & | steps, | |||
| uint & | stepsNum | |||
| ) | const |
Step generation for one piece.
| square | Steps are generated for this piece. | |
| stepArray | Steps are stored in this array. | |
| stepsnum | Size of step array. |
| void OB_Board::getHeuristics | ( | const StepArray & | steps, | |
| uint | stepsNum, | |||
| HeurArray & | heurs | |||
| ) | const |
Knowledge for steps.
Applies knowledge to given stepArray and fills heuristic array heurs will have the same size as steps.
| steps | - Given step array for heuristics generation. | |
| stepsNum | - Length of steps. |
| bool OB_Board::hasFriend | ( | ob_square_t | square, | |
| ob_player_t | owner | |||
| ) | const [inline, private] |
Has a friend test.
Variant for forward tests. Color must be supplied as well.
| bool OB_Board::hasFriend | ( | ob_square_t | square | ) | const [private] |
Has a friend test.
Piece on given square has a friend test. Used in trap kill check.
| bool OB_Board::hasStrongerEnemy | ( | ob_square_t | square, | |
| ob_player_t | owner, | |||
| ob_piece_t | piece | |||
| ) | const [inline, private] |
Has stronger enemy test.
Variant for forward tests. Color and piece must be supplied as well
| bool OB_Board::hasStrongerEnemy | ( | ob_square_t | square | ) | const [private] |
Has stronger enemy test.
Used for checking a trap kill.
| bool OB_Board::hasTwoFriends | ( | ob_square_t | square, | |
| ob_player_t | player | |||
| ) | const [private] |
Two friends test.
This is used for forward tests (without actually moveing pieces). Therefore color of player must be supplied as well.
| void OB_Board::init | ( | bool | newGame = false |
) | [private] |
General init - nullifies variables.
| newGame | true -> inits static variables for new game e.g. -> zobrist table, thirdRepetition table, etc. |
| bool OB_Board::initFromPosition | ( | const char * | fn | ) |
Inits board from a position in file.
Wrapper around initFromPositionStream.
| bool OB_Board::initFromPositionCompactString | ( | const string & | s | ) |
Inits board from compact string.
Compact string is in form PLAYER_CHAR [position in lines] e.g.:w [rrr r rrrdd e ED RhMH C mC RRRR c RR]
| bool OB_Board::initFromPositionStream | ( | istream & | ss | ) | [private] |
Inits board from position stream.
| bool OB_Board::initFromRecord | ( | const char * | fn | ) |
Inits board from a game record in file.
| void OB_Board::initZobrist | ( | ) | const [private] |
Init zobrist table.
Fills zobrist table with random u64 numbers. Zobrist algorithm is used for making position signatures.
| bool OB_Board::isFrozen | ( | ob_square_t | square | ) | const [private] |
Frozen check.
Checks whether piece at given square is frozen == !hasFriend and hasStrongerEnemy
| bool OB_Board::isSetupPhase | ( | ) | const |
Setup pieces phase test.
| void OB_Board::makeMove | ( | const Move & | move | ) |
Making whole move.
Wrapper around makeMoveNoCommit with commit() added.
| void OB_Board::makeMove | ( | const string & | move | ) |
Performs whole move.
There is no control whether move is legal.
| move | String representation of the move. |
| void OB_Board::makeMoveNoCommit | ( | const Move & | move | ) |
Making whole move.
Retrieves the step list from move, performs them, does no commit.
| void OB_Board::makeSignature | ( | ) | [private] |
Take (hopefully) unique signature of position - u64 number.
Done by XOR-ing signatures for all pieces on the board.
| void OB_Board::makeStep | ( | const Step & | step | ) | [private] |
Making the step.
One of the crucial methods in the boardstructure.
| step | Step to be made (kills are resolved as well). | |
| update | If true - board structure is updated (added steps, frozenBoard update). |
| bool OB_Board::makeStepTryCommitMove | ( | const Step & | step | ) |
Wraper for makeStep with commiting.
Performs makestep on given step. If the move is over it updatesWinner and commits.
| step | given step |
| bool OB_Board::operator== | ( | const OB_Board & | board | ) | const |
Equality operator.
Check signatures and moveCount. Right now doesn't check pieceArrays and other stuff.
| PiecePair OB_Board::parsePieceChar | ( | char | pieceChar | ) | [private] |
Parsing piece char (e.g.
R,H,c,m, ... )
| recordAction_e OB_Board::parseRecordActionToken | ( | const string & | token, | |
| ob_player_t & | player, | |||
| ob_piece_t & | piece, | |||
| ob_square_t & | from, | |||
| ob_square_t & | to | |||
| ) | [private] |
Parsing single token for init from game record.
| token | given string token (e.g. Ra1n) | |
| player | player parsed from the token | |
| piece | piece parsed from the token | |
| from | position parsed from the token | |
| to | (optional) new position parsed from the token (only if it is a step) |
| void OB_Board::performKill | ( | ob_square_t | trapPos | ) | [private] |
Performs kill.
Performs operation connected to kill - board update, rabbits num update, etc.
| bool OB_Board::quickGoalCheck | ( | Move * | move = NULL |
) | const |
Quick check for goal.
Wrapper around previous function with player = player to move in current position stepLimit = steps left for player to move in current position
| bool OB_Board::quickGoalCheck | ( | ob_player_t | player, | |
| int | stepLimit, | |||
| Move * | move = NULL | |||
| ) | const |
Quick check for goal.
Checking is unreliable ! (looks only for direct goal score without help of other pieces). Done by wave algorithm from the goal line for given player.
| ob_player_t OB_Board::sideCharToPlayer | ( | char | side | ) | const [private] |
Side character to player.
Maps 'w','g' -> gold ; 'b', 's' -> silver.
| bool OB_Board::stepIsThirdRepetition | ( | const Step & | step | ) | const [private] |
Third repetition check.
| step | - expected to be last step in current move |
| bool OB_Board::stepIsVirtualPass | ( | Step & | step | ) | const [private] |
Virtual pass check.
| step | - expected to be last step in current move |
| Move OB_Board::tracebackFlagBoard | ( | const FlagBoard & | flagBoard, | |
| int | win_square, | |||
| ob_player_t | player | |||
| ) | const |
Traceback on flag board.
After successfull goal check, this method determines the move that scores the goal.
| void OB_Board::updateWinner | ( | ) |
Updates winner of the game.
Checks winner according to reaching goal, opponent has 0 rabbits.
Step OB_Board::lastStep_ [private] |
Last made step.
1.5.7.1