@@ -25,6 +25,7 @@ parser.add_option('-d','--deterministic',action='store_true',help="switch to det
2525parser .add_option ('-n' ,type = int ,default = 10 ,help = "number of samples to plot" )
2626parser .add_option ('-v' ,'--verbose' ,action = 'store_true' ,help = "print or plot extra information" )
2727parser .add_option ('-p' ,'--profile' ,action = 'store_true' ,help = "skip plotting for profiling purposes" )
28+ parser .add_option ('-t' ,'--type' ,type = str ,help = "type of plot to show" )
2829options ,args = parser .parse_args ()
2930if len (args ): parser .error ('zero arguments expected' )
3031
@@ -678,6 +679,19 @@ elif options.variable or options.bets:
678679 print "\n Bob's strategy:"
679680 for i ,b in enumerate (bets ):
680681 print ' b%g : %s' % (b ,'' .join (times (bob [i ,k ],hands [k ]) for k in order ))
682+ if options .type :
683+ import pylab
684+ if options .type == 'p' :
685+ pb = sum (approx_hand_prob .reshape (1 ,- 1 )* alice ,axis = 1 )
686+ pb = hstack ([1 - pb .sum (),pb ])
687+ pylab .bar (hstack ([- 2 ,bets ])- .5 ,pb )
688+ pylab .xlim (- 1 ,bets .max ())
689+ pylab .xlabel ('action: raise amount or -1 for fold' )
690+ pylab .ylabel ('probability' )
691+ pylab .title ("Alice's probability of each action" )
692+ pylab .show ()
693+ else :
694+ raise RuntimeError ("unknown plot type '%s'" % options .type )
681695else :
682696 equity ,alice ,bob = poker_nash_equilibrium (bet )
683697 print "Alice's exact payoff = %s (%g)" % (equity ,equity )
0 commit comments