Backing up the results files before fucking with them
[progcomp2012.git] / agents / ramen / ai_common.h
1 /*
2  * UCC 2012 Programming Competition Entry
3  * - "Ramen"
4  *
5  * By John Hodge [TPG]
6  */
7 #ifndef _AI_COMMON_H_
8 #define _AI_COMMON_H_
9
10 #include "interface.h"
11
12 #define N_PIECES        40
13
14 enum eRanks
15 {
16         RANK_UNKNOWN,   //  0
17         RANK_MARSHAL,   //  1
18         RANK_GENERAL,   //  2
19         RANK_COLONEL,   //  3
20         RANK_MAJOR,     //  4
21         RANK_CAPTAIN,   //  5
22         RANK_LIEUTENANT,//  6
23         RANK_SERGEANT,  //  7
24         RANK_MINER,     //  8
25         RANK_SCOUT,     //  9
26         RANK_SPY,       // 10
27         RANK_BOMB,      // 11
28         RANK_FLAG,      // 12
29         N_RANKS
30 };
31 static const int MAX_RANK_COUNTS[N_RANKS] = {
32         40, 1, 1, 2, 3, 4, 4, 4, 5, 8, 1, 6, 1
33 };
34 static const char cRANK_CHARS[N_RANKS] = "#123456789sBF";
35 static inline enum eRanks CharToRank(char ch)
36 {
37         switch(ch)
38         {
39         case '1':       return RANK_MARSHAL;
40         case '2':       return RANK_GENERAL;
41         case '3':       return RANK_COLONEL;
42         case '4':       return RANK_MAJOR;
43         case '5':       return RANK_CAPTAIN;
44         case '6':       return RANK_LIEUTENANT;
45         case '7':       return RANK_SERGEANT;
46         case '8':       return RANK_MINER;
47         case '9':       return RANK_SCOUT;
48         case 's':       return RANK_SPY;
49         case 'B':       return RANK_BOMB;
50         case 'F':       return RANK_FLAG;
51         case '#':       return RANK_UNKNOWN;
52         default:
53                 // Wut. Unkown
54                 DEBUG("Unknown character '%c'", ch);
55                 return RANK_UNKNOWN;
56         }
57 }
58
59 /**
60  */
61 typedef struct sPiece
62 {
63          int    X, Y;
64         BOOL    bDead;
65         enum eRanks     Rank;   // -1 = unknown
66         BOOL    bHasMoved;
67         enum eColours   Team;
68         // TODO: Keep last moved
69         
70         BOOL    bExposed;       // Marks when the piece is known by the other team
71
72          int    StartX, StartY; // Used to save initial layout
73         enum eRanks     GuessedRank;    // Only used it bGuessValid is set
74 } tPiece;
75
76 typedef struct sPlayerStats
77 {
78         enum eColours   Colour;
79          int    nPieces;
80          int    nMoved;
81          int    nIdentified;
82          int    nRanks[N_RANKS];
83          int    nKilledRanks[N_RANKS];
84         tPiece  Pieces[N_PIECES];
85         BOOL    bGuessValid;
86 } tPlayerStats;
87
88 typedef struct sPieceRef
89 {
90         char    Index;  // Index into tPlayerStats.Pieces
91         char    Team;   // 0 = Empty, 1 = Me, 2 = Opponent, 3 = Block
92 } tPieceRef;
93
94 typedef struct sGameState
95 {
96         tPlayerStats    Opponent;
97         tPlayerStats    MyExposed;
98         tPlayerStats    MyActual;
99         tPieceRef       BoardState[];   // 
100 } tGameState;
101
102 // --- Database
103 extern char     *DB_GetOpponentFile(const char *Opponent);
104 extern void     DB_LoadGuesses(const char *DBFile, enum eColours Colour);
105 extern void     DB_WriteBackInitialState(const char *DBFile, enum eColours Colour, tPiece *Pieces);
106
107 #endif
108

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