Show / Hide Table of Contents

Class Game

Representation of a chess game

Inheritance
System.Object
Game
Implements
System.ICloneable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: PonzianiComponents.Chesslib
Assembly: PonzianiComponents.dll
Syntax
public class Game : ICloneable

Constructors

| Improve this Doc View Source

Game(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 Source

Black

Name of the player playing the black pieces

Declaration
public string Black { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Date

The starting date of the game

Declaration
public string Date { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Eco

The Eco classification of the game

Declaration
public Eco Eco { get; }
Property Value
Type Description
Eco
| Improve this Doc View Source

Event

The name of the tournament or match event

Declaration
public string Event { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

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
| Improve this Doc View Source

Moves

Enumeration of the moves of the game

Declaration
public List<ExtendedMove> Moves { get; }
Property Value
Type Description
System.Collections.Generic.List<ExtendedMove>
| Improve this Doc View Source

Position

Get's the current Position (after the last move)

Declaration
public Position Position { get; }
Property Value
Type Description
Position
| Improve this Doc View Source

Result

The result of the game

Declaration
public Result Result { get; set; }
Property Value
Type Description
Result
| Improve this Doc View Source

ResultDetail

The result of the game

Declaration
public ResultDetail ResultDetail { get; set; }
Property Value
Type Description
ResultDetail
| Improve this Doc View Source

Round

The playing round ordinal of the game

Declaration
public string Round { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

SideToMove

The Side to Move at the end of the current move list

Declaration
public Side SideToMove { get; }
Property Value
Type Description
Side
| Improve this Doc View Source

Site

The location of the event

Declaration
public string Site { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

StartPosition

The start position of the game (in FEN representation)

Declaration
public string StartPosition { get; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Tags

Additional Tags

Declaration
public Dictionary<string, string> Tags { get; set; }
Property Value
Type Description
System.Collections.Generic.Dictionary<System.String, System.String>
| Improve this Doc View Source

TimeControl

TimeControl used when game was played (usually null)

Declaration
public TimeControl TimeControl { get; set; }
Property Value
Type Description
TimeControl
| Improve this Doc View Source

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 Source

Add(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

| Improve this Doc View Source

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

| Improve this Doc View Source

Clone()

Declaration
public object Clone()
Returns
Type Description
System.Object
| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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
| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()
| Improve this Doc View Source

UndoLastMove()

Undos the last applied move from the game

Declaration
public bool UndoLastMove()
Returns
Type Description
System.Boolean

true if successful

Implements

System.ICloneable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX