Day 11 - part 2 and output, and some notes
[advent-of-code-2019.git] / day11 / run2.sh
1 #!/bin/bash
2
3 set -u
4 set -e
5
6 exec 3<input.txt
7
8 OLDIFS=$IFS
9 IFS=","
10 read -u 3 -a data
11 IFS=$OLDIFS
12
13 base_dir=$(dirname $(readlink -f $BASH_SOURCE))
14 . computer.sh
15 . robot.sh
16
17 coproc computer (run_program data)
18
19 reset_robot
20 set_robot_start_on_white 1
21
22 check_pid=$computer_PID
23
24 while ( kill -0 $check_pid > /dev/null 2>&1 ); do
25     get_robot_paint_colour >&${computer[1]}
26     read -u ${computer[0]} direction
27     read -u ${computer[0]} colour
28     do_robot_paint_and_move $direction $colour
29     sleep 0.1
30 done
31
32 # just incase the spinner is still about
33 echo -n $'\r'"                "$'\r'
34
35 echo "Part 2:"
36 draw_panel