Show / Hide Table of Contents

Class Position

This class represents a position in standard chess

Inheritance
System.Object
Position
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)
System.Object.ToString()
Namespace: PonzianiComponents.Chesslib
Assembly: PonzianiComponents.dll
Syntax
public class Position : ICloneable

Constructors

| Improve this Doc View Source

Position()

Create the start position

Declaration
public Position()
| Improve this Doc View Source

Position(String)

Create a position from a FEN string

Declaration
public Position(string fen)
Parameters
Type Name Description
System.String fen

The position specified in FEN notation

Properties

| Improve this Doc View Source

Chess960

Position is a Chess960 position

Declaration
public bool Chess960 { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

DrawPlyCount

The number of plies since the last pawn push or capture

Declaration
public int DrawPlyCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

EPD

The EPD representation of the position (FEN without move number and h50 move counter

Declaration
public string EPD { get; }
Property Value
Type Description
System.String
Remarks

The En-passant square is only provided if there is a capture possible

| Improve this Doc View Source

EPSquare

The En-Passant Square (the to-square of an en passant capture). This square is only set, if an enpassant capture is possible (not after any pawn double move as in FEN standard)

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

FEN

The FEN representation of the position In case of Chess960 X-Fen representation is used

Declaration
public string FEN { get; }
Property Value
Type Description
System.String
Remarks

The En-passant square is only provided if there is a capture possible

| Improve this Doc View Source

IsCheck

Returns true is side to move is in check

Declaration
public bool IsCheck { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsDoubleCheck

Returns true if side to move is double-checked

Declaration
public bool IsDoubleCheck { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsMate

Returns true if position is a mate

Declaration
public bool IsMate { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsStalemate

Returns true if position is stalemate

Declaration
public bool IsStalemate { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

MoveNumber

The move number of the current position

Declaration
public int MoveNumber { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

PolyglotKey

Hash Key of current position used to find position in Polyglot opening books

Declaration
public ulong PolyglotKey { get; }
Property Value
Type Description
System.UInt64
| Improve this Doc View Source

SFEN

The Shredder-FEN representation of the position (only relevant for Chess960)

Declaration
public string SFEN { get; }
Property Value
Type Description
System.String
Remarks

The En-passant square is only provided if there is a capture possible

| Improve this Doc View Source

SideToMove

The side which has to make the next move

Declaration
public Side SideToMove { get; }
Property Value
Type Description
Side

Methods

| Improve this Doc View Source

ApplyMove(Move)

Applies a move to the position

Declaration
public void ApplyMove(Move move)
Parameters
Type Name Description
Move move

The move to be applied

| Improve this Doc View Source

ApplyMove(String)

Applies a move to the position

Declaration
public void ApplyMove(string moveInUCINotation)
Parameters
Type Name Description
System.String moveInUCINotation

The move to be applied in UCI notation

| Improve this Doc View Source

ASCII()

ASCII rendering of position. Allows to printout a position diagram in console applications

Declaration
public string ASCII()
Returns
Type Description
System.String

ASCII based position diagramm

| Improve this Doc View Source

AsHTML()

HTML rendering of position. Useful for debugging within Visual Studio

Declaration
public string AsHTML()
Returns
Type Description
System.String

An HTML string showing the position diagram

| Improve this Doc View Source

CastlingAllowed(CastleFlag)

Returns true if the provided Castling option is allowed

Declaration
public bool CastlingAllowed(CastleFlag flag)
Parameters
Type Name Description
CastleFlag flag
Returns
Type Description
System.Boolean
| Improve this Doc View Source

CheckLegal(out String)

Checks if a position is legal and consistent

Declaration
public bool CheckLegal(out string message)
Parameters
Type Name Description
System.String message

out parameter providing information about cause of illegality

Returns
Type Description
System.Boolean

true, if position is legal, false otherwise

| Improve this Doc View Source

Clone()

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

Divide(Int32)

Returns the Divide value (a variation of perft, listing all moves and for each move, the perft of the decremented depth)

Declaration
public Dictionary<Move, long> Divide(int depth)
Parameters
Type Name Description
System.Int32 depth

The depth for which the divide command shall be executed

Returns
Type Description
System.Collections.Generic.Dictionary<Move, System.Int64>

A Dictionary which contains for any legal move in the positions a perft result

| Improve this Doc View Source

FixCastlingFlags()

Declaration
public void FixCastlingFlags()
| Improve this Doc View Source

GetMoves()

Generates a list of all legal Moves

Declaration
public List<Move> GetMoves()
Returns
Type Description
System.Collections.Generic.List<Move>

List of all legal moves

| Improve this Doc View Source

GetPhase()

Calculates the game phase starting by 0 at startposition and ending at 256 (Pawn ending)

Declaration
public int GetPhase()
Returns
Type Description
System.Int32

The game phase

| Improve this Doc View Source

GetPiece(Square)

Get's the piece for a given square

Declaration
public Piece GetPiece(Square square)
Parameters
Type Name Description
Square square

A square

Returns
Type Description
Piece

The piece on the square

| Improve this Doc View Source

GetPieceSquareList()

Calculates a list of squares for each piece

Declaration
public Dictionary<Piece, List<Square>> GetPieceSquareList()
Returns
Type Description
System.Collections.Generic.Dictionary<Piece, System.Collections.Generic.List<Square>>

Dictionary with list of Square for each Piece

| Improve this Doc View Source

IsDrawnByInsufficientMatingMaterial()

Checks if position is drawn due to lack of sufficient mating material

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

true, if position is drawn

| Improve this Doc View Source

Perft(Int32, Boolean)

Calculates the perft value of the current position See https://chessprogramming.wikispaces.com/Perft

Declaration
public long Perft(int depth, bool divide = false)
Parameters
Type Name Description
System.Int32 depth

The depth for which perft should be calculated

System.Boolean divide

If true, the subresults for each move on the initial depth will be printed to console https://www.chessprogramming.org/Perft

Returns
Type Description
System.Int64

The perft result

| Improve this Doc View Source

ToSAN(Move)

Creates the SAN (Standard Algebraic Notation) encoding of a move

Declaration
public string ToSAN(Move move)
Parameters
Type Name Description
Move move

The move to be encoded

Returns
Type Description
System.String

The SAN encoded move

Implements

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