WIP: report part 3

This commit is contained in:
2020-10-26 23:27:22 +02:00
parent 70ae98f31a
commit ebced2aa74
6 changed files with 123 additions and 43 deletions
+16 -7
View File
@@ -134,6 +134,12 @@ class Board {
/**
* Predicate to check if a direction is Walkable.
*
* A `walkable` direction is a tile direction where:
* <ul>
* <li>The wall is not the DOWN wall from tile (0, 0).
* <li>There is not already a wall in the desired direction. (Implies no sentinel tile).
* </ul>
*
* @param tileId The starting tileId.
* @param direction The desired direction.
@@ -147,6 +153,12 @@ class Board {
/**
* Predicate to check if a direction is Walkable.
*
* A `walkable` direction is a tile direction where:
* <ul>
* <li>The wall is not the DOWN wall from tile (0, 0).
* <li>There is not already a wall in the desired direction. (Implies no sentinel tile).
* </ul>
*
* @param row Row position of the starting tile.
* @param col Column position of the starting tile.
* @param direction The desired direction.
@@ -296,13 +308,12 @@ class Board {
* @param direction The wall's relative direction.
* @return True if the wall creates a closed room, false otherwise.
*/
private boolean makesClosedRoom (int tileId, int direction) {
private boolean isRoomCreator (int tileId, int direction) {
// Clone the list of all the walls locally.
ArrayList<Edge> w = new ArrayList<Edge>();
for (Edge it : walls)
w.add(new Edge(it));
// Create a graph from the current wall(edge)
// and populate the graph with all the edges we can attach.
// Create the largest possible coherent graph from the list of walls(edges)
Graph g = new Graph(new Edge(tileId, direction));
int size;
do {
@@ -344,9 +355,7 @@ class Board {
*/
private boolean isWallableDir (int tileId, int direction) {
// Check list
if (tileId == 0 && direction == Direction.DOWN)
return false;
if (tiles[tileId].hasWall(direction))
if (!isWalkable(tileId, direction))
return false;
switch (direction) {
case Direction.UP:
@@ -362,7 +371,7 @@ class Board {
if (tiles[rightTileId.apply(tileId)].hasWalls() >= Const.maxTileWalls) return false;
break;
}
if (Session.loopGuard && makesClosedRoom(tileId, direction))
if (Session.loopGuard && isRoomCreator(tileId, direction))
return false;
return true;
}