app/game_session.h¶
frontend-agnostic game orchestrator.
GameSession owns the single play loop (extracted from main.cpp’s runSensorGameLoop) on a worker thread. Callers issue thread-safe commands (newGame / submitHumanMove / stop / restart / shutdown) and observe progress through GameSessionListener. The CLI and the Qt GUI both drive it this way.
Threading: all listener callbacks fire on the worker thread. UI front-ends must marshal them to their own thread (the Qt SessionBridge uses queued signals). See docs/gui-docs/PLAN.md §3.1.
-
namespace kirin
Enums
-
struct BoardMismatchInfo¶
- #include <game_session.h>
-
struct ClockInfo¶
- #include <game_session.h>
-
struct GameOverInfo¶
- #include <game_session.h>
-
class GameSession¶
- #include <game_session.h>
Public Functions
-
GameSession(IEngine &engine, IBoardBackend &backend)¶
-
~GameSession()¶
-
GameSession(const GameSession&) = delete¶
-
GameSession &operator=(const GameSession&) = delete¶
-
void addListener(GameSessionListener *listener)¶
-
void start()¶
-
void newGame(const NewGameConfig &config)¶
-
void submitHumanMove(const std::string &uci)¶
-
void takeback()¶
-
void stop()¶
-
void resetBoard()¶
-
void shutdown()¶
-
inline SessionState state() const¶
Private Types
Private Functions
-
void run()¶
-
void playGame(const NewGameConfig &config)¶
-
void resetBoardToStart()¶
-
void recordMove(const std::string &uci, int encoded)¶
-
void performTakeback()¶
-
bool endIfFlagged(char sideOnMove)¶
-
void armFlagWatchdog()¶
-
void disarmFlagWatchdog()¶
-
SearchLimits limitsFor(const SearchLimits &base) const¶
-
bool reconcileBoard(int lastMove)¶
-
void setState(SessionState s)¶
-
void emitGameStarted(const GameStartInfo&)¶
-
void emitHumanTurn(char side)¶
-
void emitGameOver(const GameOverInfo&)¶
-
void emitBoardMismatch(const BoardMismatchInfo&)¶
-
void emitClock()¶
-
void emitTakeback(const TakebackInfo&)¶
-
void emitThinking(const ThinkingInfo&)¶
-
void emitInfo(const std::string&)¶
-
void emitError(const std::string&)¶
Private Members
-
IBoardBackend &backend_¶
-
std::vector<GameSessionListener*> listeners_¶
-
std::thread worker_¶
-
std::mutex cmdMutex_¶
-
std::condition_variable cmdCv_¶
-
std::atomic<bool> stopRequested_ = {false}¶
-
std::atomic<bool> shutdownRequested_ = {false}¶
-
std::atomic<SessionState> state_ = {SessionState::Idle}¶
-
std::atomic<bool> waitCancel_ = {false}¶
-
std::thread flagWatchdog_¶
-
std::mutex watchdogMutex_¶
-
std::condition_variable watchdogCv_¶
-
std::atomic<bool> watchdogStop_ = {false}¶
-
std::vector<PlayedMove> history_¶
-
PieceTracker identity_¶
-
std::string startFen_¶
-
bool takebackable_ = false¶
-
NewGameConfig currentConfig_¶
-
struct Command¶
-
struct PlayedMove¶
-
GameSession(IEngine &engine, IBoardBackend &backend)¶
-
class GameSessionListener¶
- #include <game_session.h>
Subclassed by kirin::GameRecorder, kirin::LedAssist, kirin::NetworkOpponent
Public Functions
-
virtual ~GameSessionListener() = default¶
-
inline virtual void onStateChanged(SessionState)¶
-
inline virtual void onGameStarted(const GameStartInfo&)¶
-
inline virtual void onHumanTurn(char sideToMove)¶
-
inline virtual void onGameOver(const GameOverInfo&)¶
-
inline virtual void onBoardMismatch(const BoardMismatchInfo&)¶
-
inline virtual void onTakeback(const TakebackInfo&)¶
-
inline virtual void onThinking(const ThinkingInfo&)¶
-
inline virtual void onInfo(const std::string&)¶
-
inline virtual void onError(const std::string&)¶
-
virtual ~GameSessionListener() = default¶
-
struct GameStartInfo¶
- #include <game_session.h>
-
struct MoveEvent¶
- #include <game_session.h>
-
struct NewGameConfig¶
- #include <game_session.h>
Public Members
-
bool enginePlaysWhite = true¶
-
EngineOptions options¶
-
SearchLimits limits¶
-
std::string startFen¶
-
std::optional<PieceTracker> startIdentity¶
-
TimeControl timeControl¶
-
bool opponentIsRemote = false¶
-
std::string opponentName¶
-
std::string gameId¶
-
bool enginePlaysWhite = true¶
-
struct TakebackInfo¶
- #include <game_session.h>
-
struct BoardMismatchInfo¶