Example #1
0
        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;
        }
Example #2
0
        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);
        }
Example #3
0
        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;
        }
Example #4
0
        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();
        }
Example #5
0
 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);
 }