/// <summary> /// Convert bitMove to Coordinate /// </summary> public static (int row, int col) ToCoordinate(this ulong bitMove) { if (!bitMove.IsValid()) { return(-1, -1); } var index = bitMove.BitScanReverse(); return(index / 8, index % 8); }
public static void DisplayWithLastMoveAndLegalMoves(this BitBoard board, ulong lastBitMove, byte player) { Console.WriteLine(" a b c d e f g h"); var legalMoves = board.GetLegalMoves(player); var moveIndex = lastBitMove.BitScanReverse(); var row = 0; for (var i = 0; i < 64; i++) { if (i % 8 == 0) { row++; if (i != 0) { Console.WriteLine(); } Console.Write(row + " "); } var pos = 1UL << i; var isBlack = (board.Pieces[Black] & pos) != 0; var isWhite = (board.Pieces[White] & pos) != 0; if (isBlack && isWhite) { Console.Write(Constant.WrongCellStr); } else if (isBlack) { Console.Write(moveIndex == i ? Constant.LastBlackMoveStr : Constant.BlackPieceStr); } else if (isWhite) { Console.Write(moveIndex == i ? Constant.LastWhiteMoveStr : Constant.WhitePieceStr); } else if ((legalMoves & pos) != 0) { Console.Write(Constant.LegalMoveStr); } else { Console.Write(Constant.EmptyCellStr); } } Console.WriteLine(); }