c3bd87cf7e5851534ac6b9d53dccaa6623cbe566
[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 MAXRESULTLEN    10
16 #define MAXBOOLLEN              6
17
18 /********** Type definitions **********/
19
20 /* The type of item used in an attack or defence */
21 typedef enum {rock, paper, scissors} ITEMTYPE;
22
23 /* A result of a battle, in terms of who won */
24 typedef enum {attacker, defender, tie} RESULTTYPE;
25
26
27 /* An attack, consisting of the real attack and the attack promised */
28 typedef struct {
29         ITEMTYPE realAttack;
30         ITEMTYPE promisedAttack;
31 } ATTACKTYPE;
32
33
34 /********** Utility Function definitions **********/
35 /* These are implemented in c-link.c, and automagically linked in */
36
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) 
40  */
41
42 #define debugmsg(x...) fprintf(stderr, x)
43
44 /* A (hopefully) unique identifier for this particular instance of your agent,
45    to help with debugging */
46 int me;
47
48
49 /* Returns a random item */
50
51 ITEMTYPE RandomAttack();
52
53 /* A useful translation table
54    eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
55
56 extern char ITEMNAMES[3][MAXITEMLEN];
57
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];
61
62 /********** Bot Function definitions **********/
63 /* You need to provide implementations for these to create a bot */
64
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;
68  
69  Called when your agent needs to defend itself.
70  
71  */
72 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
73
74
75 /* Attack( foeName : string - the name of your foe
76                  ) : ATTACKTYPE - the real and promised attack you wish to use
77
78  Called when your agent needs to attack another agent.
79  
80  */
81 ATTACKTYPE Attack( char * foeName );
82
83
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.
91           );
92
93  Called after your agent battles another agent, to tell you how the battle goes.
94  
95  */
96 void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
97               ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
98               int pointDelta );
99
100 /* Cleanup();
101
102    Called when your agent is no longer needed, either due to the round ending
103    or due to your agent being eliminated.
104
105  */
106 void Cleanup();

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