private void cellClick(object sender, EventArgs e) { if (!humans_turn) { return; } PictureBox p = sender as PictureBox; int tag = (int)p.Tag; if (frontier.Find(f => f.pos == tag).flipped == null) // not a valid move { return; } foreach (var x in frontier) { board[x.pos].BackgroundImage = null; board[x.pos].Refresh(); } game = game.make_move(frontier.Find(f => f.pos == tag)); display_state(); computer_score.Text = game.black.Count.ToString(); your_score.Text = game.white.Count.ToString(); Computer: humans_turn = false; turn.Text = "Computer's turn!"; turn.ForeColor = Color.Maroon; turn.Invalidate(); turn.Update(); computer_move(); display_state(); computer_score.Text = game.black.Count.ToString(); your_score.Text = game.white.Count.ToString(); frontier = game.get_frontier(true); if (frontier == null) { if (game.game_over()) { gameover(); return; } MessageBox.Show("you have no moves"); //you have no moves goto Computer; } foreach (var x in frontier) { board[x.pos].BackgroundImage = Properties.Resources.hint; } humans_turn = true; turn.Text = "Your turn!"; turn.ForeColor = Color.Green; }
private void computer_move() { frontier = game.get_frontier(false); if (frontier == null) { if (game.game_over()) { gameover(); return; } MessageBox.Show("computer has no moves"); // computer has no moves return; } possible_move m = game.ai_make_move((int)ab_depth.Value); board[m.pos].BackgroundImage = Properties.Resources.hint; board[m.pos].Refresh(); System.Threading.Thread.Sleep(100); game = game.make_move(m); display_state(); computer_score.Text = game.black.Count.ToString(); your_score.Text = game.white.Count.ToString(); }