5 * Created by Daniel Axtens on 19/04/10.
6 * Licensed under an MIT-style license: see the LICENSE file for details.
12 #define MAXCOMMANDLEN 15
13 #define MAXFOENAMELEN 50
17 /********** Type definitions **********/
19 /* The type of item used in an attack or defence */
20 typedef enum {rock, paper, scissors} ITEMTYPE;
22 /* A result of a battle */
23 typedef enum {win, lose, tie} RESULTTYPE;
26 /* An attack, consisting of the real attack and the attack promised */
29 ITEMTYPE promisedAttack;
33 /********** Utility Function definitions **********/
34 /* These are implemented in c-link.c, and automagically linked in */
36 /* prints a debug message. Same arguments as printf().
37 (you can't use printf because it is used to talk between
38 the agent and supervisor)
41 #define debugmsg(x...) fprintf(stderr, x)
43 /* A (hopefully) unique identifier for this particular instance of your agent,
44 to help with debugging */
48 /* Returns a random item */
50 ITEMTYPE RandomAttack();
52 /* A useful translation table
53 eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
55 extern char ITEMNAMES[3][MAXITEMLEN];
57 /* Another useful table - what's the result of the
58 first item vs the second item? */
59 extern RESULTTYPE RESULTOF[3][3];
61 /********** Bot Function definitions **********/
62 /* You need to provide implementations for these to create a bot */
64 /* Defend( foeName : string - the name of your foe;
65 foePromisedAttack : ITEMTYPE - the item your foe promised to use
66 ) : ITEMTYPE - the item you wish to use to defend;
68 Called when your agent needs to defend itself.
71 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
74 /* Attack( foeName : string - the name of your foe
75 ) : ATTACKTYPE - the real and promised attack you wish to use
77 Called when your agent needs to attack another agent.
80 ATTACKTYPE Attack( char * foeName );
83 /* Results( foeName : string - the name of your foe;
84 isInstigatedByYou : 0=you defended/1=you attacked;
85 yourItem : ITEMTYPE - the item you used;
86 theirItem : ITEMTYPE - the item they used;
87 promisedItem : ITEMTYPE - the item that was promised
90 Called after your agent battles another agent, to tell you how the battle goes.
93 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem,
94 ITEMTYPE theirItem, ITEMTYPE promisedItem);
98 Called when your agent is no longer needed, either due to the round ending
99 or due to your agent being eliminated.