diff --git a/java/org/artisanlogiciel/games/Display.java b/java/org/artisanlogiciel/games/Display.java index f09b75e..f4badb3 100644 --- a/java/org/artisanlogiciel/games/Display.java +++ b/java/org/artisanlogiciel/games/Display.java @@ -115,6 +115,7 @@ public class Display extends JFrame maze.resetWallsProvider(model); model.setMazeListener(maze); + model.reset(); // we are in GUI event thread, need to release it and do it outside. new Thread() { @@ -151,6 +152,7 @@ public class Display extends JFrame void resolve() { + model.reset(); model.resolve(model.getWidth() - 1, model.getHeight() - 1, maze); } @@ -446,6 +448,16 @@ public class Display extends JFrame } }; savePngButton.addActionListener(savePngAction); + final JButton saveButton = new JButton(labels.getString("save") +" raw"); + Action saveAction = new AbstractAction() { + public void actionPerformed(ActionEvent evt) + { + // + System.out.println("save"); + save((MazeParamsFixed) params,model); + } + }; + saveButton.addActionListener(saveAction); final JButton quitButton = new JButton(labels.getString("quit")); Action quitAction = new AbstractAction() { @@ -462,6 +474,7 @@ public class Display extends JFrame resizecontrol.add(slider); resizecontrol.add(autoSlide); resizecontrol.add(savePngButton); + resizecontrol.add(saveButton); resizecontrol.add(quitButton); add(controlDisplayPanel, BorderLayout.SOUTH); @@ -1076,6 +1089,7 @@ public class Display extends JFrame } } + public static void main(String pArgs[]) { LabyModel model = null; diff --git a/java/org/artisanlogiciel/games/LabyModel.java b/java/org/artisanlogiciel/games/LabyModel.java index a4364f3..8bf8b7d 100644 --- a/java/org/artisanlogiciel/games/LabyModel.java +++ b/java/org/artisanlogiciel/games/LabyModel.java @@ -86,6 +86,28 @@ public class LabyModel implements WallsProvider MazeCreationListener listener = null; + + /** +TODO + private static MyLinkedList
+ { + MyLinkedList
next; + P content + + MyLinkedList
( P object) + { + content=object; + next=null; + } + + MyLinkedList
addLast(P object)
+ {
+ next = new MyLinkedList(object);
+ return next;
+ }
+ }
+ */
+
public LabyModel(int width, int height, int maxdepth, Random random)
{
this.width = width;
@@ -414,6 +436,16 @@ public class LabyModel implements WallsProvider
{
depth = 0;
computeOpenList();
+ // don't keep solved path
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ t[x][y] &= ~(SOLVED);
+ }
+
+ }
+
}
public void fullReset()
@@ -429,7 +461,8 @@ public class LabyModel implements WallsProvider
for (int x = 0; x < width; x++)
{
// resetCell(x,y);
- t[x][y] &= ~OPEN;
+ t[x][y] &= ~( OPEN | SOLVED);
+
}
}
@@ -451,12 +484,12 @@ public class LabyModel implements WallsProvider
{
int x = p.getX();
int y = p.getY();
- if ((t[x][y] & OPEN) != OPEN)
+ if (isFlagSet(t[x][y],OPEN))
{
check = false;
t[x][y] |= OPEN;
}
- if ((t[x][y] & CLOSED) == CLOSED)
+ if (isFlagSet(t[x][y],CLOSED))
{
check = false;
t[x][y] &= ~CLOSED;
@@ -476,16 +509,15 @@ public class LabyModel implements WallsProvider
{
for (int x = 0; x < width; x++)
{
- if ((t[x][y] & CLOSED) == CLOSED)
+ if (isFlagSet(t[x][y],CLOSED))
{
t[x][y] &= ~OPEN;
}
- if (((t[x][y] & OPEN) == OPEN) || (t[x][y] == CLEAR))
+ if (isFlagSet(t[x][y],OPEN) || (t[x][y] == CLEAR))
{
openList.add(new Position(x, y));
}
}
-
}
}
@@ -613,6 +645,10 @@ public class LabyModel implements WallsProvider
short selectedDirection = 0;
int newx = x;
int newy = y;
+
+ // list of alternate paths
+ LinkedList