Multiple probabilities is not too complicated. Say you’re in state Z. You can do something like:
X RAND 99
IF < X PN 0 Z: Z 0; do whatever else // switch state to 0 and do whatever you want there.
ELIF < X PN 1 Z: Z 1; ... // switch state to 1 ...
ELIF < X PN 2 Z: Z 2; ... // switch state to 2 ...
ELSE: Z 3; ...
PN j Z is the transition probability from state Z to state j.
I haven’t tried this, but I think it should work.
For more states, as long as from each state you only transition to 4 other states, you can still apply the above. Instead of a 4 x 4 matrix, you’ll have an N x 4 matrix.
EDIT: I just realized there is a bug in the snippet I wrote above. PM me if you want the details.