NAME

Game::Theory::TwoPersonMatrix - Analyze a 2 person matrix game

VERSION

version 0.1902

SYNOPSIS

use Game::Theory::TwoPersonMatrix;
$g = Game::Theory::TwoPersonMatrix->new(
   1 => { 1 => 0.2, 2 => 0.3, 3 => 0.5 },
   2 => { 1 => 0.1, 2 => 0.7, 3 => 0.2 },
   payoff => [ [-5, 4, 6],
               [ 3,-2, 2],
               [ 2,-3, 1] ]
};
$g->row_reduce();
$g->col_reduce();
$p = $g->saddlepoint();
$o = $g->oddments();
$e = $g->expected_payoff();
$c = $g->counter_strategy($player);
$u = $g->play();

$g = Game::Theory::TwoPersonMatrix->new(
   1 => { 1 => 0.1, 2 => 0.2, 3 => 0.7 },
   2 => { 1 => 0.1, 2 => 0.2, 3 => 0.3, 4 => 0.4 },
   payoff1 => [ [5,3,8,2],[6,5,7,1],[7,4,6,0] ],
   payoff2 => [ [2,0,1,3],[3,4,4,1],[5,6,8,2] ],
);
$t = $g->mm_tally();
$m = $g->pareto_optimal();
$n = $g->nash();
$e = $g->expected_payoff();
$c = $g->counter_strategy($player);
$u = $g->play();

DESCRIPTION

A Game::Theory::TwoPersonMatrix analyzes a two person matrix game of player names, strategies and utilities ("payoffs").

Players 1 and 2 are the "row" and "column" players, respectively. This is due to the tabular format of a matrix game:

                 Player 2
                 --------
        Strategy 0.5  0.5
Player |   0.5    1   -1  < Payoff
   1   |   0.5   -1    1  <

A non-zero sum game is represented by two payoff profiles, as above in the SYNOPSIS.

METHODS

new()

$g = Game::Theory::TwoPersonMatrix->new(
   1 => { 1 => '0.5', 2 => '0.5' },
   2 => { 1 => '0.5', 2 => '0.5' },
   payoff => [ [1,0],
               [0,1] ]
);
$g = Game::Theory::TwoPersonMatrix->new(
   payoff1 => [ [2,3],[2,1] ],
   payoff2 => [ [3,5],[2,3] ],
);

Create a new Game::Theory::TwoPersonMatrix object.

Player strategies are given by a hash reference of numbered keys - one for each strategy. Payoffs are given by array references of lists of outcomes. For zero-sum games this is a single payoff list. For non-zero-sum games this is given as two lists - one for each player.

expected_payoff()

$e = $g->expected_payoff();

Return the expected payoff value of a game.

s_expected_payoff()

$g = Game::Theory::TwoPersonMatrix->new(
   1 => { 1 => '(1 - p)', 2 => 'p' },
   2 => { 1 => 1, 2 => 0 },
   payoff => [ ['a','b'], ['c','d'] ]
);
$s = $g->s_expected_payoff();

Return the expected payoff expression for a non-numeric, zero-sum game.

Using real payoff values, we solve the resulting expression for p in the eg/ examples.

counter_strategy()

$c = $g->counter_strategy($player);

Return the counter-strategies for a given player of either a zero-sum or non-zero-sum game.

saddlepoint()

$p = $g->saddlepoint;

Return the saddlepoint of a zero-sum game, or undef if there is none.

oddments()

$o = $g->oddments();

Return each player's "oddments" for a 2x2 zero-sum game.

row_reduce()

$g->row_reduce();

Reduce a zero-sum game by identifying and eliminating strictly dominated rows and their associated player strategies.

col_reduce()

$g->col_reduce();

Reduce a zero-sum game by identifying and eliminating strictly dominated columns and their associated opponent strategies.

mm_tally()

$t = $g->mm_tally();

For zero-sum games, return the maximum of row minimums and the minimum of column maximums. For non-zero-sum games, return the maximum of row and column minimums.

pareto_optimal()

$m = $g->pareto_optimal();

Return the Pareto optimal outcomes for a non-zero-sum game.

nash()

$n = $g->nash();

Identify the Nash equilibria in a non-zero-sum game.

Given payoff pair (a,b), a is maximum for its column and b is maximum for its row.

play

$u = $g->play();
$u = $g->play(\%strategies);

Return a single outcome for a zero-sum game or a pair for a non-zero-sum game.

An optional list of player strategies can be provided. This is a hashref of the same type of strategies that are given to the constructor.

SEE ALSO

The eg/ and t/ scripts in this distribution.

"A Gentle Introduction to Game Theory"

http://www.amazon.com/Gentle-Introduction-Theory-Mathematical-World/dp/0821813390

http://books.google.com/books?id=8doVBAAAQBAJ

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.