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
15 #define MAXRESULTLEN 10
18 /********** Type definitions **********/
20 /* The type of item used in an attack or defence */
21 typedef enum {rock, paper, scissors} ITEMTYPE;
23 /* A result of a battle, in terms of who won */
24 typedef enum {attacker, defender, tie} RESULTTYPE;
27 /* An attack, consisting of the real attack and the attack promised */
30 ITEMTYPE promisedAttack;
34 /********** Utility Function definitions **********/
35 /* These are implemented in c-link.c, and automagically linked in */
37 /* prints a debug message. Same arguments as printf().
38 (you can't use printf because it is used to talk between
39 the agent and supervisor)
42 #define debugmsg(x...) fprintf(stderr, x)
44 /* A (hopefully) unique identifier for this particular instance of your agent,
45 to help with debugging */
49 /* Returns a random item */
51 ITEMTYPE RandomAttack();
53 /* A useful translation table
54 eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
56 extern char ITEMNAMES[3][MAXITEMLEN];
58 /* Another useful table - who's the victor given an
59 attacker with first item vs defender with the second item? */
60 extern RESULTTYPE RESULTOF[3][3];
62 /********** Bot Function definitions **********/
63 /* You need to provide implementations for these to create a bot */
65 /* Defend( foeName : string - the name of your foe;
66 foePromisedAttack : ITEMTYPE - the item your foe promised to use
67 ) : ITEMTYPE - the item you wish to use to defend;
69 Called when your agent needs to defend itself.
72 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
75 /* Attack( foeName : string - the name of your foe
76 ) : ATTACKTYPE - the real and promised attack you wish to use
78 Called when your agent needs to attack another agent.
81 ATTACKTYPE Attack( char * foeName );
84 /* Results( foeName : string - the name of your foe;
85 isInstigatedByYou : 0=you defended/1=you attacked;
86 winner : RESULTTYPE - who won
87 attItem : ITEMTYPE - the item used to attack;
88 defItem : ITEMTYPE - the item used to defend;
89 bluffItem : ITEMTYPE - the item that was promised
90 pointDelta : integer - how your points were affected.
93 Called after your agent battles another agent, to tell you how the battle goes.
96 void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
97 ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
102 Called when your agent is no longer needed, either due to the round ending
103 or due to your agent being eliminated.