Issue implementing Pollard's Rho for discrete logarithms
First of all, Pollard Rho finds an essentially random solution $(B - b) \gamma \equiv (a - A) \pmod{N}$.  This randomness implies that if $N$ has a prime factor $p$, then $B - b$ has a probability $1/p$ of having $p$ as a multiple (and hence it will fail in precisely the way you've seen).

Pollard Rho is normally used with $N$ being a large prime; the only prime factor $N$ has is, in fact, $N$, and so it has a tiny change ($1/N$) of failing. You, of course, are using it with toy parameters, and so the chance of failure is much higher.

This does being up a nontrivial point; in the group $Z_p^*$, $N = p-1$ is always even; doesn't this mean that Pollard-Rho always have a 50% probability of failing?

Well, it would, if we used it in the straight-forward manner.  However, what we do is perform the operation in a prime subfield (or, at least, a subfield with no small factors); this makes the failure probability tiny.

If we do have to do the work in a group with a size that has small factors, say, $N = hq$, where $h$ is smooth, and $q$ has no small factors, then what we can do is compute $a^h$ and $b^h$, and use Pollards-Rho to compute $\gamma'$ such that $(a^h)^{\gamma'} \equiv (b^h)$; this is in the $q$-sized subgroup, and so has a high probability of success.  Given $\gamma'$, it's easy to reconstruct $\gamma$, as $\gamma \equiv \gamma' \pmod q$