Mostly messing with "forfax" AI
[progcomp2012.git] / samples / forfax / main.cpp
1 /**
2  * "forfax", a sample Stratego AI for the UCC Programming Competition 2012
3  * The main function for the "forfax" AI program
4  * @author Sam Moore (matches) [SZM]
5  * @website http://matches.ucc.asn.au/stratego
6  * @email [email protected] or [email protected]
7  * @git git.ucc.asn.au/progcomp2012.git
8  */
9
10 #include <cstdlib>
11 #include <iostream>
12
13 #include "forfax.h"
14
15 using namespace std;
16
17 #include <stdio.h>
18
19 /**
20  * The AI
21  */
22 Forfax forfax;
23
24 /**
25  * The main function
26  * @param argc the number of arguments
27  * @param argv the arguments
28  * @returns exit code 0 for success, something else for error
29  * Do I really need to tell you this?
30  */
31 int main(int argc, char ** argv)
32 {
33         setbuf(stdin, NULL);
34         setbuf(stdout, NULL);
35
36
37         Forfax::Status move = forfax.Setup();
38
39         
40         while (move == Forfax::OK)
41         {
42                 move = forfax.MakeMove();
43         }
44
45         switch (move)
46         {
47                 case Forfax::OK:
48                         cerr << argv[0] << " Error - Should never see this!\n";
49                         break;
50                 case Forfax::NO_NEWLINE:
51                         cerr << argv[0] << " Error - Expected a new line!\n";
52                         break;
53                 case Forfax::EXPECTED_ATTACKER:
54                         cerr << argv[0] << " Error - Attacking piece does not exist on board!\n";
55                         break;
56                 case Forfax::UNEXPECTED_DEFENDER:
57                         cerr << argv[0] << " Error - Unexpected defending piece on board!\n";
58                         break;
59                 case Forfax::NO_ATTACKER:
60                         cerr << argv[0] << " Error - Couldn't find attacker in list of pieces!\n";
61                         break;
62                 case Forfax::NO_DEFENDER:
63                         cerr << argv[0] << " Error - Couldn't find defender in list of pieces!\n";
64                         break;
65
66                 case Forfax::COLOUR_MISMATCH:
67                         cerr << argv[0] << " Error - Colour of attacker and defender are the same!\n";
68                         break;
69                 case Forfax::INVALID_QUERY:
70                         cerr << argv[0] << " Error - Query did not make sense\n";
71                         break;
72                 case Forfax::VICTORY:
73                         cerr << argv[0] << " Game end - VICTORY!\n";
74                         break;          
75                 case Forfax::BOARD_ERROR:
76                         cerr << argv[0] << " Error - An error occurred with the board!\n";
77                         break;
78         }
79
80         cerr << "Final board state:\n";
81         forfax.PrintBoard(cerr);
82
83         cerr << "Forfax is now exiting!\n";
84         
85         
86         exit(EXIT_SUCCESS);
87         return 0;
88
89         
90 }
91
92

UCC git Repository :: git.ucc.asn.au