X-Git-Url: https://git.ucc.asn.au/?p=progcomp10.git;a=blobdiff_plain;f=src%2Flink%2FC%2Fagents%2Fc_streetfighter.c;fp=src%2Flink%2FC%2Fagents%2Fc_streetfighter.c;h=3ddf6973e2378d3d86bf1308f5b9f4f40dd824dc;hp=39a8cdab1999eb1c35beeb09da1a22a9fb25f556;hb=4f032479507641dacc772624c4a6b56a664fb249;hpb=699697dcaa730ccc26cd570cbf8975e2591344c0 diff --git a/src/link/C/agents/c_streetfighter.c b/src/link/C/agents/c_streetfighter.c old mode 100644 new mode 100755 index 39a8cda..3ddf697 --- a/src/link/C/agents/c_streetfighter.c +++ b/src/link/C/agents/c_streetfighter.c @@ -1,65 +1,69 @@ -/* - * 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: - attack.promisedAttack = paper; - break; - case paper: - attack.promisedAttack = scissors; - break; - default: /* attack = scissors */ - attack.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; - } - return defence; -} - -/* You need to define a results function, even if it isn't used - (otherwise the linker will complain) */ -void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner, - ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem, - int pointDelta ) { - - return; /* Ignore whatever just happened. */ -} - -/* same for Cleanup() */ - -void Cleanup() { - return; -} +/* + * 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. */ + +void * Initialise( char * myName ) { + return NULL; +} + +ATTACKTYPE Attack( void * this, 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: + attack.promisedAttack = paper; + break; + case paper: + attack.promisedAttack = scissors; + break; + default: /* attack = scissors */ + attack.promisedAttack = rock; + break; + } + return attack; +} + +/* Here we assume they are lying, trying to kill us. And we try to kill them. */ +ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack ) { + ITEMTYPE defence; + switch (foePromisedAttack) { + case rock: + defence = scissors; + break; + case paper: + defence = rock; + break; + default: + defence = paper; + break; + } + return defence; +} + +/* You need to define a results function, even if it isn't used + (otherwise the linker will complain) */ +void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner, + ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem, + int pointDelta ) { + + return; /* Ignore whatever just happened. */ +} + +/* same for Cleanup() */ + +void Cleanup( void * this ) { + return; +}