User:Nnz/Pillars' FOV Method

From RogueBasin
< User:Nnz
Revision as of 15:56, 30 December 2010 by Nnz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This not-very-complicated-and-probably-low-quality FOV method was invented and named after the great mathematician H. J. Pillars, whom I just made up.

The algorithm

Let's suppose that our hero, the famous @ symbol, is standing on square A, and a puny kobold on square B. If A is adjacent to B, then obviously the hero can see the kobold -- they're right next to each other. In general, if we can draw a line segment connecting the center of A to the center of B, and that line segment doesn't pass through any squares containing objects that block sight, then the hero can see the kobold.

But what if the line segment passes through a square that does contain a blocking object? For each of such squares, do the following test:

  • Draw a circle centered inside the square. The size of this circle can be anything you want; the ratio of the circle's diameter to the side length of the square is called p, or the Pillars index.
  • If the line segment passes through the circle, then the square fails the test.
  • If the line segment doesn't pass through the circle (or is tangent to it), then the square passes the test.

If all blocking squares pass the test, than our hero can see the kobold.

That's it. Very simple, and probably too much so. However, I hope that other people much brighter than me (of which there are quite a few) will come up with more high-quality variations to this algorithm.