项目作者: nulligun

项目描述 :
C# probing code for 5 man Gaviota End Game Table Bases
高级语言: C#
项目地址: git://github.com/nulligun/gaviota-probe-dotnet.git
创建时间: 2017-07-31T01:38:20Z
项目社区:https://github.com/nulligun/gaviota-probe-dotnet

开源协议:MIT License

下载


This is a C# port of the Gaviota end game table base probing code. This is the same version of the probing code that is included in the Xbox version of Pwned the Game of Chess.

http://pwnedthegameofchess.com

How to use it

  1. Add the EGTB project to your solution.
  2. Add a reference for the EGTB’s to your project.
  3. Build the board structure and call the probing function\
  1. ProbeResultType probeResult = EGTB.Probe(whitePieceSquares, blackPieceSquares, whiteTypesSquares, blackTypesSquares, whosTurn, enPassantSquare);
  2. if (probeResult.found) {
  3. if (probeResult.stm == MateResult.BlackToMate) {
  4. Console.WriteLine("Black to mate in {0} plies", pr.ply);
  5. } else if (probeResult.stm == MateResult.WhiteToMate) {
  6. Console.WriteLine("White to mate in {0} plies", pr.ply);
  7. } else if (probeResult.stm == MateResult.Draw) {
  8. Console.WriteLine("Draw", pr.ply);
  9. } else {
  10. Console.WriteLine("No match in EGTB", pr.ply);
  11. }
  12. } else {
  13. Console.WriteLine("Could not find it: " + pr.error);
  14. }

Board Structure

whitePieceSquares and blackPieceSquares are List<int> types. Each entry is a zero based index identifying the square that contains a piece. A1 is 0, A2 is 1 etc…

whiteTypeSquares and blackTypeSquares are List<int> types used to represent piece types for each square defined in the previous lists. There is an enum defined to map to the correct ID for each piece.

eg, for a white Rook at A1

  1. whitePieceSquares = new List<int>();
  2. whiteTypeSquares = new List<int>();
  3. whitePieceSquares.Add(EGTB.A1);
  4. whiteTypeSquares.Add(EGTB.KING);

whosTurn 0 = white, 1 = black

enPassantSquare If a pawn has just made a two-square move, this is the position behind the pawn.

ProbeResultType

  1. public bool found; // true if there was a hit
  2. public MateResult stm; // WhiteToMate, BlackToMate, Draw, Unknown
  3. public string error; // human readable error
  4. public int ply; // absolute distance to action
  5. public int dtm; // positive if we are mating, negative if being mated

For a complete example please see the egtb_probe solution. It will convert a FEN string to a Gaviota board structure and invoke the probing code.