Labyrinth
A labyrinth game assignment
|
Go to the documentation of this file.
12 package host.labyrinth;
14 import java.util.ArrayList;
15 import java.util.Collections;
24 static final int EOR =-1;
41 static final int UP =1;
68 static final int End =8;
89 this.
id =
toID(row, col);
133 static int toID(
int row,
int col) {
171 numbers =
new ArrayList<Integer>();
172 init (begin, end, 1);
180 Range(
int begin,
int end,
int step) {
181 numbers =
new ArrayList<Integer>();
182 init (begin, end, step);
188 private void init (
int begin,
int end,
int step) {
190 for (
int i=begin ; i<end ; i+=step)
231 super(begin, end, step);
274 Edge(
int tileId,
int direction) {
337 E =
new ArrayList<Graph>();
345 E =
new ArrayList<Graph>();
352 ArrayList<Graph>
getE() {
return E; }
417 private ArrayList<Graph>
E;
static final int Step
Step for iterator style direction.
static int toCol(int id)
Takes Id coordinate and return the corresponding column coordinate.
static final int LEFT
West direction.
Class to hold constant values for entire application.
Edge(int tileId, int direction)
This constructor acts as the interface between the application's wall representation and the one base...
static int maxRounds
Default number of rounds per game (if no one set it via command line)
int id
The id coordinate of the constructed Position object.
ShuffledRange(int begin, int end, int step)
Create a shuffled version of the range [begin, end) using step as interval between items.
int tryAttach(Edge e, int count)
Recursive algorithm that tries to attach an edge into a graph IFF the graph already has a vertex with...
int V
The value of the current vertex/node.
int getRow()
Read access to virtual row coordinate.
int getV2()
Access of the second node of the edge.
Class to create shuffled ranges of numbers.
ArrayList< Graph > E
A list of all the child nodes.
int getV1()
Access of the first node of the edge.
int tryCount(int v, int count)
Recursive algorithm that tries to count the number of vertices on the graph with the same value as v.
Application wide object to hold settings like values for the session.
boolean attach(Edge e)
Attach an edge into a graph IFF the graph already has a vertex with the same value as one of the vert...
static final int DOWN
South direction.
Edge(Edge e)
A deep copy contructor.
static final int RIGHT
East direction.
Position(int row, int col, int direction)
Constructor from row-column coordinates and a direction.
int v1
First vertex of the edge.
int count(int v)
Counts the number of vertices on the graph with the value of v
ArrayList< Integer > numbers
handle to range
Position(int row, int col)
Basic constructor from row-column coordinates.
Range(int begin, int end)
Create the range [begin, end)
static final int UP
North direction.
static int boardSize
Default board's size (if no one set it via command line)
static int toRow(int id)
Takes Id coordinate and return the corresponding row coordinate.
An Application wide board position implementation holding just the id coordinate.
Helper C++ like enumerator class for direction ranged loops.
ArrayList< Graph > getE()
Access to the links of the current vertex.
Graph(Edge e)
Constructor that transform an edge into graph.
void init(int begin, int end, int step)
Common utility to create the range for all constructors.
Position(int tileId)
Basic constructor from Id.
A utility class used for room prevent algorithm.
static final int Begin
Iterator style begin of range direction (starting north)
static final int End
Iterator style end of range direction (one place after the last)
int v2
Second vertex of the edge.
Range(int begin, int end, int step)
Create the range [begin, end) using step as interval between items.
Helper C++-like enumerator class to hold direction.
static final int noTileId
Number to indicate wrong tileId.
int getCol()
Read access to virtual column coordinate.
Class to create ranges of numbers.
static int supplySize
Default board's supply size (if no one set it via command line)
static final int noSupply
Number to indicate the absent of supply.
static int opposite(int direction)
Utility to get the opposite direction.
int getId()
Read access to id coordinate.
static final int EOR
Number to indicate the End Of Range.
Provides a graph functionality for the room preventing algorithm.
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.
static final int maxTileWalls
Number of maximum walls for each tile on the board.
int getV()
Access to the current vertex.
ShuffledRange(int begin, int end)
Create a shuffled version of range [begin, end)
static boolean interactive
When true each round of the game requires user input.
Graph(int v)
Constructs a node of the graph using the value of a vertex(node).