Work towards C SDK (#11). Frenchie is still broken.
[progcomp10.git] / src / link / C / agents / c_lucifer.c
1 /*
2  *  c_lucifer.c
3  *  c-link-lib
4  *
5  *  Created by Daniel Axtens on 20/04/10.
6  *  Licensed under an MIT-style license: see the LICENSE file for details.
7  *
8  */
9
10
11 #include <c_link.h>
12
13 /* Implement the lucifer bot, which always lies expecting people to be good
14    and always goes for the kill */
15
16 ATTACKTYPE Attack( char * foe_name ) {
17         ATTACKTYPE attack;
18         
19         attack.realAttack =  RandomAttack();
20         
21         /* Here we choose the thing that will hurt them if they go for a tie */
22         switch (attack.realAttack) {
23                 case rock:
24                         attack.promisedAttack = scissors;
25                         break;
26                 case paper:
27                         attack.promisedAttack = rock;
28                         break;
29                 default: /* attack = scissors */
30                         attack.promisedAttack = paper;
31                         break;
32         }
33         
34         return attack;
35 }
36
37 /* Here we trust that they are telling the truth. And we try to kill them. */
38 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) {
39         ITEMTYPE defence;
40         switch (foePromisedAttack) {
41                 case rock:
42                         defence = paper;
43                         break;
44                 case paper:
45                         defence = scissors;
46                         break;
47                 default:
48                         defence = rock;
49                         break;
50         }
51     return defence;
52 }
53
54 /* You need to define a results function, even if it isn't used
55  (otherwise the linker will complain) */
56 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, 
57                          ITEMTYPE theirItem, ITEMTYPE promisedItem) {
58         
59         return; /* Ignore whatever just happened. */
60 }
61
62 /* same for Cleanup() */
63
64 void Cleanup() {
65         return;
66 }

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