Files
BUT3ProjetJeuGroupe/javaAPI/fr/iut_fbleau/HexGame/HexMain.java

41 lines
1.2 KiB
Java
Raw Normal View History

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);
Result res;
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));
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();
}
System.out.println(board);
System.out.println("Résultat (du point de vue de PLAYER1) : " + res);
sc.close();
}
}