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

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