adfb2ba5a8e0942b983cd98073f467d58a4fdb07
[progcomp10.git] / link / C / c-link-lib / 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                         result.promisedAttack = scissors;
25                         break;
26                 case paper:
27                         result.promisedAttack = rock;
28                         break;
29                 default: /* attack = scissors */
30                         result.promisedAttack = paper;
31                         break;
32         }
33         attack.promisedAttack = result.realAttack;      /* Tells the truth for its bluff */
34         
35         return attack;
36 }
37
38 /* Here we trust that they are telling the truth. And we try to kill them. */
39 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) {
40         ITEMTYPE defence;
41         switch (foePromisedAttack) {
42                 case rock:
43                         defence = paper;
44                         break;
45                 case paper:
46                         defence = scissors;
47                         break;
48                 default:
49                         defence = rock;
50                         break;
51         }
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 }

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