Update codebase to remove clang warnings (and a couple of legit errors
[typhoon.git] / src / play.sh
1 #!/bin/sh
2
3 # -----BEGIN EASILY CONFIGURABLE OPTIONS-------
4 bin='typhoon'
5 opts='--cpus 4 --hash 512m --logfile play.log --egtbpath /egtb/three;/egtb/four;/egtb/five'
6 dir='.'
7 ics='chessclub.com'
8 flags=''
9 # -----END EASILY CONFIGURABLE OPTIONS-------
10
11 usage() {
12   echo "Usage: $1 [--local | --icc | --fics] [--xdebug] [--edebug]"
13   echo ""
14   echo "--local and --icc toggle between playing locally against the engine and"
15   echo "playing the engine on an ICS server.  Playing locally is the default."
16   echo ""
17   echo "--xdebug enables debugging of the xboard protocol.  --edebug uses a debug"
18   echo "version of the chess engine."
19   echo ""
20   exit 1
21 }
22
23 play_locally() {
24   xboard -ponder -fcp "${bin} ${opts}" -fd ${dir} -xpopup -xexit -size medium \
25          -coords -highlight
26 }
27
28 attach_to_ics() {
29   while true; do
30     xboard -ics -icshost "${ics}" -ponder -fcp "${bin} ${opts}" -fd ${dir} \
31            -autoflag -xpopup -xexit -size medium -coords -highlight -zp \
32            ${flags}
33     sleep 30
34     killall typhoon
35   done
36 }
37
38 mode='local'
39 for _switch ; do
40   case $_switch in
41     --xdebug)
42       flags='-debug'
43       shift
44       ;;
45     --edebug)
46       bin='_typhoon'
47       shift
48       ;;
49     --local)
50       mode='local'
51       shift
52       ;;
53     --icc)
54       mode='ics'
55       shift
56       ;;
57     --fics)
58       mode='fics'
59       ics='freechess.org'
60       shift
61       ;;
62     *)
63       usage $0
64       ;;
65   esac
66 done
67
68 case ${mode} in
69   local)
70     play_locally
71     ;;
72   ics)
73     attach_to_ics
74     ;;
75   fics)
76     attach_to_ics
77     ;;
78 esac
79 exit 0