public BenchmarkItem(string[] moves) { // for now only white color will be supported // (when i'll have time later, it will be expanded) this.provider = new GameProvider(new MovesArrayAllocator(100, 100)); Color color = Color.White; foreach (var moveStr in moves) { if (moveStr.Length == 0) continue; Move move = new Move(moveStr); if (this.provider.PlayerBoards[(int)color].Figures[(int)move.From] == Queem.Core.Figure.King) if (Math.Abs((int)move.From - (int)move.To) == 2) move.Type = MoveType.KingCastle; this.provider.ProcessMove(move, color); bool needsPromotion = (int)move.Type >= (int)MoveType.Promotion; if (needsPromotion) this.provider.PromotePawn( color, move.To, move.Type.GetPromotionFigure()); color = (Queem.Core.Color)(1 - (int)color); } solver = new ChessSolver(new DebutGraph()); this.lastColor = color; }
private void worker_DoWork(object sender, DoWorkEventArgs e) { ChessSolver solver = new ChessSolver(this.debutsGraph); e.Result = solver.SolveProblem( this.gameProvider, this.chessboardControl.CurrentPlayerColor, this.maxdepth); }
public BenchmarkItem(string[] moves) { // for now only white color will be supported // (when i'll have time later, it will be expanded) this.provider = new GameProvider(new MovesArrayAllocator(100, 100)); Color color = Color.White; foreach (var moveStr in moves) { if (moveStr.Length == 0) { continue; } Move move = new Move(moveStr); if (this.provider.PlayerBoards[(int)color].Figures[(int)move.From] == Queem.Core.Figure.King) { if (Math.Abs((int)move.From - (int)move.To) == 2) { move.Type = MoveType.KingCastle; } } this.provider.ProcessMove(move, color); bool needsPromotion = (int)move.Type >= (int)MoveType.Promotion; if (needsPromotion) { this.provider.PromotePawn( color, move.To, move.Type.GetPromotionFigure()); } color = (Queem.Core.Color)(1 - (int)color); } solver = new ChessSolver(new DebutGraph()); this.lastColor = color; }
static void Main(string[] args) { //"r2qkb1r/pb1nppp1/2p4p/1p1nP1B1/2pPN3/5N2/PP2BPPP/R2QK2R w - - 0 1" var chess = new Chess("rnb1kbnr/ppppqppp/8/8/8/8/PPPP1PPP/RNBQKBNR b - - 0 1"); var solver = new ChessSolver(2); while (true) { Extentions.Print(Extentions.ChessToAscii(chess)); Console.WriteLine(solver.EvaluatePosition(chess)); if (HasMateOrStaleMate(chess)) { break; } string bestMove; if (chess.MoveColor == Color.white) { do { bestMove = Console.ReadLine(); } while (bestMove.Trim() == string.Empty); } else { bestMove = solver.FindBestMove(chess, 3); } Console.WriteLine("BestMove = " + bestMove); chess = chess.Move(bestMove); Console.WriteLine(chess.fen); } Console.ReadKey(); }