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