X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=link%2FC%2Fc-link-lib%2Fc_link.h;fp=link%2FC%2Fc-link-lib%2Fc_link.h;h=08cdb63548b59512b66ef2087be4c607c3d2af91;hb=1740df9314f3dc49c6d44378c5915674aa1ab75f;hp=0000000000000000000000000000000000000000;hpb=fac40599d3ae604872ce34f3546a6c634183148f;p=progcomp10.git diff --git a/link/C/c-link-lib/c_link.h b/link/C/c-link-lib/c_link.h new file mode 100644 index 0000000..08cdb63 --- /dev/null +++ b/link/C/c-link-lib/c_link.h @@ -0,0 +1,73 @@ +/* + * c_link.h + * c-link-lib + * + * Created by Daniel Axtens on 19/04/10. + * Licensed under an MIT-style license: see the LICENSE file for details. + * + */ + +#define MAXCOMMANDLEN 15 +#define MAXFOENAMELEN 50 +#define MAXITEMLEN 10 +#define MAXBOOLLEN 6 + +/********** Type definitions **********/ + +/* The type of item used in an attack or defence */ +typedef enum {rock, paper, scissors} ITEMTYPE; + + +/* An attack, consisting of the real attack and the attack promised */ +typedef struct { + ITEMTYPE realAttack; + ITEMTYPE promisedAttack; +} ATTACKTYPE; + + +/********** Utility Function definitions **********/ +/* These are implemented in c-link.c, and automagically linked in */ + +/* Returns a random item */ + +ITEMTYPE RandomAttack(); + +/* A useful translation table + eg printf( "I use %s.\n", ITEMNAMES[rock] ); */ + +extern char ITEMNAMES[3][MAXITEMLEN]; + +/********** Bot Function definitions **********/ +/* You need to provide implementations for these to create a bot */ + +/* Defend( foeName : string - the name of your foe; + foePromisedAttack : ITEMTYPE - the item your foe promised to use + ) : ITEMTYPE - the item you wish to use to defend; + + Called when your agent needs to defend itself. + + */ +ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ); + + +/* Attack( foeName : string - the name of your foe + ) : ATTACKTYPE - the real and promised attack you wish to use + + Called when your agent needs to attack another agent. + + */ +ATTACKTYPE Attack( char * foeName ); + + +/* Results( foeName : string - the name of your foe; + isInstigatedByYou : 0=you defended/1=you attacked; + yourItem : ITEMTYPE - the item you used; + theirItem : ITEMTYPE - the item they used; + promisedItem : ITEMTYPE - the item that was promised + ); + + Called after your agent battles another agent, to tell you how the battle goes. + + */ +void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, + ITEMTYPE theirItem, ITEMTYPE promisedItem); \ No newline at end of file