First attempt at a matlab link.
[progcomp10.git] / src / link / MATLAB / matlab-link.m
1 #
2 # matlab-link.m
3 # matlab-link
4 #
5 # Created by Daniel Axtens on 28/07/10.
6 # Licensed under an MIT-style license: see the LICENSE file for details.
7 #
8
9 # You don't need to read this file. All you need to do is take agent-template.m
10 # and fill it in with your own functions. This file does all the I/O for you,
11 # and matlab-consts.m defines useful utilities and constants.
12 #
13 # Do not depend on the contents of this file. It may be changed for speed, security
14 # or other reasons and your bot may break if you depend on it. You have been warned.
15
16 in = input("","s");
17
18 while ( !strcmp( "BYE", in ) )
19
20         splitIn = strsplit( in, " " );
21
22         switch splitIn{1}
23
24                 case "ATTACK"
25                         [attack, bluff] = Attack( splitIn{2} );
26                         
27                         disp( [ "ATTACKING ", rps.itemToString{attack}, " ", \
28                                   rps.itemToString{bluff} ] );
29
30                 case "DEFEND"
31                         defence = Defend( splitIn{2}, stringToItem(splitIn{3}) );
32                         disp( [ "DEFENDING ", rps.itemToString{defence} ] );
33
34                 case "RESULTS"
35                         Results( splitIn{2}, strcmp( splitIn{3}, "True" ), splitIn{4}, \
36                                          stringToItem(splitIn{5}), stringToItem(splitIn{6}), \
37                                          stringToItem(splitIn{7}), str2num(splitIn{8}) );
38
39                         disp( "OK" );
40
41         endswitch
42
43         fflush(stdout);
44         fflush(stderr);
45
46         in = input("","s");
47
48
49 endwhile

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