Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
154 | pmbaty | 1 | #!/usr/bin/perl -w |
2 | # |
||
3 | # Announce a move from Crafty using some soundfiles |
||
4 | # |
||
5 | |||
6 | # The move sent by crafty |
||
7 | my $move = $ARGV[0]; |
||
8 | |||
9 | # First check some specials |
||
10 | if ($move eq "O-O") { |
||
11 | system("say castle king side"); |
||
12 | } |
||
13 | elsif ($move eq "O-O-O") { |
||
14 | system("say castle queen side"); |
||
15 | } |
||
16 | elsif ($move eq "Stalemate") { |
||
17 | system("say stalemate"); |
||
18 | } |
||
19 | elsif ($move eq "Drawaccept") { |
||
20 | system("say I accept your draw offer"); |
||
21 | } |
||
22 | elsif ($move eq "Drawdecline") { |
||
23 | system("say I decline your draw offer"); |
||
24 | } |
||
25 | elsif ($move eq "Drawoffer") { |
||
26 | system("say I offer a draw"); |
||
27 | } |
||
28 | elsif ($move eq "Resign") { |
||
29 | system("say I resign"); |
||
30 | } |
||
31 | elsif ($move eq "Checkmate") { |
||
32 | system("say checkmate"); |
||
33 | } |
||
34 | # Handle all normal moves. All that needs to be done is announce |
||
35 | # each character sent by crafty alone. Set some pause beteween each |
||
36 | # char for clearer understanding. |
||
37 | # |
||
38 | # NOTE 1: Crafty uses short notation, so short notation is |
||
39 | # announced. For long notation announcements the crafty engine has |
||
40 | # to be hacked and pgn output as well as logging would get broken. |
||
41 | # |
||
42 | # NOTE 2: There has to exist a sound file named for each row, |
||
43 | # column and piece. That is there has to be sound files like a.wav, |
||
44 | # 1.wav, R.wav and so on. One can easily rename the files |
||
45 | # distributed for free eg. at the "Arena" Website |
||
46 | # (http://www.playwitharena.com). Soundfiles from Fritz are not |
||
47 | # suitable, at the moment, but the script can easily be rewritten |
||
48 | # to handle them as well. |
||
49 | else { |
||
50 | for (my $i=0; $i<length($move); $i++) { |
||
51 | my $char = substr $move, $i, 1; |
||
52 | if ($char =~ /[^=]/) { |
||
53 | if ($char =~ /x/) { |
||
54 | system("say takes"); |
||
55 | } |
||
56 | elsif ($char =~ /#/) { |
||
57 | system("say checkmate"); |
||
58 | } |
||
59 | elsif ($char =~ /\+/) { |
||
60 | system("say check"); |
||
61 | } |
||
62 | elsif ($char eq "B") { |
||
63 | system("say bishop"); |
||
64 | } |
||
65 | elsif ($char eq "K") { |
||
66 | system("say king"); |
||
67 | } |
||
68 | elsif ($char eq "N") { |
||
69 | system("say knight"); |
||
70 | } |
||
71 | elsif ($char eq "P") { |
||
72 | system("say pawn"); |
||
73 | } |
||
74 | elsif ($char eq "Q") { |
||
75 | system("say queen"); |
||
76 | } |
||
77 | elsif ($char eq "R") { |
||
78 | system("say rook"); |
||
79 | } |
||
80 | else { |
||
81 | system("say $char"); |
||
82 | } |
||
83 | } |
||
84 | } |
||
85 | } |