I converted WILDFIRE.BAS to WILDFIRE.AWK [1]. I changed the program to use a command style interface, with chess-style algebraic notation for grid locations. I added a new glyph "+" to represent controlled fire. I also changed the interface so that the commands are written or queued and the target location displayed on the map, making it possible to correct a mistake before sending the command.
For the sample run, i used Jerome Shidel's LOGGER.SYS to capture the program output from mawk. It's kind of like using the `script` command on *nix.
I wrote WILDFIRE.AWK using mawk on SvarDOS. It is 310 lines long, compared to 82 lines of BASIC. It ran without modification on Linux using busybox AWK and gawk.
Here's how i ran it. The - option uses stdin for input.
$ awk -f wildfire.awk -
What follows is an updated description of the Wildfire simulation.
A lightning storm has ignited fires in a forest. Your task is to put out the fires and save as many trees as possible. The forest is divided into 81 sectors formed by a 9x9 grid. Each sector is identified by the row number and column letter.
Symbols:
"." -- woods
"*" -- fire, uncontrolled
"+" -- fire, under control
" " -- burnt out woods
The chance of an existing fire spreading to adjacent wooded areas is 70%. Fires last for nine turns before burning out.
You have two weapons with which to fight the fire. You can drop chemicals that are designed to extinguish the fires in a specified sector. The chance that the drop will affect the fires in this sector and its eight adjacent sectors is 50%. For example, if there are six fires burning in a nine-square area, approximately three will be affected by the chemicals. The effect of chemicals is to reduce the number of turns before the fire burns out by three. Since a fire lasts only nine turns, three successful chemical hits will be needed to extinguish a fire. If the fire has been burning for six turns, then one hit will suffice. To drop chemicals, use the "DROP" or "D" command with the row & column.
The second weapon available to you is a backfire. To start a backfire, you must use the "BACK" or "B" command with the row & column of the location. The sector in which a backfire is started must be wooded. This backfire will not spread and will burn out in the next turn, forming a barrier against the spread of fire.
Your rating will be the number of trees remaining after all the fires are out, plus 30.
Turn #1
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . . * .
5 . . . . . . . * .
6 . . . * . . . . .
7 . . . . . . . . .
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): BACK 4 G
Turn #1
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . B * .
5 . . . . . . . * .
6 . . . * . . . . .
7 . . . . . . . . .
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): SEND
Turn #2
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . + * .
5 . . . . . . . * .
6 . . . * . . . . *
7 . . . . . . . . .
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): BACK 5 G
Turn #2
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . + * .
5 . . . . . . B * .
6 . . . * . . . . *
7 . . . . . . . . .
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): SEND
Turn #3
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . * .
5 . . . . . . + * .
6 . . . * . . . . *
7 . . . . . . . . .
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): BACK 6 H
Turn #3
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . * .
5 . . . . . . + * .
6 . . . * . . . B *
7 . . . . . . . . .
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): SEND
Turn #4
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . * .
5 . . . . . . * .
6 . . . * . . . + *
7 . . . . . . . . *
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): BACK 7 H
Turn #4
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . . .
4 . . . . . . * .
5 . . . . . . * .
6 . . . * . . . + *
7 . . . . . . . B *
8 . . . . . . . . .
9 . . . . . . . . .
Enter command (or "?"): SEND
Skip forward past turns 5 through 10...
Turn #11
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . . *
6 . . . . . .
7 . . + + . . +
8 . . . * . . . *
9 . . . * * * . .
Enter command (or "?"): BACK 8 C
Turn #11
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . . *
6 . . . . . .
7 . . + + . . +
8 . . B * . . . *
9 . . . * * * . .
Enter command (or "?"): SEND
Turn #12
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . . +
6 . . . . . .
7 . . + . .
8 . . + + * . . *
9 . . . * * * . .
Enter command (or "?"): BACK 9 C
Turn #12
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . . +
6 . . . . . .
7 . . + . .
8 . . + + * . . *
9 . . B * * * . .
Enter command (or "?"): SEND
Skip forward past turns 13 through 15...
Turn #15
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . .
6 . . . . . .
7 . . +
8 . . * * . *
9 . . * + . .
Enter command (or "?"): DROP 8 F
Turn #15
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . .
6 . . . . . .
7 . . [ _ _+]
8 . . [ _*_*]. *
9 . . *[ _+_ ]. .
Enter command (or "?"): SEND
Turn #16
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . .
6 . . . . . .
7 . .
8 . . + + . +
9 . . + . .
Enter command (or "?"): DROP 8 H
Turn #16
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . .
6 . . . . . .
7 . . [ _ _
8 . . +[+_._+
9 . . + [ _._.
Enter command (or "?"): SEND
Turn #17
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . .
6 . . . . . .
7 . .
8 . . . +
9 . . + . .
Enter command (or "?"): DROP 8 I
Turn #17
A B C D E F G H I
1 . . . . . . . . .
2 . . . . . . . . .
3 . . . . . . . .
4 . . . . . . .
5 . . . . .
6 . . . . . .
7 . . [ _
8 . . [._+
9 . . + [._.
Enter command (or "?"): SEND
Your rating is 83.
0 -- Burnt woods
1 to 9 -- Fire
10 -- Woods
11 -- Temporary variable