Ejemplo n.º 1
0
        private void ExecuteVsGnugo(object obj)
        {
            VsGnugo vsgnugo = new VsGnugo();

            OnExit += vsgnugo.Exit;
            vsgnugo.OnMsgOutput += Vsgnugo_OnMsgOutput;
            vsgnugo.Start();

            ClientLog.FilePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "让八子" + testCount + "~ZenVsGnugo.sgf";
            DllImport.ClearBoard();
            DllImport.FixedHandicap(9);
            DllImport.SetNumberOfSimulations(5000);
            moveCount = 0;
            ClientLog.WriteLog("(;AB[pd][dd][pp][jj][dj][pj][jp][jd][dp]BP[gnugo]WP[Zen]");//9
            //ClientLog.WriteLog("(;AB[pd][dd][pp][dj][pj][jp][jd][dp]BP[gnugo]WP[Zen]");//8
            //new Thread(() =>
            // {
            //     Thread.Sleep(2000);
            //     vsgnugo.GenMove(2);
            // }).Start();

            new Thread(() =>
            {
                int nextColor = DllImport.GetNextColor();
                DllImport.StartThinking(nextColor);
                Thread.Sleep(5000);
                DllImport.StopThinking();

                int p0  = 0, p1 = 0;
                bool p2 = false, p3 = false;
                DllImport.ReadGeneratedMove(ref p0, ref p1, ref p2, ref p3);


                DllImport.Play(p0, p1, nextColor);
                moveCount++;
                string msg = string.Format(moveCount + "\tZen:\t{0}", "" + (char)('A' + p0) + (p1 + 1));
                Console.WriteLine(msg);//WriteMsgLine(msg);
                ClientLog.WriteLog(";" + (nextColor == 1 ? "W" : "B") + "[" + (char)('a' + p0) + (char)('a' + p1) + "]");

                //nextColor = DllImport.GetNextColor();
                char gnuX = (char)('A' + p0);
                if (gnuX > 'H')
                {
                    gnuX++;
                }
                vsgnugo.InputMove(nextColor, "" + gnuX + (p1 + 1));
            }).Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Zen走棋(线程)
        /// </summary>
        /// <param name="stepNum"></param>
        public void GetZenMove(int stepNum)
        {
            Task task = Task.Factory.StartNew(() =>
            {
                int turn = stepNum % 4;
                DllImport.SetNumberOfSimulations(aiSettings[turn].Layout);
                DllImport.StartThinking(aiSettings[turn].Color);
                Thread.Sleep(aiSettings[turn].TimePerMove * 1000);
                DllImport.StopThinking();
                //Thread.Sleep(500);
                int x       = 0, y = 0;
                bool isPass = false, isResign = false;
                DllImport.ReadGeneratedMove(ref x, ref y, ref isPass, ref isResign);
                int count     = 0;
                float winRate = 0;
                DllImport.GetTopMoveInfo(0, ref x, ref y, ref count, ref winRate, null, 0);


                DealZenResult(stepNum, x, y, isPass, isResign, count, winRate);
            });
        }