예제 #1
0
        void computerWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MCTS tempMCTS = (MCTS)e.Argument;

            e.Result       = tempMCTS.getNextMove(moveTime, secondsForMove);
            nodesGenerated = tempMCTS.currentNodeNumber;
        }
예제 #2
0
        void tempBtn_Click(object sender, RoutedEventArgs e)
        {
            btnPass.Focus();

            if (!(playerPass))
            {
                if (gameStarted)
                {
                    if (((Button)sender).Background == Brushes.BurlyWood)
                    {
                        tempString = ((Button)sender).Name.Split(new Char[] { '_' });


                        if (currentTurn == 1)
                        {
                            ((Button)sender).Background = Brushes.White;
                            boardConfiguration[Convert.ToInt16(tempString[1]), Convert.ToInt16(tempString[2])] = currentTurn;

                            //UPDATE BOARD AFTER CAPTURE
                            boardConfiguration = boardOps.captureCoins(boardConfiguration, currentTurn);

                            //UPDATE STATS
                            lblTime.Content     = "LAST MOVE TIME : " + moveTime.Elapsed.Seconds + " SEC.";
                            lblLastMove.Content = "LAST MOVE : " + tempString[1] + "," + tempString[2];

                            tempCuts = boardOps.returnCuts();

                            //UPDATE GUI
                            if (tempCuts != null)
                            {
                                for (int loopCount = 0; loopCount < tempCuts.Count; loopCount++)
                                {
                                    ((Button)tilesDictionary[tempCuts[loopCount].X + "_" + tempCuts[loopCount].Y]).Background = Brushes.BurlyWood;
                                }
                            }

                            //CHANGE TURN
                            lblTurn.Content = "CURRENT TURN : COMPUTER (THINKING...)";
                            currentTurn     = 2;

                            //COMPUTER PLAYS
                            MCTS computerPlay = new MCTS(boardSize, boardConfiguration);
                            computerWorker.RunWorkerAsync(computerPlay);
                        }
                    }
                }
            }
            else
            {
                //CHANGE TURN
                lblTurn.Content = "CURRENT TURN : COMPUTER (THINKING...)";
                currentTurn     = 2;

                //COMPUTER PLAYS
                MCTS computerPlay = new MCTS(boardSize, boardConfiguration);
                computerWorker.RunWorkerAsync(computerPlay);
            }
        }