Create a deterministic program to play nd tic-tac-toe with the other contestants.
Your program should work when
n (width) and
d (dimension number) are in these ranges:
n∈[3,∞)∩ℕ ie a natural number greater than 2 d∈[2,∞)∩ℕ ie a natural number greater than 1
n = 3; d = 2 (32 ie 3 by 3):
  
n = 3; d = 3 (33 ie 3 by 3 by 3):
        
n = 6; d = 2 (62 ie 6 by 6):
     
And so on.
Input will be to STDIN. The first line of input will be two numbers,
d in the form
After this will be a line consisting of coordinates specifying the moves that have been done. Coordinates will be listed in the form:
1,1;2,2;3,3. The upper left corner is the origin ( 0,0 for 2D). In the general case, this list will be like
1,2,...,1,4;4,0,...,6,0;... where the first number represents left-right-ness, the second up-down-ness, the third through the 3rd dimension, etc. Note that the first coordinate is
Xs first turn, the second is
Os first turn, ....
Should this be the first move, the input will a number followed by 1 blank line.
For consistency, the input will always end with a newline. Sample Input (\n is newline):
For first move:
\n is the newline character.
Output the move you wish to make in the same format as the input (a comma-separated list). An invalid move (ie one that has already been taken) will result in a loss for the game.
Note: You can use a random number generator, as long as you seed it with a value such that each run would be identical given the same conditions. In other words, the program must be deterministic.
Note: only valid moves are allowed.
Winning Games (If you've played enough multi-dimensional tic tac toe, this is the same.)
In order for there to be a win, one player must have all the adjacent squares along a line. That is, that player must have
n moves on a line to be a winner.
- each tile is a point; for example (0,0,0,0,0) is a point in
- adjacent tiles are tiles such they are both points on the same unit d-cube. In other words, the Chebyshev distance between the tiles is 1.
- in other words, if a point
pis adjacent to a point
q, then every coordinate in
ps corresponding coordinate in
qdiffers from it by no more than one. Additionally, at least on coordinate pair differs by exactly one.
- Lines are defined by vectors and a tile. A line is each tile hit by the equation:
p0 + t
<some vector with the same number of coordinates as p0
Simulation and Winning Conditions:
State in your answer if it is ready for grading. That is, clearly indicate whether or not your answer is done.
If your answer is marked as done, it will not be graded until at least 24 hours after the last edit to the code.
Programs must work offline. If a program is found to be cheating, it will automatically receive a score of
-1, and will not be scored further. (How would anyone end up with their programs cheating?)
If your program produces invalid output, it is immediately counted as a loss for the game
If you program fails to produce output after 1 minute it is immediately counted as a loss for the game. If necessary, optimize for speed. I don't want to have to wait an hour to test a program off of another.
Each program will be run against the other programs twice for each
nin the range
din the range
[2,5], once as
Xand once as
O. This is one round.
For each game a program wins, it gets
+3to its score. If the program tied (1 win and 1 loss in a single round or ties for both games), then it gets
+1. If the program lost, then it gets
+0(ie no change).
The program with the highest score wins. Should there be a tie, then the program with the least number of lost games (out of the tied contestants) wins.
Note: Depending on the number of answers, I may need help running the tests.
Good luck! And may the simulations run ever in your favor!