Implemented C I/O
[progcomp10.git] / link / C / Link / 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 #define MAXCOMMANDLEN   15
11 #define MAXFOENAMELEN   50
12 #define MAXITEMLEN              10
13 #define MAXBOOLLEN              6
14
15 /********** Type definitions **********/
16
17 /* The type of item used in an attack or defence */
18 typedef enum {rock, paper, scissors} ITEMTYPE;
19
20
21 /* An attack, consisting of the real attack and the attack promised */
22 typedef struct {
23         ITEMTYPE realAttack;
24         ITEMTYPE promisedAttack;
25 } ATTACKTYPE;
26
27
28 /********** Utility Function definitions **********/
29 /* These are implemented in c-link.c, and automagically linked in */
30
31 /* Returns a random item */
32
33 ITEMTYPE RandomAttack();
34
35 /* A useful translation table
36    eg printf( "I use %s.\n", ITEMNAMES[rock] ); */
37
38 extern char ITEMNAMES[3][MAXITEMLEN];
39
40 /********** Bot Function definitions **********/
41 /* You need to provide implementations for these to create a bot */
42
43 /* Defend( foeName : string - the name of your foe;
44            foePromisedAttack : ITEMTYPE - the item your foe promised to use
45          ) : ITEMTYPE - the item you wish to use to defend;
46  
47  Called when your agent needs to defend itself.
48  
49  */
50 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
51
52
53 /* Attack( foeName : string - the name of your foe
54                  ) : ATTACKTYPE - the real and promised attack you wish to use
55
56  Called when your agent needs to attack another agent.
57  
58  */
59 ATTACKTYPE Attack( char * foeName );
60
61
62 /* Results( foeName : string - the name of your foe;
63             isInstigatedByYou : 0=you defended/1=you attacked;
64                         yourItem : ITEMTYPE - the item you used;
65             theirItem : ITEMTYPE - the item they used;
66             promisedItem : ITEMTYPE - the item that was promised
67           );
68
69  Called after your agent battles another agent, to tell you how the battle goes.
70  
71  */
72 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, 
73                           ITEMTYPE theirItem, ITEMTYPE promisedItem);

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