import java.io.*; class Game31 { private static GameEngine game = new GameEngine(); private static Player[] p = new Player[2]; //this must be a two player game private static int gamesToPlay = 100000, interval = 10000; private static BufferedReader bf; private static boolean watch = false; public static Player loadPlayer() throws IOException { System.out.println("Players: Human/rL/Random/Ender/Notrace"); char pChoice = bf.readLine().charAt(0); if (pChoice == 'h') return new Human(); if (pChoice == 'l') return new RL(); if (pChoice == 'r') return new Random(); if (pChoice == 'e') return new Ender(); if (pChoice == 'n') return new Notrace(); return null; } public static void playGame() { if (p[0] == null) { System.out.println("Player A has not been selected"); return; } if (p[1] == null) { System.out.println("Player B has not been selected"); return; } if (watch) game.playWatchedGame( p ); else { // System.out.println("Enter number of games to play:"); // gamesToPlay = Stdin.getInt(); for (int i = 0; i < gamesToPlay; i++) { if (i % interval == 0) System.out.println("A won: "+p[0].gamesWon()+" B won: "+p[1].gamesWon()); game.playGame(p); } System.out.println("**FINAL RESULTS** A won: "+p[0].gamesWon()+ " B won: "+p[1].gamesWon()); } } public static void main (String[] junk) throws IOException { System.out.println("Game of 31"); bf = new BufferedReader(new InputStreamReader(System.in)); char chx; // boolean watch = false; // GameEngine game = new GameEngine(); //Player[] p = new Player[2]; //int gamesToPlay = 1, interval = 50000; p[0] = new Random(); p[1] = new Random(); do { // System.out.println("Menu: select player A|select player B|Play|toggle Watch|eXit"); System.out.print("a) select player A\nb) select player B\np) play\n"+ "w) toggle watch("+watch+")\ng) set games to play("+gamesToPlay+")\n"+ "r) reset scores\nx) exit\n"); chx = bf.readLine().charAt(0); if (chx == 'a' || chx == 'b') p[chx-'a'] = loadPlayer(); if (chx == 'p') playGame(); if (chx == 'r') { p[0].reset(); p[1].reset(); } if (chx == 'g') { System.out.println("Enter number of games to play:"); gamesToPlay = Integer.parseInt(bf.readLine()); } /* { if (p[0 if (watch) game.PlayWatchedGame( p ); else { System.out.println("Enter number of games to play:"); gamesToPlay = Stdin.getInt(); for (int i = 0; i < gamesToPlay; i++) { if (i % interval == 0) System.out.println("A won: "+p[0].gamesWon()+"B won: "+p[1].gamesWon()); game.PlayGame(p); } } }*/ if (chx == 'w') watch = !watch; } while (chx != 'x'); } }