about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--algorithms/java/DFS.java7
-rw-r--r--lib/Fornax/CLI.rakumod21
-rw-r--r--resources/solutions/DFS-32.fornax13
-rw-r--r--resources/solutions/DFS-33.fornax25
4 files changed, 57 insertions, 9 deletions
diff --git a/algorithms/java/DFS.java b/algorithms/java/DFS.java
index ff4567d..e0da681 100644
--- a/algorithms/java/DFS.java
+++ b/algorithms/java/DFS.java
@@ -24,6 +24,9 @@ public class DFS {
                 || curx > maze.length - 1 || cury > maze[0].length - 1)
                 continue;
 
+            if (visited[curx][cury])
+                continue;
+
             // Marker cells.
             if (maze[curx][cury] == '$')
                 System.out.print("|");
@@ -43,9 +46,7 @@ public class DFS {
             if (maze[curx][cury] == '$')
                 System.exit(0);
 
-            if (visited[curx][cury]) {
-                continue;
-            } else if (maze[curx][cury] == '.') {
+            if (maze[curx][cury] == '.') {
                 visited[curx][cury] = true;
                 traverse(curx, cury, maze, visited);
                 visited[curx][cury] = false;
diff --git a/lib/Fornax/CLI.rakumod b/lib/Fornax/CLI.rakumod
index 110f587..bcecff2 100644
--- a/lib/Fornax/CLI.rakumod
+++ b/lib/Fornax/CLI.rakumod
@@ -17,7 +17,7 @@ proto MAIN(|) is export { unless so @*ARGS { put $*USAGE; exit }; {*} }
 multi sub MAIN(
     File $input, #= fornax format file (solved)
     Directory :$output = '/tmp/output', #= output directory (existing)
-    Int :$frame-rate = 1, #= frame rate
+    Rat() :$frame-rate = 1, #= frame rate
     Bool :$verbose = True, #= verbosity
 ) is export {
     my Str @lines = $input.IO.lines;
@@ -35,12 +35,16 @@ multi sub MAIN(
 
     # Colors.
     constant %C = (
+        red => "#f2b0a2",
+        blue => "#b5d0ff",
+        cyan => "#c0efff",
         black => "#000000",
         white => "#ffffff",
         green => "#aecf90",
-        cyan => "#c0efff",
-        red => "#f2b0a2",
-        pointer => "#093060"
+
+        pointer => "#093060",
+        pointer-red => "#5d3026",
+        pointer-green => "#184034",
     ).map: {.key => hex2rgb(.value)};
 
     # Every cell must be square. Get the maximum width, height and use
@@ -97,8 +101,13 @@ multi sub MAIN(
 
                         .rectangle: |@target;
                         given @grid[$r][$c] -> $cell {
-                            when $cell eq $VIS|$CUR {
-                                .rgba: |%C<cyan>, 0.64;
+                            when $cell eq $CUR {
+                                .rgba: |%C<pointer>, 0.56;
+                                .rgba: |%C<pointer-green>, 0.72 if $status == Completed;
+                                .rgba: |%C<pointer-red>, 0.72 if $status == Blocked;
+                            }
+                            when $cell eq $VIS {
+                                .rgba: |%C<blue>, 0.64;
                                 .rgba: |%C<green>, 0.96 if $status == Completed;
                                 .rgba: |%C<red>, 0.96 if $status == Blocked;
                             }
diff --git a/resources/solutions/DFS-32.fornax b/resources/solutions/DFS-32.fornax
new file mode 100644
index 0000000..1e8b226
--- /dev/null
+++ b/resources/solutions/DFS-32.fornax
@@ -0,0 +1,13 @@
+rows:7 cols:8
+.#.#..#..........#..#..$...#.#.........#.##...#.........
+-#.#..#.@........#..#..$...#.#.........#.##...#.........
+-#.#..#.-@.......#..#..$...#.#.........#.##...#.........
+-#.#..#.--@......#..#..$...#.#.........#.##...#.........
+-#.#..#.---@.....#..#..$...#.#.........#.##...#.........
+-#.#..#.----@....#..#..$...#.#.........#.##...#.........
+!-#.#..#.-----....#..@..$...#.#.........#.##...#.........
+-#.#..#.-----@...#..#..$...#.#.........#.##...#.........
+-#.#..#.------@..#..#..$...#.#.........#.##...#.........
+!-#.#..@.-------..#..#..$...#.#.........#.##...#.........
+-#.#..#.-------@.#..#..$...#.#.........#.##...#.........
+|-#.#..#.--------.#..#..@...#.#.........#.##...#.........
diff --git a/resources/solutions/DFS-33.fornax b/resources/solutions/DFS-33.fornax
new file mode 100644
index 0000000..d8e221c
--- /dev/null
+++ b/resources/solutions/DFS-33.fornax
@@ -0,0 +1,25 @@
+rows:7 cols:8
+.#.#..#..........#..#..$...#.#.........#.##...#.........
+!-@.#..#..........#..#..$...#.#.........#.##...#.........
+-#.#..#.@........#..#..$...#.#.........#.##...#.........
+-#.#..#.-.......@#..#..$...#.#.........#.##...#.........
+!-#.#..#.-.......-@..#..$...#.#.........#.##...#.........
+-#.#..#.-.......-#..#..$@..#.#.........#.##...#.........
+-#.#..#.-.......-#..#..$-..#.#..@......#.##...#.........
+-#.#..#.-.......-#..#..$-..#.#..-......#@##...#.........
+-#.#..#.-.......-#..#..$-..#.#..-......#-##...#.@.......
+-#.#..#.-.......-#..#..$-..#.#..-......#-##...#.-@......
+!-#.#..#.-.......-#..#..$-..#.#..-......#-@#...#.--......
+-#.#..#.-.......-#..#..$-..#.#..-......#-##...#.--@.....
+-#.#..#.-.......-#..#..$-..#.#..-......#-##...#.---@....
+-#.#..#.-.......-#..#..$-..#.#..-......#-##@..#.----....
+-#.#..#.-.......-#..#..$-..#.#..-..@...#-##-..#.----....
+!-#.#..#.-.......-#..#..$-..@.#..-..-...#-##-..#.----....
+-#.#..#.-.......-#..#..$-..#.#..-..-@..#-##-..#.----....
+-#.#..#.-.......-#..#..$-..#.#..-..--@.#-##-..#.----....
+-#.#..#.-.......-#..#..$-..#.#..-..---@#-##-..#.----....
+!-#.#..#.-.......-#..#..$-..#.#..-..----#-##-..@.----....
+-#.#..#.-.......-#..#..$-..#.#@.-..----#-##-..#.----....
+-#.#..#.-.......-#..#..$-..#.#-@-..----#-##-..#.----....
+!-#.#..#.-.......-#..#..$-..#.#---..----@-##-..#.----....
+|-#.#..#.-.......-#..#..@-..#.#---..----#-##-..#.----....