]> git.sommitrealweird.co.uk Git - advent-of-code-2019.git/blobdiff - day11/robot.sh
ZAP! Day 10.
[advent-of-code-2019.git] / day11 / robot.sh
index c5b56139262460946551d20b25842f7d41e8d662..79f87a80389880750ca0c73dd1a51736bd47cce1 100644 (file)
@@ -39,7 +39,7 @@ get_paint_colour() {
     if [ ${__robot_grid[$x,$y]+a} ]; then
         echo ${__robot_grid[$x,$y]}
     else
-        if [ $x -eq 0 ] && [ $y -eq 0 ] && [ $__start_on_white -eq 1 ]; then
+        if [ $x -eq 0 ] && [ $y -eq 0 ] && [ $__robot_start_on_white -eq 1 ]; then
             echo 1
         else
             echo 0
@@ -140,7 +140,9 @@ do_robot_paint_and_move() {
 draw_panel() {
     colours=("." "#")
 
-    for (( y=$__robot_lowest_y; y<=$__robot_highest_y; y++ )); do
+    # we draw upside down, in effect, starting from the bottom and going to
+    # the top, so when outputting, we should switch that round
+    for (( y=$__robot_highest_y; y>=$__robot_lowest_y; y-- )); do
         for (( x=$__robot_lowest_x; x<=$__robot_highest_x; x++ )); do
             echo -n ${colours[$(get_paint_colour $x $y)]}
         done