I noticed that every 15th or so time the program is stuck in an infinite loop and just shows the loading screen forever
to replicate just remove all other problems apart from probability and refresh the page a couple of times)
I narrowed it down to the probability problem and the while(...) in the second picture
Here it prints out the "stuck L2" 400 000 times so it is clearly stuck indefinitely

This is where I added the println

There are so many conditions and it is not my task so I didn't really try to find the cause myself.
I noticed that every 15th or so time the program is stuck in an infinite loop and just shows the loading screen forever
to replicate just remove all other problems apart from probability and refresh the page a couple of times)
I narrowed it down to the probability problem and the while(...) in the second picture
Here it prints out the "stuck L2" 400 000 times so it is clearly stuck indefinitely

This is where I added the println

There are so many conditions and it is not my task so I didn't really try to find the cause myself.