Browse Source

DEV: Comment rework

tags/v1.0b1
parent
commit
b1c59453c1
2 changed files with 11 additions and 10 deletions
  1. +10
    -9
      src/net/hoo2/auth/labyrinth/Board.java
  2. +1
    -1
      src/net/hoo2/auth/labyrinth/Game.java

+ 10
- 9
src/net/hoo2/auth/labyrinth/Board.java View File

@@ -270,14 +270,15 @@ class Board {
* Predicate to check if a wall creates a closed room. * Predicate to check if a wall creates a closed room.
* *
* This algorithm has a complexity of O(N^2) where N represents the total * This algorithm has a complexity of O(N^2) where N represents the total
* number of tiles it should be used with care.
* number of tiles.
* It should be used with care.
* *
* @param tileId The tileId of the wall where the wall is. * @param tileId The tileId of the wall where the wall is.
* @param direction The wall's relative direction from the tile. * @param direction The wall's relative direction from the tile.
* @return True if the wall creates a closed room, false otherwise. * @return True if the wall creates a closed room, false otherwise.
*/ */
private boolean createsClosedRoom (int tileId, int direction) {
// Get a snapshot of the current walls
private boolean makesClosedRoom (int tileId, int direction) {
// Get a snapshot list of all the walls (all the walls on the board)
ArrayList<Edge> w = new ArrayList<Edge>(); ArrayList<Edge> w = new ArrayList<Edge>();
for (Edge it : walls) for (Edge it : walls)
w.add(new Edge(it)); w.add(new Edge(it));
@@ -286,13 +287,13 @@ class Board {
Graph g = new Graph(new Edge(tileId, direction)); Graph g = new Graph(new Edge(tileId, direction));
int size; int size;
do { do {
size = w.size();
size = w.size(); // mark the size (before the pass)
for (int i =0, S=w.size() ; i<S ; ++i) for (int i =0, S=w.size() ; i<S ; ++i)
if (g.attach(w.get(i))) {
w.remove(i);
--i; --S;
if (g.attach(w.get(i))) { // Can we attach the edge(wall) to the graph ?
w.remove(i); // If yes remove it from the wall list
--i; --S; // decrease iterator and size to match ArrayList's new values
} }
} while (size != w.size());
} while (size != w.size()); // If the size hasn't change(no new graph leafs) exit


// Search if a vertex is attached more than once. // Search if a vertex is attached more than once.
// This means that there is at least 2 links to the same node // This means that there is at least 2 links to the same node
@@ -342,7 +343,7 @@ class Board {
if (tiles[rightTileId.apply(tileId)].hasWalls() >= Const.maxTileWalls) return false; if (tiles[rightTileId.apply(tileId)].hasWalls() >= Const.maxTileWalls) return false;
break; break;
} }
if (Session.loopGuard && createsClosedRoom(tileId, direction))
if (Session.loopGuard && makesClosedRoom(tileId, direction))
return false; return false;
return true; return true;
} }


+ 1
- 1
src/net/hoo2/auth/labyrinth/Game.java View File

@@ -83,7 +83,7 @@ public class Game {
case "--norooms": case "--norooms":
Session.loopGuard = true; Session.loopGuard = true;
break; break;
case "-i": case "-i":
case "--interactive": case "--interactive":
Session.interactive = true; Session.interactive = true;


Loading…
Cancel
Save