Attempt at fixing memory mess.
[progcomp10.git] / src / link / C / agents / c_streetfighter.c
1 /*\r
2  *  c_streetfighter.c\r
3  *  c-link-lib\r
4  *\r
5  *  Created by Daniel Axtens on 20/04/10.\r
6  *  Licensed under an MIT-style license: see the LICENSE file for details.\r
7  *\r
8  */\r
9 \r
10 \r
11 #include <c_link.h>\r
12 \r
13 /* Implement the streetfighter bot, which thinks everyone has it in for him. */\r
14 \r
15 void * Initialise( char * myName ) {\r
16         return NULL;\r
17 }\r
18 \r
19 ATTACKTYPE Attack( void * this, char * foe_name ) {\r
20         ATTACKTYPE attack;\r
21         \r
22         attack.realAttack =  RandomAttack();\r
23         \r
24         /* Here we choose the thing that will hurt them if they go for the kill */\r
25         switch (attack.realAttack) {\r
26                 case rock:\r
27                         attack.promisedAttack = paper;\r
28                         break;\r
29                 case paper:\r
30                         attack.promisedAttack = scissors;\r
31                         break;\r
32                 default: /* attack = scissors */\r
33                         attack.promisedAttack = rock;\r
34                         break;\r
35         }\r
36         return attack;\r
37 }\r
38 \r
39 /* Here we assume they are lying, trying to kill us. And we try to kill them. */\r
40 ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack ) {\r
41         ITEMTYPE defence;\r
42         switch (foePromisedAttack) {\r
43                 case rock:\r
44                         defence = scissors;\r
45                         break;\r
46                 case paper:\r
47                         defence = rock;\r
48                         break;\r
49                 default:\r
50                         defence = paper;\r
51                         break;\r
52         }\r
53     return defence;\r
54 }\r
55 \r
56 /* You need to define a results function, even if it isn't used\r
57  (otherwise the linker will complain) */\r
58 void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,\r
59              ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,\r
60              int pointDelta ) {\r
61         \r
62         return; /* Ignore whatever just happened. */\r
63 }\r
64 \r
65 /* same for Cleanup() */\r
66 \r
67 void Cleanup( void * this ) {\r
68         return;\r
69 }\r

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