cleanup
[progcomp10.git] / src / link / C / c-link-lib / 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...) sprintf(stderr, x)
42
43 /* Returns a random item */
44
45 ITEMTYPE RandomAttack();
46
47 /* A useful translation table
48    eg printf( "I use %s.\n", ITEMNAMES[rock] ); */
49
50 extern char ITEMNAMES[3][MAXITEMLEN];
51
52 /* Another useful table - what's the result of the 
53    first item vs the second item? */
54 extern RESULTTYPE RESULTOF[3][3];
55
56 /********** Bot Function definitions **********/
57 /* You need to provide implementations for these to create a bot */
58
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;
62  
63  Called when your agent needs to defend itself.
64  
65  */
66 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
67
68
69 /* Attack( foeName : string - the name of your foe
70                  ) : ATTACKTYPE - the real and promised attack you wish to use
71
72  Called when your agent needs to attack another agent.
73  
74  */
75 ATTACKTYPE Attack( char * foeName );
76
77
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
83           );
84
85  Called after your agent battles another agent, to tell you how the battle goes.
86  
87  */
88 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, 
89                           ITEMTYPE theirItem, ITEMTYPE promisedItem);
90
91 /* Cleanup();
92
93    Called when your agent is no longer needed, either due to the round ending
94    or due to your agent being eliminated.
95
96  */
97 void Cleanup();

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