Esempio n. 1
0
        public void BestMove(UciMove bestMove, UciMove ponderMove)
        {
            string text = "bestmove " + bestMove.ToString();

            if (ponderMove != null)
            {
                text += " ponder " + ponderMove.ToString();
            }

            UciCallback(text);
        }
Esempio n. 2
0
        private void Position(string positionText)
        {
            if (String.IsNullOrWhiteSpace(positionText))
            {
                return;
            }

            var kvl = CommandParser.GetElements(positionText, "fen", "startpos", "moves");

            string         fen   = kvl.ContainsKey("fen") ? kvl["fen"] : null;
            List <UciMove> moves = new List <UciMove>();

            if (kvl.ContainsKey("moves"))
            {
                string moveString = kvl["moves"];
                moves = moveString.Split(' ').Select(x => UciMove.FromString(x)).ToList();
            }

            Engine.Position(fen, moves);
        }
Esempio n. 3
0
        private void Go(string goString)
        {
            if (String.IsNullOrWhiteSpace(goString))
            {
                return;
            }

            var kvl = CommandParser.GetElements(goString, "searchmoves", "ponder", "wtime", "btime", "winc", "binc", "movestogo", "depth", "nodes", "mate", "movetime", "infinite");

            var param = new UciGoParameters()
            {
                BlackInc    = kvl.ContainsKey("binc") ? Convert.ToInt64(kvl["binc"]) : new Nullable <Int64>(),
                BlackTime   = kvl.ContainsKey("btime") ? Convert.ToInt64(kvl["btime"]) : new Nullable <Int64>(),
                Depth       = kvl.ContainsKey("depth") ? Convert.ToInt32(kvl["depth"]) : new Nullable <Int32>(),
                Infinite    = kvl.ContainsKey("infinite"),
                Mate        = kvl.ContainsKey("mate") ? Convert.ToInt32(kvl["mate"]) : new Nullable <Int32>(),
                MovesToGo   = kvl.ContainsKey("movestogo") ? Convert.ToInt32(kvl["movestogo"]) : new Nullable <Int32>(),
                MoveTime    = kvl.ContainsKey("movetime") ? Convert.ToInt32(kvl["movetime"]) : new Nullable <Int32>(),
                Nodes       = kvl.ContainsKey("nodes") ? Convert.ToInt32(kvl["nodes"]) : new Nullable <Int32>(),
                Ponder      = kvl.ContainsKey("ponder"),
                SearchMoves = kvl.ContainsKey("searchmoves") ? kvl["searchmoves"].Split(' ').Select(x => UciMove.FromString(x)).ToList() : new List <UciMove>(),
                WhiteInc    = kvl.ContainsKey("winc") ? Convert.ToInt64(kvl["winc"]) : new Nullable <Int64>(),
                WhiteTime   = kvl.ContainsKey("wtime") ? Convert.ToInt64(kvl["wtime"]) : new Nullable <Int64>(),
            };

            Engine.Go(param);
        }