README
Math::GameTheory
The package provides descriptions and data of different games amenable for Game Theory experiments and studies.
Installation
From Zef ecosystem:
zef install Math::GameTheoryFrom GitHub:
zef install https://github.com/antononcube/Raku-Math-GameTheoryGame Theory data
All games known by the package "Math::GameTheory":
use Math::GameTheory;
say "Total number of known games: {game-theory-data().elems}";
game-theory-data()# Total number of known games: 52Games and their classes:
my @dsGames = game-theory-data(Whatever, property => "Classes").map({ $_.key X $_.value.Array }).flat(1).map({ <name property> Z=> $_ })».Hash;
@dsGames.elems# 153Here is a summary:
use Data::Summarizers;
sink records-summary(@dsGames)# +------------------+--------------------------+
# | property | name |
# +------------------+--------------------------+
# | MatrixGame => 42 | MatchingPennies => 5 |
# | 2Player => 26 | VolunteersDilemma => 5 |
# | Symmetric => 24 | RockPaperScissors => 5 |
# | NPlayer => 12 | PureCoordination => 5 |
# | Social => 10 | ZeroSumRandom => 5 |
# | TreeGame => 7 | PrisonersDilemma => 4 |
# | Recreation => 6 | 3Coordination => 4 |
# | (Other) => 26 | (Other) => 120 |
# +------------------+--------------------------+Here is a "taxonomy tree" like breakdown:
use ML::TriesWithFrequencies;
my %cat = <2Player 3Player NPlayer MatrixGame TreeGame Symmetric> Z=> (^7);
game-theory-data(Whatever, property => "Classes").values
==> { .map({ %cat.keys (&) $_ }) }()
==> { $_.map({ $_ ?? $_.keys !! 'Other' })».sort({ %cat{$_} })».List }()
==> trie-create()
==> trie-form()# TRIEROOT => 52
# ââ2Player => 26
# â ââMatrixGame => 25
# â â ââSymmetric => 14
# â ââNPlayer => 1
# â ââMatrixGame => 1
# ââ3Player => 3
# â ââMatrixGame => 3
# ââMatrixGame => 2
# ââNPlayer => 11
# â ââMatrixGame => 11
# â ââSymmetric => 8
# ââOther => 1
# ââSymmetric => 2
# ââTreeGame => 7Two player games
Get the game "Chicken" (provided by the package):
my $obj = game-theory-data('Chicken')# MatrixGame(:name("Chicken"), :number-of-players(2), :number-of-actions(("Player 1" => 2, "Player 2" => 2)))Here is a description of the game:
$obj.description# The name \"chicken\" has its origins in a dangerous game in which two drivers drive toward each other. Each driver has the choice to either continue or swerve. Either at least one driver swerves, or both may die in the crash. The driver who swerved will be called a chicken, meaning a coward.Here is game's table:
$obj.htmlHere is a gray-scale version of the dataset can be obtained with $obj.html(theme => 'gray-scale').
Three player games
Get the game "3Coordination" (provided by the package):
my $obj = game-theory-data('3Coordination')# MatrixGame(:name("3Coordination"), :number-of-players(3), :number-of-actions((:Roosevelt(3), :Stalin(3), :Churchill(3))))$obj.description# An extension of the coordination game where payoffs are based on the number of coordinated players.Here is game's table:
$obj.htmlZero sum games
Represent a Rock Paper Scissors game as a directed graph:
use Graph;
my $g = Graph.new(edges => [Rock => "Scissors", Scissors => "Paper", Paper => "Rock"]):d;
#$g.dot(engine => 'neato', :2size, vertex-font-size => 8):svg# Graph(vertexes => 3, edges => 3, directed => True)image izef_math_gametheory_dist_docs_img_rock_paper_scissors_graph_svg not found
Create a Rock Paper Scissors game:
use Data::Reshapers;
my @payoff-array = ($g.adjacency-matrix <<->> transpose($g.adjacency-matrix)).deepmap(-> Int:D $p { [$p, -$p] });
my $game = Math::GameTheory::MatrixGame.new(:@payoff-array, game-action-labels => ($g.vertex-list xx 2))# MatrixGame(:name(Whatever), :number-of-players(3), :number-of-actions(("Player 1" => 3, "Player 2" => 3)))Here is game's table:
$game.html(theme => 'default')TODO
TODO Implementation
DONE Games data JSON file and corresponding retrieval (multi-)sub
TODO Matrix games
DONE
MatrixGameclassDONE HTML format of matrix game dataset
DONE Wolfram Language (WL) representation
TODO Payoff functions
TODO Simpler zero-sum games initialization
TODO Tree games
TODO
TreeGameclassTODO Creation using WL's tree game input format
TODO Special tree-game plots
TODO Documentation
DONE Complete README
TODO Basic usage notebook
TODO Blog post
TODO Video demo