Particle Filter Localization
A particle filter represents the robot pose as a cloud of guesses called particles. Each step, every particle moves like the robot did, gets a score for how well it explains the sensor readings, and the best ones are copied.
One cycle
Move. Shift every particle by the robot's odometry, plus a little random noise. Weigh. For each particle, predict the range to each landmark and compare it with the real reading. Particles that agree get high weight. Resample. Draw a new set of particles in proportion to weight, so good guesses multiply and bad ones disappear.
What to notice
At the start the particles cover the whole room, since the robot has no idea where it is. After a few readings they gather into one cluster. Press "Kidnap the robot" to teleport it without telling the filter. The particles are now all wrong, and with no particles near the truth the filter can struggle to recover. Real systems such as AMCL in Nav2 add a few random particles each step to handle this.