Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f007836

Browse files
committed
Add one plot output for variable bet equilibria
1 parent 7ed8d81 commit f007836

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

heads-up

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ parser.add_option('-d','--deterministic',action='store_true',help="switch to det
2525
parser.add_option('-n',type=int,default=10,help="number of samples to plot")
2626
parser.add_option('-v','--verbose',action='store_true',help="print or plot extra information")
2727
parser.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")
2829
options,args = parser.parse_args()
2930
if len(args): parser.error('zero arguments expected')
3031

@@ -678,6 +679,19 @@ elif options.variable or options.bets:
678679
print "\nBob'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)
681695
else:
682696
equity,alice,bob = poker_nash_equilibrium(bet)
683697
print "Alice's exact payoff = %s (%g)"%(equity,equity)

0 commit comments

Comments
 (0)