Chapter 8. Live Graphics

AmazonGui can display graphical data on the Amazon board while a command is in progress. Live graphics commands are considered temporary information about what the program is currently thinking.

The Amazons program invokes live graphics commands by writing draw commands to its standard error stream. Every line that starts with amazonsgui-gfx: is interpreted by AmazonGui as a draw command. To start live graphics the command "GFX" is sent to the external program. This tells the AI to start outputting the draw commands to standard error. If the AI receives the GFX command again it should disable printing draw commands to standard error. The button with an image of an eye on the toolbar enables and disables live graphics.
From the AI, each draw command must be sent to standard error individually. Each command must also end in a new line.

For example, our test AI sends the following commands to AmazonsGui:

fprintf(stderr, "amazonsgui-gfx: TEXT Live Graphics Demo\n");
fflush(stderr);
sleep(1);
fprintf(stderr, "amazonsgui-gfx: LABEL A4 test\n");
fflush(stderr);
sleep(1);
fprintf(stderr, "amazonsgui-gfx: SQUARE B5 C9\n");
fflush(stderr);
sleep(1);
fprintf(stderr, "amazonsgui-gfx: MARK A6 B6\n");
fflush(stderr);
sleep(1);
fprintf(stderr, "amazonsgui-gfx: TRIANGLE A9\n");
fflush(stderr);
sleep(1);
fprintf(stderr, "amazonsgui-gfx: CIRCLE C8\n");
fflush(stderr)