Replaced slow pexpect with subprocess.popen which is fast. Implemented Results()...
[progcomp10.git] / src / link / C / 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 the kill */
21         switch (attack.realAttack) {
22                 case rock:
23                         attack.promisedAttack = paper;
24                         break;
25                 case paper:
26                         attack.promisedAttack = scissors;
27                         break;
28                 default: /* attack = scissors */
29                         attack.promisedAttack = rock;
30                         break;
31         }
32         return attack;
33 }
34
35 /* Here we assume they are lying, trying to kill us. And we try to kill them. */
36 ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) {
37         ITEMTYPE defence;
38         switch (foePromisedAttack) {
39                 case rock:
40                         defence = scissors;
41                         break;
42                 case paper:
43                         defence = rock;
44                         break;
45                 default:
46                         defence = paper;
47                         break;
48         }
49     return defence;
50 }
51
52 /* You need to define a results function, even if it isn't used
53  (otherwise the linker will complain) */
54 void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
55              ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
56              int pointDelta ) {
57         
58         return; /* Ignore whatever just happened. */
59 }
60
61 /* same for Cleanup() */
62
63 void Cleanup() {
64         return;
65 }

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