Sorry for the ambiguous title.

So I was playing Divinity OS when a question popped into my mind about Probability of winning the RPS game.

I gave myself similar question with the following metrics

  • A and B have a coin

  • If it lands Head, A receives $5

  • If it lands Tails, B receives $2

  • First to reach $10 wins

By manual labour I reached conclusion that B had 7/64 chance of winning (I'm not sure if it's correct)

My question is how do I generalize this, IE, say there are 2 or 3 people playing with a fair die, they receive some arbitrary but different amounts and first to $x wins

And how to extend it to more number people?


Your answer looks correct, and computing can be done by a recursive function, e.g. in SageMath:

tot = 10
def f(a,b):
    if a >= tot and b < tot:
        return 0
    if b >= tot and a < tot:
        return 1
    return 1/2*(f(a+5,b)+f(a,b+2))

print f(0,0) # returns 7/64

For 3 people, we need three variables, e.g. using a die where each person chooses a number:

tot = 10
def f(a,b,c):
    if a >= tot and b < tot and c < tot:
        return 0
    if b >= tot and a < tot and c < tot:
        return 0
    if c >= tot and a < tot and b < tot:
        return 1
    return 1/3*(f(a+5,b,c)+f(a,b+2,c)+f(a,b,c+3))

print f(0,0,0) # returns 3226/19683 ~ 0.1638977798
  • $\begingroup$ SageMath is based on python? Anyways, I'm not sure how this works, can you elaborate it a bit? Thank you $\endgroup$
    – Anvit
    May 28 '17 at 14:38
  • $\begingroup$ Yes, it's based on python. We are defining stopping conditions: depending on who has to be the winner, return 1. Otherwise, continue the recurrence times the probability of going to each branch of the tree. $\endgroup$
    – gar
    May 28 '17 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.