deepest end is really deepest

This commit is contained in:
philippe lhardy
2018-06-13 20:56:12 +02:00
parent 89d6631f67
commit 2d3f7b01a0
4 changed files with 25 additions and 32 deletions

View File

@@ -11,8 +11,8 @@ $(OUT):
# mkdir -p $(OUT)
clean:
@find $(PACKAGE_DIR) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null && echo "cleaned classes in source"
@find $(OUT) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null || echo "nothing to clean"
@find $(PACKAGE_DIR) -name "*.class" -type f -print0|xargs -0 --no-run-if-empty rm 2>/dev/null
@find $(OUT) -name "*.class" -type f -print0|xargs -0 --no-run-if-empty rm 2>/dev/null
test:
echo "$(pwd)/$(PACKAGE_DIR)"

View File

@@ -87,27 +87,6 @@ public class LabyModel implements WallsProvider
MazeCreationListener listener = null;
/**
TODO
private static MyLinkedList<P>
{
MyLinkedList<P> next;
P content
MyLinkedList<P>( P object)
{
content=object;
next=null;
}
MyLinkedList<P> addLast(P object)
{
next = new MyLinkedList(object);
return next;
}
}
*/
public LabyModel(int width, int height, int maxdepth, Random random)
{
this.width = width;
@@ -525,13 +504,16 @@ TODO
}
}
/**
generate a maze with an entry set at (x,y)
**/
public void generateWithEntry(int x, int y)
{
openList.add(new Position(x, y));
while (!openList.isEmpty())
{
step(0); // fixme depth not set
step();
synchronized (coherentLock)
{
@@ -834,10 +816,19 @@ TODO
return backpath;
}
private final void closePosition(int x, int y)
{
t[x][y] &= ~OPEN;
t[x][y] |= CLOSED;
}
/**
* @returns wheter process closed current node.
* One step in Maze generation process
* get last element in open list and explore one random direction with it.
*
* @returns whether process closed current node.
**/
public boolean step(int depth)
public boolean step()
{
boolean complete = false;
Position current = null;
@@ -977,11 +968,12 @@ TODO
}
}
complete = true;
t[x][y] &= ~OPEN;
t[x][y] |= CLOSED;
if (current.getDepth() > deepest)
closePosition(x,y);
final int currentdepth = current.getDepth();
if ( currentdepth > deepest)
{
deepest = depth;
deepest = currentdepth;
deepestEnd = current;
}
} // current != null;