Cute Chess  0.1
Classes | Public Types | Public Member Functions | List of all members
OpeningSuite Class Reference

A suite of chess openings. More...

#include <openingsuite.h>

Public Types

enum  Format { EpdFormat, PgnFormat }
 
enum  Order { SequentialOrder, RandomOrder }
 

Public Member Functions

Format format () const
 
bool initialize ()
 
bool isNull () const
 
PgnGame nextGame (int maxPlies)
 
 OpeningSuite (const QString &fen)
 
 OpeningSuite (const QString &fileName, Format format, Order order=SequentialOrder, int startIndex=0)
 
Order order () const
 
 ~OpeningSuite ()
 

Detailed Description

A suite of chess openings.

This class acts as an abstract interface for accessing a suite of chess openings in EPD or PGN format. An OpeningSuite object reads positions and games from a text stream (eg. a text file) and returns the opening as a PgnGame object.

See also
EpdRecord
PgnGame

Member Enumeration Documentation

The format of the opening data.

Enumerator
EpdFormat 

EPD format.

PgnFormat 

PGN format.

The order in which openings are picked.

Enumerator
SequentialOrder 

Sequential order.

RandomOrder 

Random order.

Constructor & Destructor Documentation

OpeningSuite::OpeningSuite ( const QString fen)

Creates a new opening suite that starts every game at fen.

OpeningSuite::OpeningSuite ( const QString fileName,
Format  format,
Order  order = SequentialOrder,
int  startIndex = 0 
)

Creates a new opening suite that reads the openings from fileName in format format.

Openings will be picked according to order.

If order is SequentialOrder, startIndex will be the index of the first opening. If order is RandomOrder, then setting a start index does nothing.

Note
The created opening suite is null until initialize() is called.
OpeningSuite::~OpeningSuite ( )

Destroys the opening suite.

Member Function Documentation

OpeningSuite::Format OpeningSuite::format ( ) const

Returns the format of the source data.

bool OpeningSuite::initialize ( )

Initializes the opening suite.

If order is SequentialOrder, this function just opens the opening suite file and gets ready to read data. If order is RandomOrder, the file positions of all the openings are parsed from the file, which could take some time if the file is large.

Returns true if successful; otherwise returns false.

bool OpeningSuite::isNull ( ) const

Returns true if the suite contains no data; otherwise returns false.

PgnGame OpeningSuite::nextGame ( int  maxPlies)

Reads a new opening from the suite and returns it. A maximum of maxPlies plies (halfmoves) are read.

OpeningSuite::Order OpeningSuite::order ( ) const

Returns the order in which openings are picked.


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