Algo Victoire + Console Player + Main + Javadoc
This commit is contained in:
34
javaAPI/fr/iut_fbleau/HexGame/HexMain.java
Normal file
34
javaAPI/fr/iut_fbleau/HexGame/HexMain.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user