Open oulenspiegel opened 7 years ago
I just noticed also another issue with the FEN tag: if you access the value from the Game.Tags dictionary, instead of getting the original string, you seem to get the ASCII diagram of the board... in the example above, Game.Tags("FEN") returns
---------------------------------
| R | | B | | | R | K | |
---------------------------------
| P | P | | | P | P | B | P |
---------------------------------
| | | N | | | N | P | |
---------------------------------
| Q | | p | P | | | b | |
---------------------------------
| | | | | | | | |
---------------------------------
| | | n | | p | | | |
---------------------------------
| p | p | p | q | | p | p | p |
---------------------------------
| | k | | r | | b | n | r |
---------------------------------
I really am not skilled in F#, so i might be completely misunderstanding the code, but I think the idea was to add an additional custom tag to keep the ASCII diagram (given by boardSetup.toString()), that was intended to be filtered out by the game.toString() method, to show only the actual tags of the game/file
It has been, however, added in the dictionary by mistake using the "FEN" name, instead of some arbitrary new one, and thus it overwrites the standard FEN tag
I just noticed also another issue with the FEN tag: if you access the value from the Game.Tags dictionary, instead of getting the original string, you seem to get the ASCII diagram of the board
I am seeing the same thing
This is a very crude patch, and it only fixes the Game.Tags dictionary, not the Game.ToString() issue, but it gets the job done for what I'm doing, so in case someone find it usefull too, here it is:
In Pgn.Data.BoardSetup.cs replace .ToString() with:
public override string ToString()
{
string output = "";
Piece piece;
string row,pieceStr,castleStr,epStr;
int emptySquares;
for (int iRank = 0; iRank < 8; ++iRank)
{
row = "";
emptySquares = 0;
for (int iFile = 0; iFile < 8; ++iFile)
{
piece = this[iFile, iRank];
if (piece == null)
{
emptySquares += 1;
}
else
{
if (emptySquares > 0) row += emptySquares.ToString();
pieceStr = PieceToString(this[iFile, iRank]);
row += pieceStr.Trim();
emptySquares = 0;
}
if (iFile > 0 & iFile % 7 == 0)
{
if (emptySquares > 0) row += emptySquares.ToString();
output += row;
if (iRank < 7) output += "/";
}
}
}
if (IsWhiteMove)
output += " w";
else
output += " b";
castleStr = " ";
if (CanWhiteCastleKingSide)
castleStr += "K";
if (CanWhiteCastleQueenSide)
castleStr += "Q";
if (CanBlackCastleKingSide )
castleStr += "k";
if (CanBlackCastleQueenSide)
castleStr += "q";
if (castleStr.Length > 1)
output += castleStr;
else
output += " -";
epStr = "-";
if (EnPassantSquare != null)
epStr = EnPassantSquare.ToString();
output += " " + epStr;
output += " " + HalfMoveClock.ToString();
output += " " + FullMoveCount.ToString();
return output;
}
PGN example:
[Event "Arena Tournament"] [Site "MARKOVPC"] [Date "2016.11.21"] [Round "1"] [White "R2459"] [Black "R2454"] [Result "1/2-1/2"] [BlackElo "2700"] [Time "05:20:14"] [WhiteElo "2700"] [TimeControl "15+0"] [SetUp "1"] [FEN "1k1r1bnr/pppq1ppp/2n1p3/8/Q1pP2b1/2N2NP1/PP2PPBP/R1B2RK1 w - - 0 1"] [Termination "normal"] [PlyCount "137"] [WhiteType "program"] [BlackType "program"] [Comment ";"]