Exemplo n.º 1
0
        public void StartLoop()
        {
            Stopwatch s = new Stopwatch();

            s.Start();
            int turn = 0;

            lastSquare = (width * width) / 2;
            while (true)
            {
                DrawBoard(lastSquare);
                if ((blackTurn && blackIsPlayer) || (!blackTurn && whiteIsPlayer))
                {
                    lastSquare = UserSelectSquare();
                }
                else
                {
                    //lastSquare = ai.GetHighestValueMove(this);
                    if (blackTurn)
                    {
                        if (blackBotUsesAlphaBeta)
                        {
                            lastSquare = ai.MultiThreadedRAlphaBeta(this, 4, 8);
                            //lastSquare = ai.RootAlphaBeta(int.MinValue, int.MaxValue, this, 4);
                        }
                        else
                        {
                            lastSquare = ai.MonteCarloSearch(this, blackBotTimer);
                        }
                    }
                    else
                    {
                        if (whiteBotUsesAlphaBeta)
                        {
                            lastSquare = ai.MultiThreadedRAlphaBeta(this, 4, 8);
                            //lastSquare = ai.RootAlphaBeta(int.MinValue, int.MaxValue, this, 4);
                        }
                        else
                        {
                            lastSquare = ai.MonteCarloSearch(this, whiteBotTimer);
                        }
                    }
                }
                if (board[lastSquare] == 0 || board[lastSquare] == 3)
                {
                    ChangeSquare(lastSquare);
                    ai.EvaluateBoard(this);
                    int win = CheckWin(lastSquare);
                    if (win != 0)
                    {
                        DrawBoard(lastSquare);
                        WriteEndText(win);
                        UserPromptEnd();
                    }
                    turn++;

                    /*if(turn == 10){
                     *  s.Stop();
                     *  DebugWrite("Time to simulate 25 turns in miliseconds: " + s.ElapsedMilliseconds);
                     *  UserPromptEnd();
                     * }*/
                    EndTurn();
                }
            }
        }