2026-01-14 11:23:18 +01:00
|
|
|
package fr.iut_fbleau.HexGame;
|
|
|
|
|
|
|
|
|
|
import fr.iut_fbleau.GameAPI.*;
|
|
|
|
|
import java.util.EnumMap;
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Lancement d'une partie de Hex en console.
|
|
|
|
|
*/
|
|
|
|
|
public class HexMain {
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
int size = 7;
|
|
|
|
|
if (args.length >= 1) {
|
|
|
|
|
try { size = Integer.parseInt(args[0]); } catch (NumberFormatException ignored) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HexBoard board = new HexBoard(size);
|
|
|
|
|
|
|
|
|
|
Scanner sc = new Scanner(System.in);
|
2026-01-21 17:20:06 +01:00
|
|
|
Result res;
|
2026-01-14 11:23:18 +01:00
|
|
|
EnumMap<Player, AbstractGamePlayer> players = new EnumMap<>(Player.class);
|
|
|
|
|
players.put(Player.PLAYER1, new HumanConsolePlayer(Player.PLAYER1, sc));
|
|
|
|
|
players.put(Player.PLAYER2, new HumanConsolePlayer(Player.PLAYER2, sc));
|
|
|
|
|
|
2026-01-21 17:20:06 +01:00
|
|
|
|
|
|
|
|
if (args.length>=2 && args[1].equals("autoplay")) {
|
|
|
|
|
Simulation sim = new Simulation(board, players);
|
|
|
|
|
res = sim.run();
|
|
|
|
|
} else {
|
|
|
|
|
AbstractGame game = new AbstractGame(board, players) {};
|
|
|
|
|
res = game.run();
|
|
|
|
|
}
|
2026-01-14 11:23:18 +01:00
|
|
|
|
|
|
|
|
System.out.println(board);
|
|
|
|
|
System.out.println("Résultat (du point de vue de PLAYER1) : " + res);
|
|
|
|
|
|
|
|
|
|
sc.close();
|
|
|
|
|
}
|
|
|
|
|
}
|