libscid snapshot+e944e108ed8b
Chess applications made easy.
Source on GitHub License GPL v2
Loading...
Searching...
No Matches
scid::core::gamepos Namespace Reference

Named board positions commonly used as game starting points. More...

Classes

struct  GamePos
 A serialisable snapshot of one reachable position in a game. More...
 

Functions

template<typename TCont >
void collectPositions (const scid::core::Game &game, TCont &dest)
 Append all position snapshots of a game to a caller-supplied container.
 
std::vector< GamePoscollectPositions (const scid::core::Game &game)
 Return all position snapshots of a game.
 

Detailed Description

Named board positions commonly used as game starting points.

gamepos contains compact predefined position data for normal chess and Chess960 starts. Callers use these helpers when they need a known initial board state without parsing a FEN string.

Function Documentation

◆ collectPositions() [1/2]

std::vector< GamePos > scid::core::gamepos::collectPositions ( const scid::core::Game game)
inline

Return all position snapshots of a game.

Parameters
gameGame whose main line and variations are traversed.
Returns
A vector containing the same snapshots that the templated overload would append to an empty container.

◆ collectPositions() [2/2]

template<typename TCont >
void scid::core::gamepos::collectPositions ( const scid::core::Game game,
TCont &  dest 
)
inline

Append all position snapshots of a game to a caller-supplied container.

The traversal follows PGN RAV semantics: a variation starts from the position before the move immediately preceding the RAV, and nested RAVs are emitted recursively. The resulting stream is intended for clients that need a flat representation of a game tree while still being able to reconstruct variation boundaries.

To follow one variation from a given snapshot, keep reading while the next snapshots have a greater GamePos::RAVdepth. The variation ends at the first snapshot with a lower depth, an equal depth with a different GamePos::RAVnum, or the end of dest.

for (const auto& pos : positions) {
if (pos.RAVdepth == 0) {
showMainlinePosition(pos.FEN, pos.lastMoveSAN);
}
}
void collectPositions(const scid::core::Game &game, TCont &dest)
Append all position snapshots of a game to a caller-supplied container.
Definition game_positions.h:88
Template Parameters
TContContainer type supporting emplace_back() and back().
Parameters
gameGame whose main line and variations are traversed.
destContainer to which snapshots are appended. Existing contents are preserved.