Another insane project. This is just a gleam in my eye. I thought my other program was going to be my last one! Damn.

Iterations of the Prisoner's Dilemma prove interesting things about what a "successful" strategy is. (See Axelrod, The Evolution of Co-operation). I would love to build a genetic algorithm to play the prisoner's dilemma, and see what evolves. (I know it has been done before, but I like DIY.)

It's all easy apart from the genetic algorithm bit. My scribbled notes suggest this - NB I am an amateur and don't have any academic background in the field:

Use 1 for cooperation, 0 for defection. The DNA is a string of elements which operate successively to come up with a final 1 or 0.

Start with 1. (Or 0 - does it matter?)

DNA letter meanings:

Ax - "and" with x
Ox - "or" with x
Sx - save in register, start again with x
"x" can be any of:
D - defect. 0.
C - cooperate. 1.
number - opponent's strategy in game played number rounds previously
number - own strategy in game played number rounds previously. This can be distinguished by e.g. using odd for opponent, even for self; or adding 100 to self. R - retrieve result from register

I know this wastes space and it should all be bit vectors or whatever, but ignore that. My questions:

Could it be simpler? Do I need a "register"?

Should it be more complicated? Will adding complications allow for more powerful solutions?

Related to the "register" issue: does a simple linear program like this allow for different priorities? To put it another way, can you express "(1 and 0) or 1" as well as "1 and (0 or 1)" without the brackets?

How "atomic" should individual DNA elements be? E.g. should an element mean "and" and be coupled with the next element (disadvantage - some mutations might "not work" at all) or should an element mean "and with such and such" (seems less flexible, easier to write though).

A gene pool of 100 players all playing each other means 100*99 games (maths?) in a single generation. How can I make this bearably fast?

I'd be very interested to hear comments from people with a CS background.

best,
dave hj~

NB: I found this page describing Axelrod's work with this. He uses simple brute force rather than a "programming language" approach. The downside is each player can only remember the last 3 games, and this is built in. Clever though.


In reply to Genetic algorithms by dash2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.