Precise Permissive Field Of View

A Precise Permissive FOV algorithm, based on the Python implementation.

Usage

Instantiation

In order to instantiate a `PermissiveFov` object, one needs to pass it the map dimensions and an `isTransparent` function that will determine whether a pair of coordinates points to a transparent (non-blocking) cell on the map.

Since Permissive FOV contains TypeScript typings, it can also be used within TypeScript applications, the only difference being, obviously, the `import` statement:

FOV computation

A FOV computation requires four parametres: the source coordinates `x` and `y`, maximum sight radius (use `Infinity` for unlimited sight radius) and a function that will mark a given pair of coordinates as seen.

Changing the transparency check function

Precise Permissive Field Of View is a field of view (FOV) computation algorithm. Given a 2D grid with a source point S and n points marked as obstacles, it will determine all points visible from S.

Here's an example of a field of view calculated using the Permissive FOV algorithm:

Real life uses

As with most field of view algorithms, Precise Permissive Field Of View can be used in any game with a two dimensional grid layout, e.g. a roguelike.

Due to the permissive nature of this algorithm, it is well suited for situations where symmetry and permissiveness are the desired features, e.g. for reasons of gameplay balance.

Restrictiveness vs. permissiveness

As the name itself implies, this algorithm is permissive (as opposed to restrictive). It means that it will typically consider many more points to be in field of view than other algorithms would.

This also means that in some cases, the field of view will take an unnatural looking shape, including points that are considered to be visible despite being right behind an obstacle. Here are two examples that demonstrate this:

Symmetry

A FOV algorithm is considered symmetric given that the following is true:

Given any set of points A and B, when B is in FOV of A, then A is in FOV of B.

In other words, a field of view is symmetric when all of the points seen from source can also see the source, while all the points not seen by the source, cannot see the source either.

Permissive Precise FOV is perfectly symmetric.

Performance

Compared to other available FOV algorithms, Precise Permissive FOV is rather slow, with an average time required to compute a single field of view several times longer than that of the best performing alternatives.

This means that this algorithm may not be well suited for uses where the field of view computation is performed very frequently. That being said, the symmetric nature of Precise Permissive FOV allows for smart optimisations. For instance, if the FOV has already been calculated for origin point A, determining whether A is visible from B doesn't require another FOV computation: if A sees B, then B sees A.

Images

FOV images have been generated by FOV Torture Chamber.

Credits

Python implementation's authorship and copyright notice: