当前位置: 首页>>代码示例>>C#>>正文


C# Position.flip方法代码示例

本文整理汇总了C#中Position.flip方法的典型用法代码示例。如果您正苦于以下问题:C# Position.flip方法的具体用法?C# Position.flip怎么用?C# Position.flip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Position的用法示例。


在下文中一共展示了Position.flip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loop

    /// UCI::loop() waits for a command from stdin, parses it and calls the appropriate
    /// function. Also intercepts EOF from stdin to ensure gracefully exiting if the
    /// GUI dies unexpectedly. When called with some command line arguments, e.g. to
    /// run 'bench', once the command is executed the function returns immediately.
    /// In addition to the UCI ones, also some additional debug commands are supported.
    internal static void loop(string args)
    {
        var pos = new Position(StartFEN, false, ThreadPool.main()); // The root position
        string token = string.Empty;

        do
        {
            try
            {
                string cmd;
                if (args.Length > 0)
                {
                    cmd = args;
                }
                else if (null == (cmd = Console.ReadLine())) // Block here waiting for input
                {
                    cmd = "quit";
                }
                
                var stack = Position.CreateStack(cmd);
                if (stack.Count == 0)
                {
                    continue;
                }

                token = stack.Pop();

                // 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" || (token == "ponderhit") && Search.Signals.stopOnPonderhit)
                {
                    Search.Signals.stop = true;
                    ThreadPool.main().notify_one(); // Could be sleeping
                }
                else if (token == "ponderhit")
                {
                    Search.Limits.ponder = false; // Switch to normal search
                }
                else if (token == "uci")
                {
                    Output.Write("id name ");
                    Output.Write(Utils.engine_info(true));
                    Output.Write("\n");
                    Output.Write(OptionMap.Instance.ToString());
                    Output.WriteLine("\nuciok");
                }
                else if (token == "ucinewgame")
                {
                    Search.reset();
                    TimeManagement.availableNodes = 0;
                }
                else if (token == "isready")
                {
                    Output.WriteLine("readyok");
                }
                else if (token == "go")
                {
                    go(pos, stack);
                }
                else if (token == "position")
                {
                    position(pos, stack);
                }
                else if (token == "setoption")
                {
                    setoption(stack);
                }

                // Additional custom non-UCI commands, useful for debugging
                else if (token == "flip")
                {
                    pos.flip();
                }
                else if (token == "eval")
                {
                    Output.WriteLine(Eval.trace(pos));
                }
                else if (token == "bench")
                {
                    Benchmark.benchmark(pos, stack);
                }
                else if (token == "d")
                {
                    Output.Write(pos.displayString());
                }
                else if (token == "perft")
                {
                    token = stack.Pop(); // Read depth
                    var ss =
                        Position.CreateStack(
                            $"{OptionMap.Instance["Hash"].v} {OptionMap.Instance["Threads"].v} {token} current perft");
                    Benchmark.benchmark(pos, ss);
//.........这里部分代码省略.........
开发者ID:torfranz,项目名称:NetFish,代码行数:101,代码来源:UCI.cs

示例2: flipTest

        public void flipTest()
        {
            Bitboards.init();
            Position.init();

            var fen1 = "r1bbk1nr/pp3p1p/2n5/1N4p1/2Np1B2/8/PPP2PPP/2KR1B1R w kq - 0 13";
            var pos1 = new Position(fen1, false, null);
            pos1.flip();
            Assert.AreEqual("2kr1b1r/ppp2ppp/8/2nP1b2/1n4P1/2N5/PP3P1P/R1BBK1NR b KQ - 0 13", pos1.fen());

            pos1.flip();
            Assert.AreEqual(fen1, pos1.fen());

            var fen2 = "2r3k1/1q1nbppp/r3p3/3pP3/pPpP4/P1Q2N2/2RN1PPP/2R4K b - b3 0 23";
            var pos2 = new Position(fen2, false, null);
            pos2.flip();
            Assert.AreEqual("2r4k/2rn1ppp/p1q2n2/PpPp4/3Pp3/R3P3/1Q1NBPPP/2R3K1 w - b6 0 23", pos2.fen());

            pos2.flip();
            Assert.AreEqual(fen2, pos2.fen());
        }
开发者ID:torfranz,项目名称:NetFish,代码行数:21,代码来源:PositionTests.cs


注:本文中的Position.flip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。