Git Product home page Git Product logo

minigame's Introduction

Build Status

MiniGame

Simplistic Game Theory Library in Ruby

Installation

gem install minigame

Usage:

To create new players:

employer = Player.new name: "IBM"
employee = Player.new name: "John Smith

To create a new list of strategies for all players in a game:

strategies = Strategy.new [{name: "Accept Training"}, 
                           {name: "Generic Training"},
                           {name: "Task Specific Training"},
                           {name: "Deny Training"}]

To create new StrategyProfiles:


# Regular training game -- generic strictly dominated
# 
#      Employer:            | Task Specific       |    Generic
# Employee:  ---------------|---------------------|------------------
#                           |                     |
#   Deny Training           |  (-2, 0)            |     (-2, -1)
#   ------------------------|---------------------|------------------
#   Accept Training         |  (1, 4)             |     (5, -2)
#   ------------------------|---------------------|------------------
strategy_profile = StrategyProfile.new
strategy_profile << {id: 1, strategy: generic, payoff: -2, player: employer}
strategy_profile << {id: 1, strategy: accept, payoff: 5, player: employee}

strategy_profile << {id: 2, strategy: generic, payoff: -1, player: employer}
strategy_profile << {id: 2, strategy: deny, payoff: -2, player: employee}

strategy_profile << {id: 3, strategy: task, payoff: 0, player: employer}
strategy_profile << {id: 3, strategy: deny, payoff: -2, player: employee}

strategy_profile << {id: 4, strategy: task, payoff: 4, player: employer}
strategy_profile << {id: 4, strategy: accept, payoff: 1, player: employee}

To create a new game:

gs = Game.new
gs.strategy_profiles = strategy_profile

To get the list of strictly dominated strategies:

gs.strictly_dominated_list

  [{:name=>"Generic Training"}, {:name=>"Deny Training"}]

To get the list a weakly dominated strategies:

# training game -- generic weakly dominated (not realistic)
# 
#      Employer:            | Task Specific       |    Generic
# Employer: ----------------|---------------------|------------------
#                           |                     |
#   Deny Training           |  (-2, -1)           |     (-2, -1)
#   ------------------------|---------------------|------------------
#   Accept Training         |  (1, 4)             |     (5, -2)
#   ------------------------|---------------------|------------------
gs.weakly_dominated_list

  [{:name=>"Generic Training"}]

To get the list strategy profiles that are nash equilibria:

gs.nash 

  [["Accept Training", "Task Specific Training"]]

minigame's People

Contributors

wavell avatar

Stargazers

Roman avatar Chris Olstrom avatar acevedog avatar

Watchers

 avatar James Cloos avatar

Forkers

joker16312 taylor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.