Enigmatic Code

Programming Enigma Puzzles

Puzzle #60: Mexican standoff

From New Scientist #3283, 23rd May 2020 [link] [link]

The Good, the Bad and the Bumbling have decided the only way to resolve their differences is with a three-way duel, aka a Mexican standoff. They stand in a triangle, each armed with a gun and unlimited ammunition. As you might expect, Good has the deadliest shot: he kills his target 99 per cent of the time. Bad is more hit-and-miss: his success rate is 66 per cent. And Bumbling, in his role as the comedy relief, only fatally hits the mark 33 per cent of the time. On a count of three, each will draw their gun and, using the best strategy they can, will keep shooting with the aim of being the last spaghetti westerner standing.

Roughly what is the chance that Bumbling will survive?


5 responses to “Puzzle #60: Mexican standoff

  1. Jim Randell 23 May 2020 at 9:45 am

    (See also: Enigma 1190).

    Assuming they all fire at the same time, and then pause to evaluate the outcome before simultaneously taking the next shot.

    If each targets their deadliest remaining foe, then The Good will target The Bad, The Bad will target The Good, and the Bumbling will also target The Good.

    So The Good is targeted by both the others. His chance of surviving the first shot is 34%×67% = 23%.

    The Bad is targeted by The Good, so his chance of surviving the first shot is 1%.

    The Bumbling is not targeted by either of the others, so he has a 100% chance of surviving the first shot, and there is a 99%×66% = 65% chance that The Good and The Bad will have eliminated each other after the first shot. So the chances of The Bumbling’s survival look pretty good.

    Here is a Python program that runs a million random trials and reports the results.

    Run: [ @repl.it ]

    from random import randint
    from enigma import irange, fdiv, arg, printf
    # run N trials
    N = arg(1000000, 0, int)
    # hit rates for each participant (0, 1, 2)
    hit = [ 99, 66, 33 ]
    # who targets who?
    def target(p, ts):
      # target the deadliest foe
      return min(t for t in ts if t != p)
    # run one round
    def run(ps):
      ps = set(ps)
      while len(ps) > 1:
        # collect removed
        rs = set()
        for p in ps:
          t = target(p, ps)
          if randint(0, 99) < hit[p]:
        # remaining participants
      return ps
    # run the trials
    printf("running {N} trials ...")
    ps = [0, 1, 2]
    r = dict((p, 0) for p in ps)
    for _ in irange(1, N):
      for w in run(ps):
        r[w] += 1
    # output the results
    for (i, x) in enumerate(["Good", "Bad", "Bumbling", "Nobody"]):
      n = (r[i] if i < 3 else N - sum(r.values()))
      f = fdiv(n, N)
      printf("{x} wins {n}/{N} = {f:.2%}")

    Solution: The chance The Bumbling survives is around 77%.

    The result of a typical run is:

    running 1000000 trials ...
    Good wins 151004/1000000 = 15.10%
    Bad wins 4321/1000000 = 0.43%
    Bumbling wins 768605/1000000 = 76.86%
    Nobody wins 76070/1000000 = 7.61%

    So about 7.6% of the time no-one survives.

    • Jim Randell 23 May 2020 at 11:52 am

      If we do the maths (in a similar way to that described in Enigma 1190), we get:

      p([A, B, C]) = (228939 / 1516739, 67 / 15117, 3495017 / 4550217)

      giving survival probabilities of:

      The Good = 15.09%
      The Bad = 0.44%
      The Bumbling = 76.81%
      Nobody = 7.65%

      Which is a pretty good match to the probabilities calculated from the random trials.

  2. Hugh Casement 23 May 2020 at 10:44 am

    Martin Gardner, in his book More Mathematical Puzzles and Diversions (Penguin, 1961), has a variant in which the three do not fire simultaneously but first draw lots to decide who fires first and who second. They continue in the same cyclic order until only one is left alive.

    In that case the best strategy for the poorest shot, if he has first go or the others miss, is to shoot into the air, so as not to antagonize either of his opponents. Those two then continue to fire at each other until one is dead, when he has a good chance of getting a shot at the survivor.

    The puzzle had presumably previously appeared in Gardner’s column in Scientific American.
    Other versions had already appeared in print, the earliest known to him in 1938.

  3. arthurvause 24 May 2020 at 9:18 am

    Treating the puzzle as an Absorbing Markov Chain, I get slightly different probabilities for the winner being Good, Bad, Bumbling and None of 15.09%, 0.44%, 76.81%, 7.65%

    The calculations are shown in this spreadsheet.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: