37 package host.labyrinth;
39 import java.util.Scanner;
49 scan =
new Scanner(System.in);
65 System.out.println(
"Press enter to continue...");
92 for (
int i =0 ; i<args.length ; ++i) {
96 if (i+1 < args.length)
102 if (i+1 < args.length)
108 if (i+1 < args.length)
117 case "--interactive":
124 System.out.println(
"Labyrinth Game");
125 System.out.println(
"");
126 System.out.println(
"Usage:");
127 System.out.println(
"labyrinth [-b|--board <Num>] [-s|--supplies <Num>] [-r|--rounds <Num>] [--norooms] [-i|--interactive]");
128 System.out.println(
"or");
129 System.out.println(
"labyrinth -h|--help");
130 System.out.println(
"\nOptions\n");
131 System.out.println(
"-b | --board:\n Sets the size of board's edge.\n");
132 System.out.println(
"-s | --supplies:\n Sets the number of supplies on the board.\n");
133 System.out.println(
"-r | --rounds:\n Sets the maximum number of rounds of the game.\n");
134 System.out.println(
"--norooms:\n Prevents the creation of closed rooms inside the board.\n");
135 System.out.println(
"-i | --interactive:\n Each round requires user input in order to continue.\n");
136 System.out.println(
"-h | --help:\n Print this and exits.");
147 public static void main(String[] args) {
162 System.out.println(
"Initial board: " + (game.
round()));
170 System.out.println();
171 System.out.println(
"State after round: " + (game.
round()+1));
175 System.out.println(T.
getName() +
":\t tileId =" + m[0] +
" (" + m[1] +
", " + m[2] +
")");
177 System.out.println(M.
getName() +
":\t tileId =" + m[0] +
" (" + m[1] +
", " + m[2] +
")");
192 System.out.println(
"New day has come... Tie!!!");
198 catch (Exception e) {
200 System.out.println(e.getMessage());
void createBoard(int theseusTile, int minotaurTile)
Creates the board with all the requested walls and supplies.
static void main(String[] args)
Main game loop.
This class is the representation of the games's board.
int round()
Utility to get current round of the game.
int playerTileId()
Utility to access player's tileID.
String [][] getStringRepresentation(int theseusTile, int minotaurTile)
Returns a 2-D array with the string representation of the board.
static int supplySize
Default board's supply size (if no one set it via command line)
This class represents the game's player.
int [] move(int id)
Player's move.
int nextRound()
Utility to increase and get the increased round of the game.
static boolean getArguments(String[] args)
Command line argument handler.
static boolean interactive
When true each round of the game requires user input.
Scanner scan
Input handle used in interactive mode.
An Application wide board position implementation holding just the id coordinate. ...
static boolean loopGuard
When true a wall creation guard is added to prevent closed rooms inside the board.
static int toID(int row, int col)
Takes row and column coordinates and return the calculated Id coordinate.
Game()
< An empty constructor
Application wide object to hold settings like values for the session.
static int boardSize
Default board's size (if no one set it via command line)
static int maxRounds
Default number of rounds per game (if no one set it via command line)
int round
Holds the round of the game.
void printBoard(String[][] sBoard)
Print board utility.
void waitUser()
Utility to hold the execution of the program waiting for user input.