Skip to content

Commit

Permalink
Add GamePhase get_phase to states
Browse files Browse the repository at this point in the history
  • Loading branch information
QueensGambit committed May 3, 2024
1 parent 81e1a94 commit 3cbb403
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion engine/src/environments/chess_related/boardstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class BoardState : public State
void set_auxiliary_outputs(const float* auxiliaryOutputs) override;
BoardState* clone() const override;
void init(int variant, bool isChess960) override;
GamePhase get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const;
GamePhase get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const override;
};

#endif // BOARTSTATE_H
Expand Down
6 changes: 6 additions & 0 deletions engine/src/environments/fairy_state/fairystate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@ void FairyState::init(int variant, bool isChess960)
board.set(variants.find(StateConstantsFairy::available_variants()[variant])->second, variants.find(StateConstantsFairy::available_variants()[variant])->second->startFen, isChess960, &states->back(), nullptr, false);
variantNumber = variant;
}

GamePhase FairyState::get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const
{
// TODO: Implement phase definition here
return GamePhase(0);
}
1 change: 1 addition & 0 deletions engine/src/environments/fairy_state/fairystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class FairyState : public State
Tablebase::WDLScore check_for_tablebase_wdl(Tablebase::ProbeState &result) override;
void set_auxiliary_outputs(const float* auxiliaryOutputs) override;
void init(int variant, bool isChess960);
GamePhase get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const override;
};

#endif // FAIRYSTATE_H
1 change: 1 addition & 0 deletions engine/src/environments/open_spiel/openspielstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class OpenSpielState : public State
void set_auxiliary_outputs(const float* auxiliaryOutputs);
OpenSpielState *clone() const;
void init(int variant, bool isChess960);
GamePhase get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const override;
};

#endif // OPENSPIELSTATE_H
6 changes: 6 additions & 0 deletions engine/src/environments/stratego_related/strategostate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,9 @@ void StrategoState::init(int variant, bool isChess960) {
spielState = spielGame->NewInitialState();
}
}

GamePhase StrategoState::get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const
{
// TODO: Implement phase definition here
return GamePhase(0);
}
1 change: 1 addition & 0 deletions engine/src/environments/stratego_related/strategostate.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class StrategoState : public State
StrategoState *clone() const;
StrategoState *openBoard() const;
void init(int variant, bool isChess960) override;
GamePhase get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const override;
};

#endif // STRATEGOSTATE_H
9 changes: 9 additions & 0 deletions engine/src/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ class State
* @param variant Variant which the position corresponds to
*/
virtual void init(int variant, bool isChess960) = 0;

/**
* @brief get_phase Returns the current game phase of the state
* @param numPhases Number of phases in total
* @param gamePhaseDefinition Game phase definition to use (e.g. MOVECOUNT, LICHESS)
* @return Game phase (uint)
*/
virtual GamePhase get_phase(unsigned int numPhases, GamePhaseDefinition gamePhaseDefinition) const = 0;

};

#endif // GAMESTATE_H

0 comments on commit 3cbb403

Please sign in to comment.