12 package host.labyrinth;
14 import java.util.ArrayList;
15 import java.util.Collections;
27 static final int EOR =-1;
29 static final int noView = viewDistance+1;
44 static int boardSize = 15;
45 static int supplySize = 4;
46 static int maxRounds = 100;
47 static boolean loopGuard =
false;
48 static boolean interactive =
false;
64 static final int Begin =1;
65 static final int End =8;
66 static final int Step =2;
67 static final int numOfDirections =4;
74 static final int UP =1;
75 static final int RIGHT =3;
76 static final int DOWN =5;
77 static final int LEFT =7;
78 static final int NONE =8;
86 return (direction != NONE) ? (direction+4)%
DirRange.
End : NONE;
89 static int get (
int fromId,
int toId) {
120 this.
id = toID(row, col);
142 case Direction.
UP: this.
id = toID(row+1, col);
break;
165 static int toID(
int row,
int col) {
203 numbers =
new ArrayList<Integer>();
204 init (begin, end, 1);
212 Range(
int begin,
int end,
int step) {
213 numbers =
new ArrayList<Integer>();
214 init (begin, end, step);
220 private void init (
int begin,
int end,
int step) {
222 for (
int i=begin ; i<end ; i+=step)
230 if (!numbers.isEmpty())
231 return numbers.remove(0);
239 return numbers.size();
259 Collections.shuffle(numbers);
270 super(begin, end, step);
271 Collections.shuffle(numbers);
313 Edge(
int tileId,
int direction) {
376 E =
new ArrayList<Graph>();
384 E =
new ArrayList<Graph>();
391 ArrayList<Graph>
getE() {
return E; }
402 return tryAttach(e, 0) > 0;
411 return tryCount (v, 0);
427 count = n.tryAttach (e, count);
428 if (V == e.
getV1()) {
432 if (V == e.
getV2()) {
449 count = n.tryCount (v, count);
456 private ArrayList<Graph>
E;
static final int RIGHT
East direction.
Class to hold constant values for entire application.
static final double preMoveFactor
pre move distances factor
int getV1()
Access of the first node of the edge.
Helper C++-like enumerator class to hold direction.
Position(int tileId)
Basic constructor from Id.
static final int End
Iterator style end of range direction (one place after the last)
int id
The id coordinate of the constructed Position object.
Graph(int v)
Constructs a node of the graph using the value of a vertex(node).
static final int minimaxTreeDepth
The maximum depth of the minimax tree.
ArrayList< Graph > E
A list of all the child nodes.
void init(int begin, int end, int step)
Common utility to create the range for all constructors.
int getV2()
Access of the second node of the edge.
Range(int begin, int end, int step)
Create the range [begin, end) using step as interval between items.
int v2
Second vertex of the edge.
ShuffledRange(int begin, int end)
Create a shuffled version of range [begin, end)
static final int numOfPlayers
Edge(int tileId, int direction)
This constructor acts as the interface between the application's wall representation and the one base...
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...
static final double postMoveFactor
post move distances factor
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...
static final double opponentFactor
Parameters to control move evaluation.
static final double supplyFactor
supply distance factor
Provides a graph functionality for the room preventing algorithm.
Helper C++ like enumerator class for direction ranged loops.
int getId()
Read access to id coordinate.
Position(int row, int col)
Basic constructor from row-column coordinates.
static final int viewDistance
The max distance of the Heuristic player's ability to see.
int V
The value of the current vertex/node.
int getRow()
Read access to virtual row coordinate.
int getCol()
Read access to virtual column coordinate.
ArrayList< Graph > getE()
Access to the links of the current vertex.
static int toRow(int id)
Takes Id coordinate and return the corresponding row coordinate.
Edge(Edge e)
A deep copy contructor.
static final int EOR
Number to indicate the End Of Range.
Graph(Edge e)
Constructor that transform an edge into graph.
static int toCol(int id)
Takes Id coordinate and return the corresponding column coordinate.
Position(int row, int col, int direction)
Constructor from row-column coordinates and a direction.
An Application wide board position implementation holding just the id coordinate. ...
static final int maxTileWalls
Number of maximum walls for each tile on the board.
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...
int v1
First vertex of the edge.
int getV()
Access to the current vertex.
static final int NONE
No direction.
static final int noSupply
Number to indicate the absent of supply.
static int toID(int row, int col)
Takes row and column coordinates and return the calculated Id coordinate.
Application wide object to hold settings like values for the session.
Class to create ranges of numbers.
ArrayList< Integer > numbers
handle to range
static int boardSize
Default board's size (if no one set it via command line)
static final int LEFT
West direction.
static final int noTileId
Number to indicate wrong tileId.
A utility class used for room prevent algorithm.
int count(int v)
Counts the number of vertices on the graph with the value of v
static final int UP
North direction.
static final int noOpponent
Number to indicate the absent of supply.
static int opposite(int direction)
Utility to get the opposite direction.
static final int DOWN
South direction.
Range(int begin, int end)
Create the range [begin, end)
ShuffledRange(int begin, int end, int step)
Create a shuffled version of the range [begin, end) using step as interval between items...
Class to create shuffled ranges of numbers.