X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2019.git/blobdiff_plain/6db27abe8665a8a34ce1590cfe1a667bf843d7ad..7d2ab2bc1f8f0a8eb3f50644a1de5f4d3ad938d2:/day11/robot.sh diff --git a/day11/robot.sh b/day11/robot.sh index c5b5613..79f87a8 100644 --- a/day11/robot.sh +++ b/day11/robot.sh @@ -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