solipsist comments on Prisoner's Dilemma (with visible source code) Tournament - Less Wrong

47 Post author: AlexMennen 07 June 2013 08:30AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (232)

You are viewing a single comment's thread. Show more comments above.

Comment author: So8res 24 June 2013 06:59:36AM *  3 points [-]

All right procrastinators, let's talk strategy. You want a bot that's unexploitable. Ideally, it should be as easy as possible for the opponent to prove that you'll do whatever they do. In a world of unexploitable bots, the bot that can achieve the most cooperation will win.

MimicBots fit all of these parameters. They make it clear that their opponent is choosing between (C, C) and (D, D). Against a MimicBot, (C, D) is not an option. MimicBots pass up some utility by cooperating with CooperateBot, but that's fine in this competition. You aren't playing against CooperateBot. You're playing against humans' bots, and I doubt that anyone is mad enough to submit a CooperateBot.

The biggest problem with a MimicBot is that it will time out when playing other MimicBots. The MimicBots will dive into an evaluation loop, where my bot evaluates yours on a quine of me, and you evaluate my quine on a quine of you, ad infinitum.

Your MimicBot has got to bottom out at some point if you don't want to risk timing out. If you find yourself diving into an evaluation loop you'd better bottom out into Cooperation.

Note that bottoming out into cooperation is not the same thing as cooperating at the top level. If the 100th simulation of you cooperates, and the 100th simulation of them sees that as a weakness and defects, then the 99th level of you will defect and so will the 98th and so on up to the top level, where mutual defection occurs.

I'm not asking you to cooperate when the other bot looks like they're going to time out. That's suicide. Rather, I'm pointing out that you can't just simulate me against you, because that loop will never end. You've got to simulate me against a version of you that is one step closer to cooperation. This is true no matter what strategy you choose. But let's consider the simple case: a MimicBot that simulates you on a copy of itself that simulates you on a copy of itself that eventually bottoms out into a bot that simulates you on CooperateBot.

Such a bot is a Rank N MimicBot, where N is the simulation depth at which it puts forth a CooperateBot.

Any particular Rank N is exploitable. For example, JusticeBot is a Rank 1 MimicBot — it bottoms out immediately by simulating you against CooperateBot. You can exploit JusticeBot by cooperating with CooperateBot and nobody else.

Notice, however, the price of exploiting JusticeBot: in order to exploit JusticeBot, you've got to cooperate with CooperateBot (a Rank 0 MimicBot).

As another example, consider a Rank 10 MimicBot. It simulates the opponent against a Rank 9 MimicBot. You can exploit an Rank 10 MimicBot if and only if you're willing to cooperate with a Rank 9 MimicBot.

In general, you can exploit a Rank N MimicBot by cooperating with a Rank (N-1) MimicBot.

The trick here is that the opponent doesn't know which MimicBot they'll be playing. They have to guess exactly right to exploit you. If they guess high, mutual cooperation is achieved (If you guess I'm a Rank 10 you'll cooperate with a Rank 9). If they guess low, mutual defection is achieved. (If you defect against Rank 10, Rank 11 will not cooperate with you.) You can only be exploited if they guess your rank precisely.

