Coder Social home page Coder Social logo

prisoners-dilemma's Introduction

Prisoners Dilemma Simulator

This is a simple Prisoners' Dilemma simulator, written in Haskell and published under the MIT license.

Overview

  • Pd.Master includes the main game logic. Its interface consists of play2, which simulates an iterated prisoners' dilemma with two agents, and playN, which takes n agents and simulates the same for each possible pair, summing up the scores.

  • Pd.Agents has some example agents, namely Always Cooperate, Always Defect and Tit for Tat.

Usage

So far, there is no user interface, you'll have to use ghci:

λ> :l Pd/Main.hs 
[1 of 4] Compiling Pd.Types         ( Pd/Types.hs, interpreted )
[2 of 4] Compiling Pd.Master        ( Pd/Master.hs, interpreted )
[3 of 4] Compiling Pd.Agents        ( Pd/Agents.hs, interpreted )
[4 of 4] Compiling Main             ( Pd/Main.hs, interpreted )
Ok, modules loaded: Pd.Agents, Pd.Master, Main, Pd.Types.
λ> play2 1 (alwaysD, alwaysD)
(1,1)
λ> play2 1 (alwaysD, alwaysC)
(3,0)
λ> play2 10 (alwaysD, alwaysC)
(30,0)
λ> playN 1 [alwaysD, alwaysD]
[1,1]
λ> playN 1 [alwaysD, alwaysC, titForThat]
[6,2,2]
λ> playN 10 [alwaysD, alwaysC, titForThat]
[42,20,29]

Todo

  • Allow alternative payoff matrices.
  • Hide the plumbing, create a proper interface.

prisoners-dilemma's People

Contributors

atlaua avatar

Watchers

James Cloos avatar  avatar  avatar

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.