private static void DoSearch() { var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; // Starting pos //fen = "2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w - -"; // Mate in 3 fen = "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1"; // Developed fen = "r1b1kb1r/2pp1ppp/1np1q3/p3P3/2P5/1P6/PB1NQPPP/R3KB1R b KQkq - 0 1 "; // Midgame var fact = new BoardFactory(); var board = fact.ParseFEN(fen); var hyperbola = new HyperbolaQuintessence(); var evaluationService = new EvaluationService(); var attacksService = new AttacksService(hyperbola); var movesService = new PossibleMovesService(attacksService, hyperbola); var interruptor = new ConsoleInterruptor(); var searchService = new SearchService(movesService, evaluationService, interruptor); searchService.OnSearchInfo += info => Console.WriteLine(info.ToString()); var sParams = new SearchParams(); //sParams.MaxDepth = 5; sParams.Infinite = true; var move = searchService.Search(board, sParams); }
public Game(IInterruptor interruptor) { var hyperbola = new HyperbolaQuintessence(); var evaluationService = new EvaluationService(); var attacksService = new AttacksService(hyperbola); var movesService = new PossibleMovesService(attacksService, hyperbola); var searchService = new SearchService(movesService, evaluationService, interruptor); BoardFact = new BoardFactory(); Hyperbola = hyperbola; Evaluation = evaluationService; Attacks = attacksService; Moves = movesService; Search = searchService; }
private static void TestRepetitions() { var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; // Starting pos //fen = "2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w - -"; // Mate in 3 fen = "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1"; // Developed var fact = new BoardFactory(); var board = fact.ParseFEN(fen); var hyperbola = new HyperbolaQuintessence(); var evaluationService = new EvaluationService(); var attacksService = new AttacksService(hyperbola); var movesService = new PossibleMovesService(attacksService, hyperbola); var interruptor = new ConsoleInterruptor(); var searchService = new SearchService(movesService, evaluationService, interruptor); Console.WriteLine(searchService.IsRepetition(board)); var move = new Move(1, 18, ChessPiece.WhiteKnight); board = board.DoMove(move); Console.WriteLine(move.ToPositionString() + " " + searchService.IsRepetition(board)); move = new Move(57, 42, ChessPiece.BlackKnight); board = board.DoMove(move); Console.WriteLine(move.ToPositionString() + " " + searchService.IsRepetition(board)); move = new Move(18, 1, ChessPiece.WhiteKnight); board = board.DoMove(move); Console.WriteLine(move.ToPositionString() + " " + searchService.IsRepetition(board)); move = new Move(42, 57, ChessPiece.BlackKnight); board = board.DoMove(move); Console.WriteLine(move.ToPositionString() + " " + searchService.IsRepetition(board)); move = new Move(1, 18, ChessPiece.WhiteKnight); board = board.DoMove(move); Console.WriteLine(move.ToPositionString() + " " + searchService.IsRepetition(board)); move = new Move(57, 40, ChessPiece.BlackKnight); board = board.DoMove(move); Console.WriteLine(move.ToPositionString() + " " + searchService.IsRepetition(board)); }
private static void DoPerft() { var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; //fen = "3k4/3p4/8/K1P4r/8/8/8/8 b - - 0 50"; //fen = "8/1kP5/8/K2p3r/8/8/8/8 w - - 1 53 "; //fen = "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1"; //fen = "2k5/8/8/8/8/8/6p1/2K5 w - - 1 1 "; //fen = "rnbqkbnr/1ppppppp/8/p7/1P6/P7/2PPPPPP/RNBQKBNR b KQkq b3 0 2 "; var fact = new BoardFactory(); var hyperbola = new HyperbolaQuintessence(); var attacksService = new AttacksService(hyperbola); var movesService = new PossibleMovesService(attacksService, hyperbola); var perft = new PerftService(movesService); var results = perft.GetPossibleMoves(fact.ParseFEN(fen), 1); using (var sharperClient = new SharperPerftClient(@"C:\sharper\Sharper.exe", fen)) { var perftRunner = new PerftRunner(perft, sharperClient, fact); perftRunner.OnOut += Console.Write; perftRunner.Test(fen, 6); } }
private static void TestMove() { var fact = new BoardFactory(); var board = fact.ParseFEN("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -"); board.EnPassantFile = Board.Files[3]; var hyperbola = new HyperbolaQuintessence(); var evaluationService = new EvaluationService(); Console.WriteLine(evaluationService.Evaluate(board)); var attacksService = new AttacksService(hyperbola); var movesService = new PossibleMovesService(attacksService, hyperbola); var forWhite = true; var moves = movesService.GetPossibleKingMoves(board).ToList(); var dests = moves.Select(x => x.To); var toMoveBoard = fact.PiecesToBitBoard(dests); var attacked = attacksService.GetAllAttacked(board); var newMove = new Move(4, 2, ChessPiece.WhiteKing); var movedBoard = board.DoMove(newMove); Debugging.ShowBitBoard(movedBoard.BitBoard[ChessPiece.WhiteKing], movedBoard.BitBoard[ChessPiece.WhiteRook]); }