Added simulation method. Implementing #8
This commit is contained in:
parent
1c968e676b
commit
8ed7093d2d
|
@ -69,19 +69,34 @@ public class Game {
|
||||||
this.gameOn = false;
|
this.gameOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Simulates n games.
|
* Simulates n games.
|
||||||
// *
|
* Simulates the games and prints statistical output to stdout.
|
||||||
// * @param runs The number of games to simulate.
|
*
|
||||||
// */
|
* @param runs The number of games to simulate.
|
||||||
// public static void simulate(int runs) {
|
*/
|
||||||
// Player p1 = new MaurizioAI();
|
public static void simulate(int runs) {
|
||||||
// Player p2 = new MalteAI();
|
Player p1 = new MaurizioAI();
|
||||||
// for (int i = 0; i < runs; i++) {
|
Player p2 = new MalteAI();
|
||||||
// Game g = new Game(p1, p2);
|
// 0 - Draw
|
||||||
// g.start
|
// 1 - p1 wins
|
||||||
// }
|
// 2 - p2 wins
|
||||||
// }
|
int[] statistic = new int[3];
|
||||||
|
for (int i = 0; i < runs; i++) {
|
||||||
|
int result = new Game(p1, p2).start(false, true);
|
||||||
|
// TODO: Improve IDs
|
||||||
|
statistic[result]++;
|
||||||
|
}
|
||||||
|
System.out.println("Draws : " + statistic[0]);
|
||||||
|
System.out.println("Maurizio: " + statistic[1] + " wins");
|
||||||
|
System.out.println("Malte : " + statistic[2] + " wins");
|
||||||
|
|
||||||
|
System.out.println("PERCENTAGE:");
|
||||||
|
System.out.println("Draws : " + (statistic[0] / runs * 100.0) + "%");
|
||||||
|
System.out.println("Maurizio: " + (statistic[1] / runs * 100.0) + "% wins");
|
||||||
|
System.out.println("Malte : " + (statistic[2] / runs * 100.0) + "% wins");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a game.
|
* Start a game.
|
||||||
|
|
Loading…
Reference in a new issue