POTM: Programmer of the Month: Nuts: Input and Output Specifications

In addition to the long rules (the details), it is necessary to be very explicit about the input to your program and the output it produces. That is the purpose of the following. If you have questions - please post them to the forum.
Any change made after September 11 is dated and marked in red.

When your entry runs, it will be asked to read a file that will contain definitions of the following problem elements:
   1) The size of the grid (containing N by N squares)
   2) The location of all nuts in the grid
   3) The number of squirrels on each square in the grid
   4) YOUR current position ...
It will then be asked to output a move.

The input file will be presented as a full path argument to your executable, and your executable will write output to stdout.
For example:     nut_muncher     /tmp/inputfile


A. The GRID will contain SQUARES which are identified with a standard X,Y coordinate system ... with the lower left square identifed as 0,0.
B. The OUTPUT of your program will be the X and Y coordinates of the square to which you wish to move, separated by a comma and containing no red space and followed by a CR/LF as in printf("\n"). For example: 3,3 is a legitimate move if you are curently at 2,2. No equal signs, no parentheses, no red space, only a single comma separating two numbers.
Sep 26: There will be NO output to stderr and NO additional output to stdout other than the two comma-separated numbers.
C. The INPUT of your program will be a series of Name=Value pairs with one Name=Value pair per line. The "Name" will be one of the following; the Value will always be a X,Y pair with no red space on the line.
(Examples shown below for Values):

SIZE=4,4
(signifying a 5x5 grid - the X,Y pair given is the largest square coordinate pair permitted)
SIZE will always be present and the first line of input; There will only be ONE size line per move; the SIZE line will be the same for all moves in a game/round.

NUT=2,3
(signifying a nut in square 2,3)
There will always be at least one NUT line; There may be up half as many NUT lines as there are squares; X,Y coordinates for all NUT lines are unique since there cannot be more than one nut per square; there cannot be a NUT on the center square.

SQUIRREL=2,2
(signifying a squirrel on square 2,2)
There will always be at least one SQUIRREL line representing yourself; there will only be one SQUIRREL line in the single player mode; in multi-SQUIRREL mode there will be one SQUIRREL line for each player in the round; at the start of the game/round, there will be one SQUIRREL line for each player and they all will appear at the center square.

YOU=2,2
(signifying your position on square 2,2)
This is in addition to your SQUIRREL line which will also appear; the YOU line will always be present; the YOU line will be the last line of the input file.


A sample grid (mid-game) and its description to help clarify any issues:

NOTE: there are five squirrels including yourself
NOTE: you share a square with another squirrel
NOTE: NUT and SQUIRREL lines are not ordered in any particular way
NOTE: All NUT lines will appear before any SQUIRREL lines


The POTM is unsponsored and just for fun.       Tuesday 04:36:59 AM      Copyright © 2004-6 - Fred Hicinbothem