13 int main(int argc, char ** argv)
16 char * red = NULL; char * blue = NULL; double timeout = 0.00001; bool graphics = false; bool allowIllegal = false; FILE * log = NULL;
17 Piece::Colour reveal = Piece::BOTH;
18 for (int ii=1; ii < argc; ++ii)
20 if (argv[ii][0] == '-')
27 fprintf(stderr, "Expected timeout value after -t switch!\n");
30 timeout = atof(argv[ii+1]);
43 fprintf(stderr, "Expected filename or \"stdout\" after -o switch!\n");
48 fprintf(stderr, "Expected at most ONE -o switch!\n");
51 if (strcmp(argv[ii+1], "stdout") == 0)
54 log = fopen(argv[ii+1], "w");
61 if (reveal == Piece::BOTH)
67 if (reveal == Piece::BOTH)
74 system("less manual.txt");
78 if (strcmp(argv[ii]+2, "help") == 0)
81 system("less manual.txt");
86 fprintf(stderr, "Unrecognised switch \"%s\"...\n", argv[ii]);
96 else if (blue == NULL)
100 fprintf(stderr, "Unexpected argument \"%s\"...\n", argv[ii]);
107 fprintf(stderr, "Usage: stratego [options] red blue\n");
108 fprintf(stderr, " stratego --help\n");
113 Game game(red, blue, graphics, timeout, allowIllegal, log, reveal);
116 if (!game.Setup(red, blue))
118 fprintf(stdout, "NONE %d\n",game.TurnCount());
122 MovementResult result = game.Play();
123 game.PrintEndMessage(result);
125 Piece::Colour winner = game.Turn();
126 if (Board::LegalResult(result))
128 if (winner == Piece::BOTH)
129 winner = Piece::NONE;
132 if (winner == Piece::RED)
133 winner = Piece::BLUE;
143 fprintf(stdout, "%s RED %d\n", red,game.TurnCount());
146 fprintf(stdout, "%s BLUE %d\n", blue,game.TurnCount());
149 fprintf(stdout, "DRAW %d\n",game.TurnCount());
152 fprintf(stdout, "NONE %d\n",game.TurnCount());