rockemsockemrationalagents

find nash equilibrium with fictitious play
git clone https://wehaveforgeathome.hates.computer/rockemsockemrationalagents.git
Log | Files | Refs | LICENSE

commit 9ecd5fff35eb5917e2b3358fda1b092e4e7d5ba2
parent a04a9612c126be62f0531dae50597f8f799b86d7
Author: Ryan Wolf <rwolf@borderstylo.com>
Date:   Wed,  3 Mar 2010 00:15:09 -0800

broke distribution up

Diffstat:
Mresera.pl | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/resera.pl b/resera.pl @@ -62,18 +62,20 @@ printf("Player Row:\t(%.0f%%, %.0f%%)\n", ($choices->[1][0] / $iterations) * 100, ($choices->[1][1] / $iterations) * 100); +sub p_of_first_choice { + my ($n_chose_first, $n_chose_second) = @_; + my $total_choices = $n_chose_first + $n_chose_second; + if ($total_choices == 0) { + return .5; + } + return $n_chose_first / $total_choices; +} + sub distributions { my $choices = shift; - # if no one has picked anything, guess - if ($choices->[0][0] + $choices->[0][1] == 0 || - $choices->[1][0] + $choices->[1][1] == 0) { - return [.5,.5]; - } return [ - $choices->[0][0] / - ($choices->[0][0] + $choices->[0][1]), - $choices->[1][0] / - ($choices->[1][0] + $choices->[1][1]) + p_of_first_choice($choices->[0][0], $choices->[0][1]), + p_of_first_choice($choices->[1][0], $choices->[1][1]) ]; }