Work towards C SDK (#11). Frenchie is still broken.
[progcomp10.git] / src / link / C / c_link.h
1 /*
2  *  c_link.h
3  *  c-link-lib
4  *
5  *  Created by Daniel Axtens on 19/04/10.
6  *  Licensed under an MIT-style license: see the LICENSE file for details.
7  *
8  */
9
10 #include <stdio.h>
11
12 #define MAXCOMMANDLEN   15
13 #define MAXFOENAMELEN   50
14 #define MAXITEMLEN              10
15 #define MAXBOOLLEN              6
16
17 /********** Type definitions **********/
18
19 /* The type of item used in an attack or defence */
20 typedef enum {rock, paper, scissors} ITEMTYPE;
21
22 /* A result of a battle */
23 typedef enum {win, lose, tie} RESULTTYPE;
24
25
26 /* An attack, consisting of the real attack and the attack promised */
27 typedef struct {
28         ITEMTYPE realAttack;
29         ITEMTYPE promisedAttack;
30 } ATTACKTYPE;
31
32
33 /********** Utility Function definitions **********/
34 /* These are implemented in c-link.c, and automagically linked in */
35
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) 
39  */
40
41 #define debugmsg(x...) fprintf(stderr, x)
42
43 /* A (hopefully) unique identifier for this particular instance of your agent,
44    to help with debugging */
45 int me;
46
47
48 /* Returns a random item */
49
50 ITEMTYPE RandomAttack();
51
52 /* A useful translation table
53    eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
54
55 extern char ITEMNAMES[3][MAXITEMLEN];
56
57 /* Another useful table - what's the result of the 
58    first item vs the second item? */
59 extern RESULTTYPE RESULTOF[3][3];
60
61 /********** Bot Function definitions **********/
62 /* You need to provide implementations for these to create a bot */
63
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;
67  
68  Called when your agent needs to defend itself.
69  
70  */
71 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
72
73
74 /* Attack( foeName : string - the name of your foe
75                  ) : ATTACKTYPE - the real and promised attack you wish to use
76
77  Called when your agent needs to attack another agent.
78  
79  */
80 ATTACKTYPE Attack( char * foeName );
81
82
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
88           );
89
90  Called after your agent battles another agent, to tell you how the battle goes.
91  
92  */
93 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, 
94                           ITEMTYPE theirItem, ITEMTYPE promisedItem);
95
96 /* Cleanup();
97
98    Called when your agent is no longer needed, either due to the round ending
99    or due to your agent being eliminated.
100
101  */
102 void Cleanup();

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