예제 #1
0
        public void TestCSimulateOWin()
        {
            UltimateBoard b = Games.GetBoard(Games.OWins, Games.OWins.Length);
            GameTreeNode  t = new GameTreeNode(Games.OWins[Games.OWins.Length - 1]);

            Assert.That(t.Simulate(b), Is.EqualTo(1));
        }
예제 #2
0
        public void TestCSimulateDraw()
        {
            UltimateBoard b = Games.GetBoard(Games.Draw, Games.Draw.Length);
            GameTreeNode  t = new GameTreeNode(Games.Draw[Games.Draw.Length - 1]);

            Assert.That(t.Simulate(b), Is.EqualTo(0.5f));
        }
예제 #3
0
        /// <summary>
        ///  the computers play
        /// </summary>
        private void ComputerPlay()
        {
            DisableAllButtons();
            uxTextBox.Text = "My Turn.";
            Update();

            for (int i = 0; i < 25000; i++)
            {
                UltimateBoard temp = new UltimateBoard(_currentGamePosition);
                _portionOfGameTree.Simulate(temp);
            }

            GameTreeNode t = _portionOfGameTree.GetBestChild();

            (int, int, int, int)p = t.Play;
            _currentGamePosition.Play(p);
            uxFlowLayoutPanel.Controls[p.Item1].Controls[p.Item2].Controls[p.Item3].Controls[p.Item4].Text = _SymbolOComputer;

            if (!GameIsover("I"))
            {
                _portionOfGameTree = t;

                foreach ((int, int, int, int)loc in _currentGamePosition.GetAvailablePlays())
                {
                    uxFlowLayoutPanel.Controls[loc.Item1].Controls[loc.Item2].Controls[loc.Item3].Controls[loc.Item4].Enabled = true;
                }
                uxTextBox.Text = "Your Turn.";
            }
        }