rockemsockemrationalagents

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

commit 4b1759af2d427432df0cf5ad840e4f82d166203d
parent 2e262658db95d328871d6f09180cba7ee56218ed
Author: Ryan Wolf <rwolf@borderstylo.com>
Date:   Tue,  2 Mar 2010 15:50:02 -0800

cleaned up formatting

Diffstat:
MREADME.md | 1-
Mresera.pl | 27++++++++++-----------------
2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md @@ -37,4 +37,3 @@ TODO * expand summary * there's a lot of room to optimise (precomputing $a-$b-$c+$d instead of finding it n times comes immediately to mind)--faster means more iterations -* add a fun license (maybe [WTFPL](http://en.wikipedia.org/wiki/Do_What_The_Fuck_You_Want_To_Public_License)?) diff --git a/resera.pl b/resera.pl @@ -15,10 +15,10 @@ if (scalar @ARGV == 8) { ]; } -my $pm = " Choice 1 | Choice 2\n" . - " -------------------\n" . - "Choice 1 | %d, %d | %d, %d\n" . - "Choice 2 | %d, %d | %d, %d\n\n"; +my $pm = " Choice 1 | Choice 2\n" . + " --------------------\n" . + "Choice 1 | %3d, %3d | %3d, %3d\n" . + "Choice 2 | %3d, %3d | %3d, %3d\n\n"; printf( $pm, $grid->[0][0][0], @@ -42,10 +42,10 @@ for (my $n = 0; $n < $iterations; $n++) { $choices->[1][$this_choice->[1]]++; } -printf("Player Column:\t(%f%%, %f%%)\n", +printf("Player Column:\t(%.0f%%, %.0f%%)\n", ($choices->[0][0] / $iterations) * 100, ($choices->[0][1] / $iterations) * 100); -printf("Player Row:\t(%f%%, %f%%)\n", +printf("Player Row:\t(%.0f%%, %.0f%%)\n", ($choices->[1][0] / $iterations) * 100, ($choices->[1][1] / $iterations) * 100); @@ -54,14 +54,6 @@ sub player_outcome { return $grid->[$row][$col][$player]; } -sub outcomes { - my ($row,$col,$grid) = @_; - return [ - player_outcome(0,$row,$col,$grid), - player_outcome(1,$row,$col,$grid) - ]; -} - sub player_slope { my ($player,$other_p,$grid) = @_; my $a = player_outcome($player,0,0,$grid); @@ -96,9 +88,10 @@ sub choice { foreach my $player (0,1) { my $other = ($player==0) ? 1 : 0; my $slope = player_slope( - $player, - $dist->[$other], - $grid); + $player, + $dist->[$other], + $grid + ); if ($slope > 0) { $this_choice->[$player] = 0; }