Python simulation code for the RoyBean algorithm