private void updater_Tick(object sender, EventArgs e) { // this means draw, stop AI if (moves_taken == 25) { LockButtons(true); AiEnabled = false; CheckBox_AI.IsChecked = false; debug.Content = "Draw"; } if (Player) { Label_Player.Content = "Playing: O"; Player_char = 'O'; if (AiEnabled) { // Just in case something goes wrong try { Button button = (Button)FindName(mAI.MakeMove(moves)); button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } catch (Exception) { } } } else { Label_Player.Content = "Playing: X"; Player_char = 'X'; } Label_Move.Content = "Move: " + moves_taken; }