Hacker News new | ask | show | jobs
by NKCSS 3732 days ago
Small bug; your code has a small bias for right.

if (random > 0.5) { direction = 'right'; }

1 is not included in Math.Random, so it should be < 0.5 == left, >= 0.5 == right.