Experience the phenomenon of gas diffusion in a simulated 2D environment with perfect spheres representing gas particles moving and colliding. Implement a grid optimization technique to speed up collision checks and enhance the realism of particle interactions.