예제 #1
0
 static void loopT(string[] args)
 {
     //do
     {
         GlobalMembersUci.loop(args);
     } ///while (true);
 }
예제 #2
0
    // setoption() is called when engine receives the "setoption" UCI command. The
    // function updates the UCI option ("name") to the given value ("value").
    public static void Output()
    {
        /*ProcessStartInfo si = new ProcessStartInfo()
        {
            FileName = "HybridizerRefrigitz.exe",//"C:\\Program Files (x86)\\Arena\\Arena.exe",
            UseShellExecute = false,
            CreateNoWindow = true,
            RedirectStandardError = true,
            RedirectStandardInput = true,
            RedirectStandardOutput = true
        };

         myProcessO= new Process();
        myProcessO.StartInfo = si;
        try
        {
            // throws an exception on win98
            myProcessO.PriorityClass = ProcessPriorityClass.BelowNormal;
        }
        catch { }

        myProcessO.OutputDataReceived += new DataReceivedEventHandler(myProcess_OutputDataReceived);

        myProcessO.Start();
        myProcessO.BeginErrorReadLine();
        myProcessO.BeginOutputReadLine();*/
        object o = new object();
        lock (o)
        {
            do
            {
                string Is = "";
                if (ThinkingHybridizerRefrigitz.OutP != null && ThinkingHybridizerRefrigitz.OutP != ""
                       )
                {
                    Is = GlobalMembersUci.Next(ref ThinkingHybridizerRefrigitz.OutP);

                    // SendLine(Is);
                    Console.Write//Line
                        (
                        //"[UCI] "+
                        Is + " ");
                }
            } while (true);
        }
    }
예제 #3
0
파일: main.cs 프로젝트: tetrashop/Refrigitz
    /*
     * Stockfish, a UCI chess playing engine derived from Glaurung 2.1
     * Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
     * Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
     *
     * Stockfish is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * Stockfish is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */



    public static void t_main(int argc, string[] argv)
    {
        Console.Write(GlobalMembersMisc.engine_info());
        Console.Write("\n");

        GlobalMembersBitboard.init(GlobalMembersUcioption.Options);
        GlobalMembersBitboard.init();
        Position.init();
        Bitbases.init();
        GlobalMembersBitboard.init();
        GlobalMembersBitboard.init();
        GlobalMembersBitboard.init();
        GlobalMembersThread.Threads.init();
        Tablebases.init(GlobalMembersUcioption.Options["SyzygyPath"]);
        GlobalMembersTt.TT.resize(GlobalMembersUcioption.Options["Hash"]);

        GlobalMembersUci.loop(argc, argv);

        GlobalMembersThread.Threads.exit();
    }
예제 #4
0
    // position() is called when engine receives the "position" UCI command.
    // The function sets up the position described in the given FEN string ("fen")
    // or the starting position ("startpos") and then makes the moves given in the
    // following move list ("moves").

    public static void position(Position pos, istringstream @is)
    {
        Move   m;
        string token;
        string fen;

        @is >> token;

        if (token == "startpos")
        {
            fen = ((char)StartFEN).ToString();
            @is >> token;             // Consume "moves" token if any
        }
        else if (token == "fen")
        {
            while (@is >> token && token != "moves")
            {
                fen += token + " ";
            }
        }
        else
        {
            return;
        }

        pos.set(fen, GlobalMembersUcioption.Options["UCI_Chess960"], GlobalMembersThread.Threads.main());
        #if StateStackPtr_ConditionalDefinition1
        SetupStates = std.auto_ptr <Stack <StateInfo> >(new Stack <StateInfo>());
        #elif StateStackPtr_ConditionalDefinition2
        SetupStates = std.auto_ptr <Stack <StateInfo> >(new Stack <StateInfo>());
        #else
        SetupStates = Search.StateStackPtr(new Stack <StateInfo>());
        #endif

        // Parse move list (if any)
        while (@is >> token && (m = GlobalMembersUci.to_move(pos, token)) != Move.MOVE_NONE)
        {
            SetupStates.push(new StateInfo());
            pos.do_move(m, SetupStates.top());
        }
    }
예제 #5
0
    public static void loop(string[] argv)
    {
        if (tt == null)
        {
            //string IsA = argv[0];
            var tt = new Task(() => GlobalMembersUci.Output());
            tt.Start();
        }
       /* else if (!tt.IsAlive)
        {
            string IsA = argv[0];
            var tt = new Task(() => GlobalMembersUci.Output());
            tt.Start();
        }
        */
        //Position pos;
        string token = "", cmd = "";

        //pos.set(StartFEN, false, &States->back(), Threads.main());

        for (int i = 1; i < argv.Length; ++i)
            cmd += (argv[i]).ToString() + " ";

        do
        {

            if (argv.Length == 1 && cmd == "") // Block here waiting for input or EOF
                cmd = "quit";

            // istringstream is (cmd);

            token = ""; // getline() could return empty or blank line
                        //is >> skipws >> token;
            if (cmd != "quit")
            {

                cmd = Console.ReadLine();
                token = Next(ref cmd);

            }
            // The GUI sends 'ponderhit' to tell us to ponder on the same move the
            // opponent has played. In case Signals.stopOnPonderhit is set we are
            // waiting for 'ponderhit' to stop the search (for instance because we
            // already ran out of time), otherwise we should continue searching but
            // switching from pondering to normal search.
            if (token == "quit"
                || (token == "stop" && HybridizerRefrigitz.AllDraw.CalIdle == 1)
                || (token == "ponderhit" 
                ))
            {
             if((token == "quit"
                || token == "stop")&& HybridizerRefrigitz.AllDraw.CalIdle == 1)
                {
                    HybridizerRefrigitz.AllDraw.CalIdle = 2;
                    while (HybridizerRefrigitz.AllDraw.CalIdle != 5) { }
                    HybridizerRefrigitz.AllDraw.CalIdle=-1; }
                //t.t.Play(-1, -1);//remain fen
                //StartFEN = (new GlobalMembersUci()).Fen();
            }
            else if (token == "ponderhit")
            {
                //HybridizerRefrigitz.AllDraw.CalIdle = 0;



            }
            else if (token == "uci")

            {
                Console.WriteLine("\nid name tetrashop.ir and faradars.org 2020 Hybridizer chess engine.");

                //sync_cout << "id name " << engine_info(true)
                //     << "\n" << Options
                //    << "\nuciok" << sync_endl;

            }
            else if (token == "ucinewgame")


            {
                t.t.Form1_Load();

            }
            else if (token == "isready")
            {
                if (AllDraw.CalIdle == 0)
                    Console.WriteLine("\nreadyok");

                //sync_cout << "readyok" << sync_endl;
            }

            else if (token == "go")
            {
                if (HybridizerRefrigitz.AllDraw.CalIdle != 1)
                {
                    if (HybridizerRefrigitz.AllDraw.CalIdle == 0)
                    {
                        Console.Write("\ngo 0");

                        HybridizerRefrigitz.AllDraw.CalIdle = 2;
                        Console.Write("\ngo 2");
                        while (HybridizerRefrigitz.AllDraw.CalIdle != 1)
                        {
                        }
                        Console.Write("\ngo 1");
                    }
                } //undeterministic blok line location!
                Console.Write("\ngo go");
                go(ref cmd);

                Console.Write("\ngo play");
                AllDraw.OrderPlateDraw = AllDraw.OrderPlate;
                t.t.Play(-1, -1);
                HybridizerRefrigitzForm.Table = t.t.Draw.CloneATable(AllDraw.TableListAction[AllDraw.TableListAction.Count - 2]);
                Console.Write("\ngo finished.");
               // HybridizerRefrigitz.AllDraw.CalIdle = 0;
            }

            else if (token == "position")
            {
                position(ref cmd);
            }

            else if (token == "setoption")
            {

                setoption(ref argv[0]);
            }

            // Additional custom non-UCI commands, useful for debugging
            else if (token == "flip")
            {
                //pos.flip();
            }
            else if (token == "bench")
            {
                //benchmark(pos, is
            }
            else if (token == "d")
            {
                posa();
                //sync_cout << pos << sync_endl;
            }
            else if (token == "eval")
            {
                //sync_cout << Eval::trace(pos) << sync_endl;
            }

            else if (token == "perft")
            {
                int depth;
                //stringstream ss;

                 depth=System.Convert.ToInt32(Console.ReadLine());
                AllDraw.MaxAStarGreedy = depth;
                //ss << Options["Hash"] << " "
                //  << Options["Threads"] << " " << depth << " current perft";

                //  benchmark(pos, ss);
            }
            else
            {
                //sync_cout << "Unknown command: " << cmd << sync_endl;
            }

        } while (token != "quit" && argv.Length == 1); // Passed args have one-shot behaviour

        // Threads.main()->wait_for_search_finished();
    }
예제 #6
0
    // go() is called when engine receives the "go" UCI command. The function sets
    // the thinking time and other parameters from the input string, then starts
    // the search.

    public static void go(Position pos, istringstream @is)
    {
        Search.LimitsType limits = new Search.LimitsType();
        string            token;

        while (@is >> token)
        {
            if (token == "searchmoves")
            {
                while (@is >> token)
                {
                    limits.searchmoves.Add(GlobalMembersUci.to_move(pos, token));
                }
            }

            else if (token == "wtime")
            {
                @is >> limits.time[(int)Color.WHITE];
            }
            else if (token == "btime")
            {
                @is >> limits.time[(int)Color.BLACK];
            }
            else if (token == "winc")
            {
                @is >> limits.inc[(int)Color.WHITE];
            }
            else if (token == "binc")
            {
                @is >> limits.inc[(int)Color.BLACK];
            }
            else if (token == "movestogo")
            {
                @is >> limits.movestogo;
            }
            else if (token == "depth")
            {
                @is >> limits.depth;
            }
            else if (token == "nodes")
            {
                @is >> limits.nodes;
            }
            else if (token == "movetime")
            {
                @is >> limits.movetime;
            }
            else if (token == "mate")
            {
                @is >> limits.mate;
            }
            else if (token == "infinite")
            {
                limits.infinite = true;
            }
            else if (token == "ponder")
            {
                limits.ponder = true;
            }
        }

        GlobalMembersThread.Threads.start_thinking(pos, limits, SetupStates);
    }