about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-11-03 22:22:57 +0530
committerAndinus <andinus@nand.sh>2021-11-03 22:22:57 +0530
commit8cef86f0eb8b46b0ed2d7c37fa216890300249f6 (patch)
tree4d50ebc636068bcc1aa0fc8f7c8bbbc2ac252a41 /lib
parentc9e3cb29fedcbe7e247d5abfb61bc4f0024ce5f4 (diff)
downloadfornax-8cef86f0eb8b46b0ed2d7c37fa216890300249f6.tar.gz
java/DFS: Don't walk on visited, Add DFS solutions, change colors
It didn't walk on visited grid but printed that as an iteration so it
seemed like it did.
Diffstat (limited to 'lib')
-rw-r--r--lib/Fornax/CLI.rakumod21
1 files changed, 15 insertions, 6 deletions
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;
                             }