Simulate the gopher-hole game.
A sequence of blank-line-separated board configurations for the
gopher-hole game. Each board configuration in the input file has the format
NROWS NCOLUMNS
NHOLES
HOLE_ROW(1) HOLE_COLUMN(1)
HOLE_ROW(2) HOLE_COLUMN(2)
.
.
.
HOLE_ROW(N) HOLE_COLUMN(N)
The upper left corner of the board is row 1 column 1. No playing field will be larger than 100 rows by 100 columns. This is the number of patches in the field. Immediately following this are a sequence of picks listed by row and column, one per line. For example, an input file containing two games would be
column 111111111122222222223 123456789012345678901234567890 line 1:10 10[EOL] 2:3[EOL] 3:1 1[EOL] 4:1 3[EOL] 5:2 1[EOL] 6:5 5[EOL] 7:[EOL] 8:10 10[EOL] 9:2[EOL] 10:2 1[EOL] 11:1 2[EOL] 12:5 5[EOL] 13:1 1[EOL] 14:2 1[EOL] :[EOF]
(1) The playing field is surrounded by a "fence." This is depicted in the output file with a leading row of the form +------+, where the number of hyphens match the number of columns on the field. Each row is preceded and succeeded by a | (pipe) character. A final line of the form +------+ is printed to mark the bottom of the field. Within the field, each patch is represented by an ASCII character. Initially, all patches are uninspected and are marked by a pound (#) symbol.
(2) If a move is not a gopher hole, then the inspected patch is "cleared" to reveal the sum of gopher holes adjacent (horizontally, vertically, or diagonally) to this hole. A sum of zero is represented as a blank, while other sums are represented by the corresponding digit. If an inspected patch has no adjacent gopher holes, then all adjacent patches are inspected. This last rule is applied recursively.
(3) If a player inspects the location of one of the holes, the game ends because the player "fell in a hole." In this case, the board configuration is printed with the same information as before the losing play was made, with these two execptions:
column 111111111122222222223 123456789012345678901234567890 line 1:Program 6 by team 0[EOL] 2:+----------+[EOL] 3:|###1 |[EOL] 4:|#311 |[EOL] 5:|11 |[EOL] 6:| |[EOL] 7:| |[EOL] 8:| |[EOL] 9:| |[EOL] 10:| |[EOL] 11:| |[EOL] 12:| |[EOL] 13:+----------+[EOL] 14:[EOL] 15:+----------+[EOL] 16:|##1 |[EOL] 17:|#21 |[EOL] 18:|11 |[EOL] 19:| |[EOL] 20:| |[EOL] 21:| |[EOL] 22:| |[EOL] 23:| |[EOL] 24:| |[EOL] 25:| |[EOL] 26:+----------+[EOL] 27:[EOL] 28:+----------+[EOL] 29:|2#1 |[EOL] 30:|#21 |[EOL] 31:|11 |[EOL] 32:| |[EOL] 33:| |[EOL] 34:| |[EOL] 35:| |[EOL] 36:| |[EOL] 37:| |[EOL] 38:| |[EOL] 39:+----------+[EOL] 40:[EOL] 41:+----------+[EOL] 42:|2*1 |[EOL] 43:|!21 |[EOL] 44:|11 |[EOL] 45:| |[EOL] 46:| |[EOL] 47:| |[EOL] 48:| |[EOL] 49:| |[EOL] 50:| |[EOL] 51:| |[EOL] 52:+----------+[EOL] 53:End of program 6 by team 0[EOL] :[EOF]