cleanup
[progcomp10.git] / link / C / Link / c-link-lib / sample-agents / c-streetfighter.c
1 /*
2  *  c-streetfighter.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 streetfighter bot, which thinks everyone has it in for him. */
14
15 ATTACKTYPE Attack( char * foe_name ) {
16         ATTACKTYPE attack;
17         
18         attack.realAttack =  RandomAttack();
19         
20         /* Here we choose the thing that will hurt them if they go for a tie */
21         switch (attack.realAttack) {
22                 case rock:
23                         result.promisedAttack = paper;
24                         break;
25                 case paper:
26                         result.promisedAttack = rock;
27                         break;
28                 default: /* attack = scissors */
29                         result.promisedAttack = paper;
30                         break;
31         }
32         attack.promisedAttack = result.realAttack;      /* Tells the truth for its bluff */
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 }
52
53 /* You need to define a results function, even if it isn't used
54  (otherwise the linker will complain) */
55 void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, 
56                          ITEMTYPE theirItem, ITEMTYPE promisedItem) {
57         
58         return; /* Ignore whatever just happened. */
59 }

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