/// <summary> /// Perform the CPU's Move /// </summary> /// <param name="random">Make a random move?</param> private void makeCPUsMove(int OsRow, int OsCol, bool random = false) { int row = 0, col = 0; // If to make a random move if (random) { Random rand = new Random(); row = rand.Next(0, 4); col = rand.Next(0, 5); // pictureBox_click(Controls["pic" + row.ToString() + col.ToString()], new EventArgs()); } // Else make a move based on Alpha-Beta Search else { GameTreeNode gtn = new GameTreeNode(gameBoard, OsRow, OsCol); gtn.NextTurn = (State)Turn; SearchTree gt = new SearchTree(); gtn.Text = "Root"; GameTreeNode newMove; if (gt.insertNode(gtn)) { newMove = gt.immResult; } else { newMove = gt.getNextBestMove(); //gt.ShowDialog(); } row = newMove.Row; col = newMove.Column; } // Perform a click operation at on the PictureBox pictureBox_click(Controls["pic" + row.ToString() + col.ToString()], new EventArgs()); }
/// <summary> /// Perform the CPU's Move /// </summary> /// <param name="random">Make a random move?</param> private void makeCPUsMove(int OsRow, int OsCol, bool random = false) { int row = 0, col = 0; // If to make a random move if (random) { Random rand = new Random(); row = rand.Next(0, 4); col = rand.Next(0, 5); // pictureBox_click(Controls["pic" + row.ToString() + col.ToString()], new EventArgs()); } // Else make a move based on Alpha-Beta Search else { GameTreeNode gtn = new GameTreeNode(gameBoard, OsRow, OsCol); gtn.NextTurn = (State)Turn; SearchTree gt = new SearchTree(); gtn.Text = "Root"; GameTreeNode newMove; if (gt.insertNode(gtn)) newMove = gt.immResult; else { newMove = gt.getNextBestMove(); //gt.ShowDialog(); } row = newMove.Row; col = newMove.Column; } // Perform a click operation at on the PictureBox pictureBox_click(Controls["pic" + row.ToString() + col.ToString()], new EventArgs()); }