Cute Chess  0.1
Public Member Functions | Static Public Member Functions | Friends | List of all members
EcoNode Class Reference

A node in the ECO tree (Encyclopaedia of Chess Openings) More...

#include <econode.h>

Public Member Functions

EcoNodechild (const QString &sanMove) const
 
QString ecoCode () const
 
bool isLeaf () const
 
QString opening () const
 
QString variation () const
 
 ~EcoNode ()
 

Static Public Member Functions

static const EcoNodefind (const QVector< PgnGame::MoveData > &moves)
 
static void initialize ()
 
static void initialize (PgnStream &in)
 
static const EcoNoderoot ()
 
static void write (const QString &fileName)
 

Friends

LIB_EXPORT QDataStreamoperator<< (QDataStream &out, const EcoNode *node)
 
LIB_EXPORT QDataStreamoperator>> (QDataStream &in, EcoNode *&node)
 

Detailed Description

A node in the ECO tree (Encyclopaedia of Chess Openings)

The EcoNode class can be used to generate and query a database (a tree) of known chess openings that belong to the Encyclopaedia of Chess Openings. More about ECO: http://en.wikipedia.org/wiki/Encyclopaedia_of_Chess_Openings

The ECO tree can be generated from a PGN collection or from a binary file that's part of the cutechess library (the default). A node corresponding to a PgnGame can be found by traversing the ECO tree as new moves are added to the game, or by passing all the moves at once to the find() function.

Note
The Encyclopaedia of Chess Openings only applies to games of standard chess that start from the default starting position.

Constructor & Destructor Documentation

EcoNode::~EcoNode ( )

Destroys the node and its subtree.

Member Function Documentation

EcoNode * EcoNode::child ( const QString sanMove) const

Returns the node's child node corresponding to sanMove, or 0 if no match is found.

QString EcoNode::ecoCode ( ) const

Returns the node's ECO code, or an empty string if the node is an inner node.

const EcoNode * EcoNode::find ( const QVector< PgnGame::MoveData > &  moves)
static

Returns the deepest node (closest to the leaves) that matches the opening sequence in moves.

void EcoNode::initialize ( )
static

Initializes the ECO tree from the internal opening database.

void EcoNode::initialize ( PgnStream in)
static

Initializes the ECO tree by parsing the PGN games in in.

bool EcoNode::isLeaf ( ) const

Returns true if the node is a leaf node; otherwise returns false. A leaf node is a node that counts as an opening and has an ECO code and a name.

QString EcoNode::opening ( ) const

Returns the node's opening name, or an empty string if the node is an inner node.

const EcoNode * EcoNode::root ( )
static

Returns the root node of the ECO tree. initialize() is called first if the tree is uninitialized.

QString EcoNode::variation ( ) const

Returns the node's variation name, or an empty string if the node is an inner node or doesn't have a variation name.

void EcoNode::write ( const QString fileName)
static

Writes the ECO tree in binary format to fileName.

Friends And Related Function Documentation

LIB_EXPORT QDataStream& operator<< ( QDataStream out,
const EcoNode node 
)
friend

Writes the node node to stream out.

LIB_EXPORT QDataStream& operator>> ( QDataStream in,
EcoNode *&  node 
)
friend

Reads a node from stream in into node. node should be a null or uninitialized pointer.


The documentation for this class was generated from the following files: