Class Game
Representation of a chess game
Inheritance
Implements
Inherited Members
Namespace: PonzianiComponents.Chesslib
Assembly: PonzianiComponents.dll
Syntax
public class Game : ICloneable
Constructors
| Improve this Doc View SourceGame(String)
Creates a new Game
Declaration
public Game(string startposition = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
Parameters
Type | Name | Description |
---|---|---|
System.String | startposition | The start position of the game. If skipped the standard initial position is used |
Properties
| Improve this Doc View SourceBlack
Name of the player playing the black pieces
Declaration
public string Black { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Date
The starting date of the game
Declaration
public string Date { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Eco
The Eco classification of the game
Declaration
public Eco Eco { get; }
Property Value
Type | Description |
---|---|
Eco |
Event
The name of the tournament or match event
Declaration
public string Event { get; set; }
Property Value
Type | Description |
---|---|
System.String |
IntroductionComment
Introduction Comment: When parsing PGN there is sometimes a comment before the 1st move, adding some additional information about the game or the initial position
Declaration
public string IntroductionComment { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Moves
Enumeration of the moves of the game
Declaration
public List<ExtendedMove> Moves { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ExtendedMove> |
Position
Get's the current Position (after the last move)
Declaration
public Position Position { get; }
Property Value
Type | Description |
---|---|
Position |
Result
The result of the game
Declaration
public Result Result { get; set; }
Property Value
Type | Description |
---|---|
Result |
ResultDetail
The result of the game
Declaration
public ResultDetail ResultDetail { get; set; }
Property Value
Type | Description |
---|---|
ResultDetail |
Round
The playing round ordinal of the game
Declaration
public string Round { get; set; }
Property Value
Type | Description |
---|---|
System.String |
SideToMove
The Side to Move at the end of the current move list
Declaration
public Side SideToMove { get; }
Property Value
Type | Description |
---|---|
Side |
Site
The location of the event
Declaration
public string Site { get; set; }
Property Value
Type | Description |
---|---|
System.String |
StartPosition
The start position of the game (in FEN representation)
Declaration
public string StartPosition { get; }
Property Value
Type | Description |
---|---|
System.String |
Tags
Additional Tags
Declaration
public Dictionary<string, string> Tags { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
TimeControl
TimeControl used when game was played (usually null)
Declaration
public TimeControl TimeControl { get; set; }
Property Value
Type | Description |
---|---|
TimeControl |
White
Name of the player playing the white pieces
Declaration
public string White { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceAdd(ExtendedMove)
Adds a new Move to the game
Declaration
public bool Add(ExtendedMove extendedMove)
Parameters
Type | Name | Description |
---|---|---|
ExtendedMove | extendedMove |
Returns
Type | Description |
---|---|
System.Boolean | true, if move is legal |
AddVariation(List<ExtendedMove>, Int32, Side)
Adds a variation to the current game
Declaration
public void AddVariation(List<ExtendedMove> variation, int moveNumber = 1, Side side = Side.WHITE)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<ExtendedMove> | variation | List of all moves, which form the variation |
System.Int32 | moveNumber | Move number where variation starts |
Side | side | Side to move where variation starts |
Clone()
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object |
GetMove(Int32, Side)
Move for a given movenumber and side
Declaration
public ExtendedMove GetMove(int moveNumber, Side side)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | moveNumber | Move number for which the position should be determined |
Side | side | Side (White/Black) for which the position should be determined |
Returns
Type | Description |
---|---|
ExtendedMove | The move at that point within the game |
GetPosition(Int32, Side)
Position for a given move within the game
Declaration
public Position GetPosition(int moveNumber, Side side)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | moveNumber | Move number for which the position should be determined |
Side | side | Side (White/Black) for which the position should be determined |
Returns
Type | Description |
---|---|
Position | The position at that point within the game |
PlyIndex(Int32, Side)
Declaration
public static int PlyIndex(int moveNumber, Side side)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | moveNumber | |
Side | side |
Returns
Type | Description |
---|---|
System.Int32 |
SANNotation(Boolean, Boolean)
Outputs the Game in SAN (Standard Algebraic Notation) Notation
Declaration
public string SANNotation(bool withComments = true, bool withVariations = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | withComments | |
System.Boolean | withVariations |
Returns
Type | Description |
---|---|
System.String | A string containing the notation |
SetResult(String)
Set's the game's result from it's string representation
Declaration
public bool SetResult(string resultString)
Parameters
Type | Name | Description |
---|---|---|
System.String | resultString | The result as string, either "*", "1-0", "0-1", or "1/2-1/2" |
Returns
Type | Description |
---|---|
System.Boolean | true, if valid result string has been passed |
SetTag(String, String)
Set's a PGN Tag value
Declaration
public void SetTag(string tag, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | tag | The tag's name |
System.String | value | The tag's value |
ToPGN(IPGNOutputFormatter, Boolean)
Outputs the Game in PGN (Portable Game Notation) format
Declaration
public string ToPGN(IPGNOutputFormatter formatter = null, bool withVariations = false)
Parameters
Type | Name | Description |
---|---|---|
IPGNOutputFormatter | formatter | A IPGNOutputFormatter, which creates PGN comments for each move |
System.Boolean | withVariations |
Returns
Type | Description |
---|---|
System.String | A string containing the pgn formatted gamse |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
UndoLastMove()
Undos the last applied move from the game
Declaration
public bool UndoLastMove()
Returns
Type | Description |
---|---|
System.Boolean | true if successful |