Prime numbers and field of vision

 from Red Blob Games
14 Dec 2018

I wrote in the roguelike discord:

I suspect fov and prime numbers are related because you have things like drawing a line to (12,4) to see if any tile is obstructed, but that goes exactly through (3,1) and (6,2) and (9,3) so that means you can calculate the answer for those three points along the way instead of starting a new line — and that's related to prime factorization. But if you draw a line to (13,4) you don't get the answers for points in between. Hm

So let me draw a picture:

The color tells you how many lines to that point share the same angle, and thus can be reused. You'd have to check line of sight once for each ratio, not once for each location.

I was hoping for a more interesting pattern here. Maybe I should be asking different questions like: if I only trace line of sight to the perimeter, which points in the interior will get matched? The blue points here:

Email me , or tweet @redblobgames, or comment: