private void button3_Click(object sender, EventArgs e) { if(!on_game) { return; } if(board.points.Count==0) { return; } Board n = new Board(); if (ai_vs_human) { if(board.points.Count==1) { return; } for(int i=0;i<board.points.Count-2;++i) { n.play(board.points[i]); } } else { for (int i = 0; i < board.points.Count - 1; ++i) { n.play(board.points[i]); } } board = n; Refresh(); }
private void button1_Click(object sender, EventArgs e) { black = comboBox1.Text; white = comboBox2.Text; board = new Board(); if (black != "Human" && white != "Human") { if (black == "RandomAI") { ai = new RandomAI(); } else if (black == "MonteCarloAI") { ai = new MCTAI(); } if (white == "RandomAI") { ai2 = new RandomAI(); } else if (white == "MonteCarloAI") { ai2 = new MCTAI(); } Info.GameState st; while (true) { st = board.play(ai.play(board)); Refresh(); if (st == Info.GameState.END_GAME) { break; } st = board.play(ai2.play(board)); Refresh(); if (st == Info.GameState.END_GAME) { break; } } double black_point = board.stones[0].size(); double white_point = board.stones[1].size() + 6.5; String msg = "Black " + black_point + " White " + white_point; MessageBox.Show(msg); return; } if (black == "RandomAI") { ai = new RandomAI(); } else if (black == "MonteCarloAI") { ai = new MCTAI(); } if (white == "RandomAI") { ai = new RandomAI(); } else if (white == "MonteCarloAI") { ai = new MCTAI(); } if (black != "Human") { ai_vs_human = true; board.play(ai.play(board)); } if (white != "Human") { ai_vs_human = true; } Refresh(); on_game = true; }
public bool onePlayOut(Board board) { Board tmp = new Board(board); Info.GameState s; while(true) { List<Point> l = nextMovePlayOut(tmp); if (l.Count == 0) { s = tmp.play(Point.Pass); if (s == Info.GameState.END_GAME) { return (double)tmp.stones[0].size() > (double)tmp.stones[1].size() + 6.5; } } else { Point p = l[rnd.Next(l.Count)]; tmp.play(p); } } }