5 * Created by Daniel Axtens on 19/04/10.
\r
6 * Licensed under an MIT-style license: see the LICENSE file for details.
\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
18 /********** Type definitions **********/
\r
20 /* The type of item used in an attack or defence */
\r
21 typedef enum {rock, paper, scissors} ITEMTYPE;
\r
23 /* A result of a battle, in terms of who won */
\r
24 typedef enum {attacker, defender, tie} RESULTTYPE;
\r
27 /* An attack, consisting of the real attack and the attack promised */
\r
29 ITEMTYPE realAttack;
\r
30 ITEMTYPE promisedAttack;
\r
34 /********** Utility Function definitions **********/
\r
35 /* These are implemented in c-link.c, and automagically linked in */
\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
42 #define debugmsg(x...) fprintf(stderr, x)
\r
44 /* A (hopefully) unique identifier for this particular instance of your agent,
\r
45 to help with debugging */
\r
49 /* Returns a random item */
\r
51 ITEMTYPE RandomAttack();
\r
53 /* A useful translation table
\r
54 eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
\r
56 extern char ITEMNAMES[3][MAXITEMLEN];
\r
58 /* Another useful table - who's the victor given an
\r
59 attacker with first item vs defender with the second item? */
\r
60 extern RESULTTYPE RESULTOF[3][3];
\r
62 /********** Bot Function definitions **********/
\r
63 /* You need to provide implementations for these to create a bot */
\r
65 /* Initialise( yourName : string - name of this instance (you)
\r
66 ) : void * - A data pointer to represent this instance
\r
68 Called to create a new instance of this agent
\r
71 void *Initialise( char * yourName );
\r
73 /* Defend( this : pointer - value returned from Initialise();
\r
74 foeName : string - the name of your foe;
\r
75 foePromisedAttack : ITEMTYPE - the item your foe promised to use
\r
76 ) : ITEMTYPE - the item you wish to use to defend;
\r
78 Called when your agent needs to defend itself.
\r
81 ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack );
\r
84 /* Attack( this: pointer - value returned from Initialise();
\r
85 foeName : string - the name of your foe
\r
86 ) : ATTACKTYPE - the real and promised attack you wish to use
\r
88 Called when your agent needs to attack another agent.
\r
91 ATTACKTYPE Attack( void * this, char * foeName );
\r
94 /* Results( this : pointer - value returned from Initialise();
\r
95 foeName : string - the name of your foe;
\r
96 isInstigatedByYou : 0=you defended/1=you attacked;
\r
97 winner : RESULTTYPE - who won
\r
98 attItem : ITEMTYPE - the item used to attack;
\r
99 defItem : ITEMTYPE - the item used to defend;
\r
100 bluffItem : ITEMTYPE - the item that was promised
\r
101 pointDelta : integer - how your points were affected.
\r
104 Called after your agent battles another agent, to tell you how the battle goes.
\r
107 void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,
\r
108 ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
\r
111 /* Cleanup( this: pointer - value returned from Initialise()
\r
114 Called when your agent is no longer needed, either due to the round ending
\r
115 or due to your agent being eliminated.
\r
118 void Cleanup( void * this );
\r