public static string toAlgebraicNotation(string s) { string an = null; int c1, r1, c2, r2; char piece; if (Notations.parse(s, out c1, out r1, out c2, out r2) && (piece = Board.pieces[c1, r1]) != '\0') { an = piece.ToString(); PieceType type = Board.GetType(piece); PieceColor color = Board.GetColor(piece); if (Board.GetColor(piece) == PieceColor.WHITE) { an = an.ToLower(); } char dest = Board.pieces[c2, r2]; if (dest != '\0' && Board.GetColor(dest) != color && Board.GetType(dest) != PieceType.KING) { an += "x"; }/* * if (type != PieceType.PAWN && type > PieceType.QUEEN) * { * int i = Board.GetPos(piece, c1 * 8 + r1); * if (i != -1) * { * int pc = i / 8; * int pr = i % 8; * int p2 = Board.pieces[pc, pr]; * int capture = -1; * if (Board.ValidMove(type, pc, pr, c2, r2, out capture)) * { * if (c1 == pc) * an += Math.Abs(r1 - 8); * else * an += (char)(c1 + 97); * } * } * }*/ an += string.Format("{0}{1}", (char)(c2 + 97), Math.Abs(r2 - 8)); if (dest != '\0' && Board.GetType(dest) == PieceType.KING) { an += "++"; } } return(an); }
public void MoveFromHistory(ArrayList history, int n) { InitBoard(); for (int i = 0; i < n; i++) { HMove move = (HMove)history[i]; if (move.Nn == string.Empty) { move.Nn = Notations.fromAlgebraicNotation(move.An); } int c, r, c2, r2; Notations.parse(move.Nn, out c, out r, out c2, out r2); Piece p = (Piece)Board._pieces[c + "x" + r]; p.Move(c2, r2); Board.whites = !Board.whites; } }