Let Eij be the event that the player on roll flips i heads before the other player flips j heads, and let X be the first two flips having sample space {hh,ht,th,tt} where h means heads and t tails, and let pij≡Pr(Eij).
Then pij=Pr(Ei−1j−1|X=hh)∗Pr(X=hh)+Pr(Ei−1j|X=ht)∗Pr(X=ht)+Pr(Eij−1|X=th)∗Pr(X=th)+Pr(Eij|X=tt)∗Pr(X=tt)
Assuming a standard coin Pr(X=∗)=1/4 means that pij=1/4∗[pi−1j−1+pi−1j+pij−1+pij]
solving for pij, =1/3∗[pi−1j−1+pi−1j+pij−1]
But p0j=p00=1 and pi0=0, implying that the recursion fully terminates. However, a direct naive recursive implementation will yield poor performance because the branches intersect.
An efficient implementation will have complexity O(i∗j) and memory complexity O(min(i,j)). Here's a simple fold implemented in Haskell:
Prelude> let p i j = last. head. drop j $ iterate ((1:).(f 1)) start where
start = 1 : replicate i 0;
f c v = case v of (a:[]) -> [];
(a:b:rest) -> sum : f sum (b:rest) where
sum = (a+b+c)/3
Prelude> p 0 0
1.0
Prelude> p 1 0
0.0
Prelude> p 10 10
0.5329097742513388
Prelude>
UPDATE: Someone in the comments above asked whether one was suppose to roll 10 heads in a row or not. So let Ekl be the event that the player on roll flips i heads in a row before the other player flips i heads in a row, given that they already flipped k and l consecutive heads respectively.
Proceeding as before above, but this time conditioning on the first flip only,
pk,l=1−1/2∗[pl,k+1+pl,0] where pil=pii=1,pki=0
This is a linear system with i2 unknowns and one unique solution.
To convert it into an iterative scheme, simply add an iterate number n and a sensitivity factor ϵ:
pk,l,n+1=1/(1+ϵ)∗[ϵ∗pk,l,n+1−1/2∗(pl,k+1,n+pl,0,n)]
Choose ϵ and pk,l,0 wisely and run the iteration for a few steps and monitor the correction term.