I believe that at the end of each turn, a base random number is generated.

This is then modified according to other factors to determine whether the agent succeeds.