#!/usr/bin/python import mariosolver import Gnuplot mariosolver.setupSpaces() g = Gnuplot.Gnuplot() g('set data style lines') g('set xrange[94:0]') tempFile = open('temp2', 'w') spaces = range(95) #spaces.reverse() for space in spaces: (n, d) = mariosolver.getProbabilityOfSuccess(space, 0, (True, True), frozenset()) (n1, d1) = mariosolver.getProbabilityOfSuccess(space, 5, (True, True), frozenset()) (n2, d2) = mariosolver.getProbabilityOfSuccess(space, 10, (True, True), frozenset()) (n3, d3) = mariosolver.getProbabilityOfSuccess(space, 15, (True, True), frozenset()) (n4, d4) = mariosolver.getProbabilityOfSuccess(space, 20, (True, True), frozenset()) tempFile.write('%d %.10f %.10f %.10f %.10f %.10f\n' % (space, n/d, n1/d1, n2/d2, n3/d3, n4/d4)) tempFile.close() g('set terminal png medium size 800, 600') g('set output "plotspace.png"') g('set ylabel "Probability of winning this turn"') g('set xlabel "Starting square (squares away from princess)"') g('set grid ytics') g('set key left top') #g('set style line 10 linecolor black') #g('set style arrow 10 linestyle 10 nohead') g('set arrow from 22, graph 0 to 22, graph 1 nohead linetype -1') g('set arrow from 46, graph 0 to 46, graph 1 nohead linetype -1') g('set arrow from 70, graph 0 to 70, graph 1 nohead linetype -1') g('set arrow from 1, graph 0 to 1, graph 1 nohead linetype 0') g('set arrow from 6, graph 0 to 6, graph 1 nohead linetype 0') g('set arrow from 12, graph 0 to 12, graph 1 nohead linetype 0') g('set arrow from 15, graph 0 to 15, graph 1 nohead linetype 0') g('set arrow from 20, graph 0 to 20, graph 1 nohead linetype 0') g('set arrow from 56, graph 0 to 56, graph 1 nohead linetype 0') g('set arrow from 58, graph 0 to 58, graph 1 nohead linetype 0') g('set arrow from 66, graph 0 to 66, graph 1 nohead linetype 0') g('set label "World 1" at 85, 0.85') g('set label "World 2" at 61, 0.95') g('set label "World 3" at 37, 0.95') g('set label "World 4" at 13, 0.95') g('plot "temp2" using 1:2 title "0 coins", "temp2" using 1:3 title "5 coins", "temp2" using 1:4 title "10 coins", "temp2" using 1:5 title "15 coins", "temp2" using 1:6 title "20 coins"')