app/network_opponent.h¶
the remote human, presented to GameSession as an opponent.
GameSession is written against IEngine (“where the opponent’s move comes
from”) and IBoardBackend (“the physical board”), so networked play needs no new game loop (docs/networked-play-docs/PLAN.md §2). NetworkOpponent supplies the two hooks:
• Inbound — as an IEngine, its go() blocks on the transport for the peer’s move instead of searching. GameSession then plays that move on the local gantry via IBoardBackend, exactly as it plays an engine move today. • Outbound — as a GameSessionListener, onMovePlayed() relays each locally made move (the human on this board) back out to the peer.
Every other IEngine method delegates to a wrapped inner engine (LinkedEngine) so the authoritative chess state stays consistent with the board backend, which shares that same inner engine.
Networked mode is a toggle (setNetworked). It defaults to on — a NetworkOpponent is remote unless told otherwise. Turned off, the two hooks fall back to the wrapped engine (go() runs a real local search; no moves are relayed), so a single opponent instance can back both a friend game and a local AI game on the same board without reconstructing the GameSession. This is what lets the Qt SessionBridge flip one game loop between the two modes.
-
namespace kirin
-
class NetworkOpponent : public kirin::IEngine, public kirin::GameSessionListener¶
- #include <network_opponent.h>
Public Functions
-
inline NetworkOpponent(IEngine &inner, INetworkTransport &transport)¶
-
inline void setNetworked(bool on)¶
-
inline bool networked() const¶
-
inline virtual void applyOptions(const EngineOptions &opts) override¶
-
inline virtual void newGame(const std::string &fen = "") override¶
-
inline virtual bool playMove(const std::string &uci) override¶
-
inline virtual bool playMove(int encodedMove) override¶
-
inline virtual int parseMove(const std::string &uci) override¶
-
inline virtual std::string fen() const override¶
-
inline virtual char sideToMove() const override¶
-
inline virtual GameResult result() const override¶
-
inline virtual bool isGameOver() const override¶
-
inline virtual std::string resultReason() const override¶
-
inline virtual AnalysisLine analyze(const SearchLimits &limits) override¶
-
virtual std::string go(const SearchLimits &limits, const ThinkingCallback &onInfo = nullptr) override¶
-
virtual void stop() override¶
-
inline NetworkOpponent(IEngine &inner, INetworkTransport &transport)¶
-
class NetworkOpponent : public kirin::IEngine, public kirin::GameSessionListener¶