Added support for HI command (C can now see UUID)
[progcomp10.git] / src / link / C / c_link.h
1 /*\r
2  *  c_link.h\r
3  *  c-link-lib\r
4  *\r
5  *  Created by Daniel Axtens on 19/04/10.\r
6  *  Licensed under an MIT-style license: see the LICENSE file for details.\r
7  *\r
8  */\r
9 \r
10 #include <stdio.h>\r
11 \r
12 #define MAXCOMMANDLEN   15\r
13 #define MAXFOENAMELEN   50\r
14 #define MAXITEMLEN              10\r
15 #define MAXRESULTLEN    10\r
16 #define MAXBOOLLEN              6\r
17 #define UUIDLEN 37      // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12) + 1 null\r
18 \r
19 /********** Type definitions **********/\r
20 \r
21 /* The type of item used in an attack or defence */\r
22 typedef enum {rock, paper, scissors} ITEMTYPE;\r
23 \r
24 /* A result of a battle, in terms of who won */\r
25 typedef enum {attacker, defender, tie} RESULTTYPE;\r
26 \r
27 \r
28 /* An attack, consisting of the real attack and the attack promised */\r
29 typedef struct {\r
30         ITEMTYPE realAttack;\r
31         ITEMTYPE promisedAttack;\r
32 } ATTACKTYPE;\r
33 \r
34 \r
35 /********** Utility Function definitions **********/\r
36 /* These are implemented in c-link.c, and automagically linked in */\r
37 \r
38 /* prints a debug message. Same arguments as printf().\r
39    (you can't use printf because it is used to talk between\r
40     the agent and supervisor) \r
41  */\r
42 \r
43 #define debugmsg(x...) fprintf(stderr, x)\r
44 \r
45 /* A (hopefully) unique identifier for this particular instance of your agent,\r
46    to help with debugging */\r
47 int me;\r
48 \r
49 \r
50 /* Returns a random item */\r
51 \r
52 ITEMTYPE RandomAttack();\r
53 \r
54 /* A useful translation table\r
55    eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */\r
56 \r
57 extern char ITEMNAMES[3][MAXITEMLEN];\r
58 \r
59 /* Another useful table - who's the victor given an \r
60    attacker with first item vs defender with the second item? */\r
61 extern RESULTTYPE RESULTOF[3][3];\r
62 \r
63 /********** Bot Function definitions **********/\r
64 /* You need to provide implementations for these to create a bot */\r
65 \r
66 /* Initialise( yourName : string - name of this instance (you)\r
67              ) : void * - A data pointer to represent this instance\r
68  \r
69  Called to create a new instance of this agent\r
70 \r
71  */\r
72 void *Initialise( char * yourName );\r
73 \r
74 /* Defend( this : pointer - value returned from Initialise();\r
75            foeName : string - the name of your foe;\r
76            foePromisedAttack : ITEMTYPE - the item your foe promised to use\r
77          ) : ITEMTYPE - the item you wish to use to defend;\r
78  \r
79  Called when your agent needs to defend itself.\r
80  \r
81  */\r
82 ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack );\r
83 \r
84 \r
85 /* Attack( this: pointer - value returned from Initialise();\r
86            foeName : string - the name of your foe\r
87                  ) : ATTACKTYPE - the real and promised attack you wish to use\r
88 \r
89  Called when your agent needs to attack another agent.\r
90  \r
91  */\r
92 ATTACKTYPE Attack( void * this, char * foeName );\r
93 \r
94 \r
95 /* Results( this : pointer - value returned from Initialise();\r
96             foeName : string - the name of your foe;\r
97             isInstigatedByYou : 0=you defended/1=you attacked;\r
98             winner : RESULTTYPE - who won\r
99                         attItem : ITEMTYPE - the item used to attack;\r
100             defItem : ITEMTYPE - the item used to defend;\r
101             bluffItem : ITEMTYPE - the item that was promised\r
102             pointDelta : integer - how your points were affected.\r
103           );\r
104 \r
105  Called after your agent battles another agent, to tell you how the battle goes.\r
106  \r
107  */\r
108 void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,\r
109               ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,\r
110               int pointDelta );\r
111 \r
112 /* Cleanup( this: pointer - value returned from Initialise()\r
113           );\r
114 \r
115    Called when your agent is no longer needed, either due to the round ending\r
116    or due to your agent being eliminated.\r
117 \r
118  */\r
119 void Cleanup( void * this );\r

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