private void PictureBox0_Click(object sender, EventArgs e) { PictureBox p = sender as PictureBox; if (p.Image != null) { return; } if (turn == PlayerTurn.None) { return; } if (turn == PlayerTurn.Player1) { p.Image = player1.Image; } else { p.Image = player2.Image; } //Check for Winner winner = GetWinner(); if (winner == Winner.None) { //Change Turns turn = (PlayerTurn.Player1 == turn) ? PlayerTurn.Player2 : PlayerTurn.Player1; if (AI.CPU == false) { return; } else { AI.TakeTurn(BoardStatus()); int play = AI.Play; PictureBox[] pictureBoxes = { p0, p1, p2, p3, p4, p5, p6, p7, p8 }; for (int i = 0; i < pictureBoxes.Length; i++) { if (play == i) { pictureBoxes[i].Image = player2.Image; } } } } else { turn = PlayerTurn.None; } ShowTurn(); }