Poker hand, dynamic programming

426 Views Asked by At

enter image description here

Please see the question above. I just don't understand how come $f(0,r) =0$. Shouldn't that be $-r$ dollars?

1

There are 1 best solutions below

0
On BEST ANSWER

Arthur already explained why $f(0, r) = 0$, but here's another way to frame the boundary conditions if you wanted to keep using the same expression except with black/red removed, depending (Python script):

@memoize
def E(b, r):
    if b == 0 and r == 0:
        return 0
    elif r == 0:
        return max(b - r, E(b - 1, r))
    elif b==0:
        return max(b - r, E(b, r - 1))
    else:
        return max(b - r, b / (b + r) * E(b - 1, r) + r / (b + r) * E(b, r - 1))

The important thing to note is that the payoff is always equal to $b-r$ if you stop, and $0$ if you just decide to draw all the cards. The $f(0, r) = 0$ shortcut is just optimizing away the unnecessary recursion calls.