Exemple #1
0
        protected AbstractBoard.Player opponentPiece; // the opponents piece

        public Node(AbstractBoard b, Node parent, Space move)
        {
            this.board = b.Clone();
            this.parent = parent;
            this.move = move;
            if (parent != null)
               

          
            myPiece = AbstractBoard.GetOponentPiece(parent.myPiece);
            children = new List<Node>();
        }
Exemple #2
0
        private void button_click(object sender, EventArgs e)
        {
            Space s = (Space)sender;

            gb[s.X, s.Y] = AbstractBoard.Player.O;
            LoadBoard();
            if (CheckForWinners())
                mediumBoard_Load(null, new EventArgs());  //Winner was found, reload the game

            if (gb.OpenSquares.Count == gb.Size) //if all spaces are open, randomly pick one for excitement
            {
                Random r = new Random();
                s = new Space(r.Next(0, 4), r.Next(0, 4));
            }
            else
                s = MiniMax.GetBestMove(gb, AbstractBoard.Player.X);

            gb[s.X, s.Y] = AbstractBoard.Player.X;
            LoadBoard();
            if (CheckForWinners())
                mediumBoard_Load(null, new EventArgs());  //Winner was found, reload the game

        }