X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Flink%2FC%2Fc-link-lib%2Fagents%2Fc-streetfighter.c;fp=src%2Flink%2FC%2Fc-link-lib%2Fagents%2Fc-streetfighter.c;h=c63939d1267de91274731dfde78955fe56a106b6;hb=e9a8105a8f22404f4ac550d79954eaa6b7f5d8ff;hp=0000000000000000000000000000000000000000;hpb=4597b27a44522a5c2785cc23029435f44f60ea55;p=progcomp10.git diff --git a/src/link/C/c-link-lib/agents/c-streetfighter.c b/src/link/C/c-link-lib/agents/c-streetfighter.c new file mode 100644 index 0000000..c63939d --- /dev/null +++ b/src/link/C/c-link-lib/agents/c-streetfighter.c @@ -0,0 +1,63 @@ +/* + * c-streetfighter.c + * c-link-lib + * + * Created by Daniel Axtens on 20/04/10. + * Licensed under an MIT-style license: see the LICENSE file for details. + * + */ + + +#include + +/* Implement the streetfighter bot, which thinks everyone has it in for him. */ + +ATTACKTYPE Attack( char * foe_name ) { + ATTACKTYPE attack; + + attack.realAttack = RandomAttack(); + + /* Here we choose the thing that will hurt them if they go for the kill */ + switch (attack.realAttack) { + case rock: + result.promisedAttack = paper; + break; + case paper: + result.promisedAttack = scissors; + break; + default: /* attack = scissors */ + result.promisedAttack = rock; + break; + } + return attack; +} + +/* Here we assume they are lying, trying to kill us. And we try to kill them. */ +ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) { + ITEMTYPE defence; + switch (foePromisedAttack) { + case rock: + defence = scissors; + break; + case paper: + defence = rock; + break; + default: + defence = paper; + break; + } +} + +/* You need to define a results function, even if it isn't used + (otherwise the linker will complain) */ +void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, + ITEMTYPE theirItem, ITEMTYPE promisedItem) { + + return; /* Ignore whatever just happened. */ +} + +/* same for Cleanup() */ + +void Cleanup() { + return; +}