Algo Victoire + Console Player + Main + Javadoc

This commit is contained in:
2026-01-14 11:23:18 +01:00
parent d8ea5cd958
commit 22891ae2b6
15 changed files with 280 additions and 54 deletions

View File

@@ -0,0 +1,34 @@
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);
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));
AbstractGame game = new AbstractGame(board, players) {};
Result res = game.run();
System.out.println(board);
System.out.println("Résultat (du point de vue de PLAYER1) : " + res);
sc.close();
}
}