Update grid.js to make deterministic and infinite