Therefore, I advocate that we get a bunch of us together to play Rank N MimicBots. We all pick our own N, possibly randomized. Note that Rank N MimicBots will achieve mutual cooperation with any MimicBot of any rank (including CooperateBot, JusticeBot, and MimicBots who don't bottom out). Anyone trying to exploit us will only be able to exploit a specific rank, at the price of cooperation with a lower rank and the risk of defection from higher ranks. So long as we have a wide spread of ranks, our MimicBot clique will be internally cooperative and unexploitable in aggregate.

On Tolerance

MimicBot cooperates with CooperateBot. That leaves utility lying on the table. This may irk you (if you expect anyone was dumb enough to play CooperateBot). More irksome is the fact that MimicBot cooperates with JusticeBot. There is at least one JusticeBot in play, and we should expect that many non-procrastinators have submitted bots who exploit that JusticeBot. It would be a shame for our Rank N MimicBots to miss a shot at cooperation with bots who special-case defection against JusticeBot.

Therefore I recommend submitting MimicBots of rank 3 or higher. This gives people a little leeway to exploit CooperateBot or JusticeBot as they please, and allows us a broader range of mutual cooperation with bots who have already been submitted.

On choosing N

I recommend choosing a highish N. Very low N is obviously a bad idea. Playing rank 0 (CooperateBot) is suicidal. Playing rank 1 (JusticeBot) exposes you to exploitation by everyone who's decided to kick wubble's JusticeBot. Beyond rank 1 all the Ranks are theoretically similar, but you've got to consider what other bots will do. It's conceivable that some bots won't believe they're playing a MimicBot until they hit a deep enough recursion depth. It's possible that some bots will (incorrectly) think that you're exploitable if you return too quickly. Therefore I recommend a high N.

If you're particularly paranoid, consider randomizing N. Humans are notoriously bad at picking random numbers, and the MimicBot clique could in theory be exploited by a bot who exploits the ranks that humans are more likely to pick. Setting your counter to (+ 3 (random 1000)) is a quick way to counter that.

You can also shake things up a bit by using non-standard counters. For example, you could write a Timed MimicBot which passes down the initial time (instead of a counter) to its quines and puts forth a CooperateBot after a certain amount of time has passed (instead of when the counter hits zero).

How do I write one of these?

You write one of these with a degrading quine. Each level should evaluate the opponent against a slightly weeker version of itself. You can do this easily by putting a counter in your bot. So long as the counter is positive, the quining function should return a quine with the counter decremented. Once the counter hits zero, the quining function should return a CooperateBot.

Sounds nice, but how do I write a 'degrading quine'?

It's actually pretty easy in scheme.

  1. Define (quine (lambda (code) 'placeholder)) and (template 'placeholder). Write the rest of your logic, pretending that (quine template) generates a child quine.
  2. Manually copy all of your code and paste it over the template placeholder. In the pasted code, find all of the "holes" (parts that can vary: the counter, the template, your cooperation predicate, etc.) and replace them with odd negative numbers.
  3. Write the quine function to walk through the code. If it sees a negative integer, figure out which hole it is by checking (+ code 1). This allows you to replace the -3 hole without having any -3s anywhere else in the code and so on.
  4. Copy the real quine function into the template's quine function.

If you make any more code changes after this process, remember to mirror them in your template. It will end up having this form:

(letrec [(counter (+ 3 (random 100)))
         (template '(letrec [(counter -1)
                             (template -3)
                             ...
         (quine (lambda (code)
           (cond
             ; The -1 hole is for the counter.
             ((and (integer? code) (negative? code) (= 0 (+ 1 code)))
               (- counter 1))
             ; The -3 hole is for the template.
             ((and (integer? code) (negative? code) (= -2 (+ 1 code)))
               `',template)
             ...

In order to make your MimicBot bottom out, you'll want to define a predicate that is similarly flexible. It should be along the lines of ((eval them) (quine template)) so long as the counter is positive and #t when the counter gets to zero. The body of the letrec can then be as simple as (if predicate 'C 'D).

You'll want some extra code to spawn the simulation in a thread and kill it if it goes overtime and so on.

If we all write bots like this, we can form a very powerful group capable of a wide range of mutual cooperation and very difficult to exploit.

Join me. With our combined strength, we can end this destructive conflict and bring order to the galaxy.

Comment author: solipsist 24 June 2013 03:07:48PM *  2 points [-]

The MimicBots will dive into an evaluation loop, where my bot evaluates yours on a quine of me, and you evaluate my quine on a quine of you, ad infinitum.

MimicBot, as I described it, breaks out of a simulation probabilistically; it will almost surely not fall into an infinite depth of simulations. MimicBot cooperates with probability ε, and has an expected simulation depth of 1/ε when played against itself. As long as ε<.5, the best action against MimicBot is to cooperate, so the expected simulation depth can be as low as 2.

Comment author: So8res 24 June 2013 03:40:56PM *  0 points [-]

I'd still recommend you refrain from acting as Rank 0 or 1 (from cooperating immediately or from simulating the opponent on a MimicBot who cooperates), as it's likely that there are bots in play that prey on CooperateBots and JusticeBots (as determined by checking if you cooperate DefectBot). Also, I imagine there will probably be a fair number of DefectBots on the field, your MimicBot is exploited by a fraction of them.

I strongly recommend writing a MimicBot that goes through two iterations before allowing itself to exit with a fixed probability. Given that tweak I agree completely that your MimicBot is quite powerful.

Comment author: solipsist 24 June 2013 04:53:20PM *  1 point [-]

I strongly recommend writing a MimicBot that goes through two iterations before allowing itself to exit with a fixed probability.

You can deal with those special cases that way. I was going to use a flatter, less quiny approach.

def special_casing_bot(opponent)
    if acts_like_cooperate_bot(opponent):
        return DEFECT
    elif act_like_other_exploitable_bot(opponent):
        return DEFECT
    elif special_case_3(opponent):
        return DEFECT
    elif special_case_4(opponent):
        return COOPERATE
    elif special_case_5(opponent):
        return DEFECT
    # etc
    else:
        return mimic_bot(opponent)
Comment author: So8res 24 June 2013 05:14:01PM 0 points [-]

Depending upon the implementation of mimic_bot, this is a quiny approach. mimic_bot obviously can't run the opponent on an exact quine of yourself, because then you won't achieve mutual cooperation. (When one of the bots cooperates unconditionally, the other will see that it acts_like_cooperate_bot and defect.) So long as mimic_bot plays opponents against a pure MimicBot instead of a perfect quine, this should work quite well.

On an unrelated note, woah, how'd you get whitespace working?

Comment author: solipsist 24 June 2013 05:20:55PM *  5 points [-]

On an unrelated note, woah, how'd you get whitespace working?

Total kludge. Used exotic unicode whitespace characters, which are displayed unaltered in comments :-).

Comment author: ialdabaoth 24 June 2013 03:31:32PM 0 points [-]

MimicBot cooperates with probability ε

You mean defects with probability ε. It cooperates with probability 1-ε.

Comment author: solipsist 24 June 2013 03:48:01PM *  3 points [-]

MimicBot cooperates with probability ε

You mean defects with probability ε.

No, I did not mean this, but I left out an important word: I should have said MimicBot cooperates unconditionally with probability ε.

MimicBot will almost perfectly mirror the strategy of its opponent. Most of the time (probability 1-ε), MimicBot returns the result of a simulation of its opponent against MimicBot. If you're fighting MimicBot, you should expect it to think and act almost exactly the way you think and act. If you decide to always cooperate with MimicBot, MimicBot will decide to cooperate with you. If you decide to always defect against MimicBot, MimicBot will (almost always) decide to defect against you. If you play a mixed strategy against MimicBot, MimicBot will play an almost identical mixed strategy against you.

The slight imperfection in the strategy mirror (cooperating unconditionally with probability ε) is necessary to avoid infinite recursion

Comment author: ialdabaoth 24 June 2013 03:48:53PM 2 points [-]

reads further

is enlightened

Comment author: So8res 24 June 2013 03:41:56PM 1 point [-]

Incorrect. His MimicBot cooperates with probability ε and mimics the opponent with probability 1-ε (which may result in cooperation or defection, depending upon the opponent.)

Comment author: Kawoomba 24 June 2013 04:10:54PM 1 point [-]

Heh, only if random() returns a random number in [0, 1], which isn't specified in the pseudocode.