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...) sprintf(stderr, x)
43 /* Returns a random item */
45 ITEMTYPE RandomAttack();
47 /* A useful translation table
48 eg printf( "I use %s.\n", ITEMNAMES[rock] ); */
50 extern char ITEMNAMES[3][MAXITEMLEN];
52 /* Another useful table - what's the result of the
53 first item vs the second item? */
54 extern RESULTTYPE RESULTOF[3][3];
56 /********** Bot Function definitions **********/
57 /* You need to provide implementations for these to create a bot */
59 /* Defend( foeName : string - the name of your foe;
60 foePromisedAttack : ITEMTYPE - the item your foe promised to use
61 ) : ITEMTYPE - the item you wish to use to defend;
63 Called when your agent needs to defend itself.
66 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
69 /* Attack( foeName : string - the name of your foe
70 ) : ATTACKTYPE - the real and promised attack you wish to use
72 Called when your agent needs to attack another agent.
75 ATTACKTYPE Attack( char * foeName );
78 /* Results( foeName : string - the name of your foe;
79 isInstigatedByYou : 0=you defended/1=you attacked;
80 yourItem : ITEMTYPE - the item you used;
81 theirItem : ITEMTYPE - the item they used;
82 promisedItem : ITEMTYPE - the item that was promised
85 Called after your agent battles another agent, to tell you how the battle goes.
88 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem,
89 ITEMTYPE theirItem, ITEMTYPE promisedItem);
93 Called when your agent is no longer needed, either due to the round ending
94 or due to your agent being eliminated.