Skip to content

gigix/Evolution-of-Cooperation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The book The Evolution Of Cooperation (by Robert Axelrod) was a great work. You should definitely check it out . (And here is a Chinese version )

However, the software emulating its system was implemented with Fortran , and hardly readable. I want to rebuild it with Ruby and make it more readable, probably make it an online system and invite people all over the world to contribute their strategies.

What Is It, After All?

I created a platform to simulate a series of Iterated Prisoner’s Dilemma (which has also been referred to as the “Peace-War game”) games. You can try to build a smartest strategy to win the championship of all the prisoners.

How Can I Participate?

I’m doing it alone so far. You can help by both ways:

Submit Strategies

You can submit a strategy which would be used by a “prisoner” in Iterated Prisoner’s Dilemma . In order to program a strategy, you need to:

  • Create a .rb file (e.g. never_forgive.rb) within “strategies” directory (or make a subdirectory for yourself, it’s your call).
  • Define a class for your strategy, which must be a subclass of Strategy:
    class MyNiubiStrategy < Strategy

    end
  • Override/implement to_operate? method, which has 2 arguments: the history of your actions and your opponent’s. Based on the historical actions, you need to make a decision: am I going to cooperate in this round, or shall I defect/betray?
    • To those who don’t know Ruby much: the value of last statement in a method would be returned. Return false or nil causes your prisoner to betray, otherwise he will cooperate.
    • Both arguments are arrays. For example, you could use opponent_history.last to get the last step your opponent just behaved. Check the document for more detail.
    • With each historical action step in any argument, you can call cooperative? and treacherous? methods to determine its attitude.
  • Add your new strategy into competition task, which is in Rakefile.
    competitors = [
    AlwaysCooperateStrategy,
    AlwaysBetrayStrategy,
    TitForTatStrategy,
    NeverForgive,
    MyNiubiStrategy,
    RandomStrategy
    ]
  • Finally…invoke rake competition in your console, and see if your strategy wins the championship.

Contribute to the Platform

(TBD)

That’s it. Read the book if you haven’t.

About

A readable implementation of "The Evolution of Cooperation" (by Robert Axelrod) game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages