BenMakesGames.FoV 1.1.2

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
dotnet add package BenMakesGames.FoV --version 1.1.2
NuGet\Install-Package BenMakesGames.FoV -Version 1.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BenMakesGames.FoV" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BenMakesGames.FoV --version 1.1.2
#r "nuget: BenMakesGames.FoV, 1.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BenMakesGames.FoV as a Cake Addin
#addin nuget:?package=BenMakesGames.FoV&version=1.1.2

// Install BenMakesGames.FoV as a Cake Tool
#tool nuget:?package=BenMakesGames.FoV&version=1.1.2

What Is It?

BenMakesGames.FoV is a collection of field-of-view algorithms designed for square tile grids. It features the following algorithms:

  • Diamond-wall
  • Milazzo's Beveled-wall
  • Raycasting
  • Shadowcasting

Field-of-view/line-of-sight is useful for roguelikes, and other tactical, tile-based games where vision plays an important role.

Buy Me a Coffee at

How to Use


dotnet add package BenMakesGames.FoV 

Create a Map

Your map must implement IFoVMap, which requires a Width and Height property, and a method that returns whether or not a given tile is opaque:

For example:

public sealed class MyMap: IFoVMap
    public int Width { get; }
    public int Height { get; }

    // store your tiles however you want; here's one possibility:
    public MyTile[] Tiles { get; }

    // BlocksLight is required by IFoVMap; here's one possible implementation:
    bool BlocksLight(int x, int y)
        if(x < 0 || x >= Width || y < 0 || y >= Height)
            return true;

        return Tiles[x + y * Width].IsOpaque;


Another common implementation is to use a Dictionary<(int X, int Y), MyTile> collection to store the map.

Call One of the FoV Algorithms

All of the algorithms have the same signature:

HashSet<(int X, int Y)> Compute(IFoVMap map, (int X, int Y) origin, int radius)

They take a map, origin point, and sight radius, and returns a set of points that are visible from the origin.

Basic usage:

var visibleTiles = DiamondWallsFoV.Compute(Map, (Player.X, Player.Y), Player.SightRadius);

for(int y = 0; y < Map.Height; y++)
    for(int x = 0; x < Map.Width; x++)
        if(visibleTiles.Contains((x, y)))
            // tile is visible; draw it!
            // don't draw the tile, or draw it as a fog of war tile

When implementing field-of-view in your game, you should only compute a new field of view when the player moves, or the map changes (such as a door opening or closing).

Available Algorithms, and Their Features

  • DiamondWallsFoV
    • Relatively fast algorithm. Compared to other algorithms, reveals more tiles in a given sight radius.
  • MilazzoFoV
    • Medium speed; designed to have intuitive lines of sight, especially for maps which contain many single-tile walls/pillars.
  • RayCastFoV
    • Slowest algorithm, with occasionally unintuitive lines of sight. Not generally recommended; included for historical reasons.
  • ShadowCastFoV
    • The fastest algorithm of the bunch, especially when used in large, open spaces with large sight radii.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 84 2/3/2024
1.1.1 170 4/16/2023
1.1.0 144 4/16/2023
1.0.0 156 4/14/2023