-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
executable file
·71 lines (64 loc) · 1.84 KB
/
script.sh
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
#!/bin/bash
EXPECTED_ARGS=2
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {output file start} {number of games to play}"
exit $E_BADARGS
fi
output=$1
games=$2
cd game
make
cd ../
./blackjack -g $games -dump $output
array=(no-usable usable)
ending=(dat)
for item in ${array[*]}
do
for type in ${ending[*]}
do
name=$output-$item.$type
echo "reset
set term postscript
set output \"./results/graphs/$name.ps\"
set dgrid3d 10,10
set palette defined (0 0 0 0, 1 0 0 1, 3 0 1 0, 4 1 0 0, 6 1 1 1)
set xtics ('A' 0, '2' 1, '3' 2, '4' 3, '5' 4, '6' 5, '7' 6, '8' 7, '9' 8, '10' 9)
set xlabel 'Dealer Reveals'
set ylabel 'Player Sum'
set ytics ('12' 0, '13' 1, '14' 2, '15' 3, '16' 4 , '17' 5, '18' 6, '19' 7, '20' 8, '21' 9)
set nokey
set title '$output $item ace, Probability'
splot '$name' using 2:1:3 with lines pal" | gnuplot
convert ./results/graphs/$name.ps -rotate 90 ./results/graphs/$name.png
rm ./results/graphs/$name.ps
done
done
ending=(datpol)
for item in ${array[*]}
do
for type in ${ending[*]}
do
name=$output-$item.$type
echo "reset
set term postscript
set output \"./results/graphs/$name.ps\"
set dgrid3d 10,10
set palette model RGB
set palette model RGB defined (0 \"blue\", 0 'dark-blue', 1 \"white\", 2 \"white\", 3 \"dark-red\", 3 'red' )
set xtics ('A' 0, '2' 1, '3' 2, '4' 3, '5' 4, '6' 5, '7' 6, '8' 7, '9' 8, '10' 9)
set xlabel 'Dealer Reveals'
set ylabel 'Player Sum' rotate by 270
set ytics ('12' 0, '13' 1, '14' 2, '15' 3, '16' 4 , '17' 5, '18' 6, '19' 7, '20' 8, '21' 9)
set view 0,0
set pm3d
set nokey
set title '$output $item ace, Policy'
splot '$name' using 2:1:3 with points pal" | gnuplot
convert ./results/graphs/$name.ps -rotate 90 ./results/graphs/$name.png
rm ./results/graphs/$name.ps
done
done
mv *.dat ./results/
mv *.datpol ./results/