legitbugfix #19

Open
Alistair VAISSE wants to merge 10 commits from legitbugfix into master
3 changed files with 16 additions and 3 deletions
Showing only changes of commit c278b18872 - Show all commits

View File

@@ -0,0 +1,7 @@
Bot 1, Bot 2, Winner
RandomBot,MiniMaxBot,WIN
RandomBot,HeuristicBot,WIN
RandomBot,MonteCarloBot,WIN
MiniMaxBot,HeuristicBot,WIN
MiniMaxBot,MonteCarloBot,WIN
HeuristicBot,MonteCarloBot,WIN
1 Bot 1 Bot 2 Winner
1 Bot 1 Bot 2 Winner
2 RandomBot MiniMaxBot WIN
3 RandomBot HeuristicBot WIN
4 RandomBot MonteCarloBot WIN
5 MiniMaxBot HeuristicBot WIN
6 MiniMaxBot MonteCarloBot WIN
7 HeuristicBot MonteCarloBot WIN

View File

@@ -12,11 +12,13 @@ public class Arena {
private List<AbstractGamePlayer> bots = new ArrayList<>(); private List<AbstractGamePlayer> bots = new ArrayList<>();
private FileWriter csvWriter; private FileWriter csvWriter;
private int board_size;
public Arena() { public Arena(int size) {
try { try {
csvWriter = new FileWriter("arena_results.csv"); csvWriter = new FileWriter("arena_results.csv");
csvWriter.append("Bot 1, Bot 2, Winner\n"); csvWriter.append("Bot 1, Bot 2, Winner\n");
this.board_size = size;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -51,7 +53,7 @@ public class Arena {
} }
private Result playMatch(AbstractGamePlayer bot1, AbstractGamePlayer bot2) { private Result playMatch(AbstractGamePlayer bot1, AbstractGamePlayer bot2) {
IBoard board = new HexBoard(11); IBoard board = new HexBoard(this.board_size);
EnumMap<Player, AbstractGamePlayer> players = new EnumMap<>(Player.class); EnumMap<Player, AbstractGamePlayer> players = new EnumMap<>(Player.class);
players.put(Player.PLAYER1, bot1); players.put(Player.PLAYER1, bot1);
players.put(Player.PLAYER2, bot2); players.put(Player.PLAYER2, bot2);

View File

@@ -4,7 +4,11 @@ import fr.iut_fbleau.GameAPI.Player;
public class ArenaMain { public class ArenaMain {
public static void main(String[] args) { public static void main(String[] args) {
Arena arena = new Arena(); int size = 7;
if (args.length >= 1) {
try { size = Integer.parseInt(args[0]); } catch (NumberFormatException ignored) {}
}
Arena arena = new Arena(size);
arena.addBot(new RandomBot(Player.PLAYER1, 12345L)); // Correct constructor usage arena.addBot(new RandomBot(Player.PLAYER1, 12345L)); // Correct constructor usage
arena.addBot(new MiniMaxBot(Player.PLAYER2)); arena.addBot(new MiniMaxBot(Player.PLAYER2));
arena.addBot(new HeuristicBot(Player.PLAYER1)); arena.addBot(new HeuristicBot(Player.PLAYER1));