Fixed an infinite loop that sometimes occurred in RandomAgent.

Closes #65