public void UpdateBoard(ref Mancala game) { if (!game.leftTurn && game.aiActive) { int ai_index = game.get_ai_move(Mancala.max_depth, true)[1]; switch (ai_index) { case 7: btnR0.PerformClick(); break; case 8: btnR1.PerformClick(); break; case 9: btnR2.PerformClick(); break; case 10: btnR3.PerformClick(); break; case 11: btnR4.PerformClick(); break; case 12: btnR5.PerformClick(); break; } } if (game.isGameOver()) { game.captureAll(); } for (int i = 0; i < 7; i++) { LeftSide[i].Text = game.board[i].ToString(); RightSide[i].Text = game.board[i + 7].ToString(); } if (!game.gameOver) { lblTurn.Text = game.leftTurn ? "Left" : "Right"; } else { label1.Visible = false; lblTurn.Visible = false; lblGameOver.Visible = true; } }
private void Form1_Load(object sender, EventArgs e) { game = new Mancala(); LeftSide[0] = lblL0; LeftSide[1] = lblL1; LeftSide[2] = lblL2; LeftSide[3] = lblL3; LeftSide[4] = lblL4; LeftSide[5] = lblL5; LeftSide[6] = lblBottomStore; RightSide[0] = lblR0; RightSide[1] = lblR1; RightSide[2] = lblR2; RightSide[3] = lblR3; RightSide[4] = lblR4; RightSide[5] = lblR5; RightSide[6] = lblTopStore; UpdateBoard(ref game); }
public void UpdateBoard(ref Mancala game) { if (game.isGameOver()) { game.captureAll(); } for (int i = 0; i < 7; i++) { LeftSide[i].Text = game.board[i].ToString(); RightSide[i].Text = game.board[i + 7].ToString(); } if (!game.gameOver) { lblTurn.Text = game.leftTurn ? "Left" : "Right"; } else { label1.Visible = false; lblTurn.Visible = false; lblGameOver.Visible = true; } }