PlanarAlly icon indicating copy to clipboard operation
PlanarAlly copied to clipboard

[FEAT] The Rings of Light (a proposal for a better vision system in hexagonal grids)

Open galaxyonfire opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe. For a hexagonal grid based map, the amount of hexagonal tiles viewed via the traditional circle-based vision is dramatically different than the number of square tiles viewed at a large vision radius.

Describe the solution you'd like Please bear with me through some math.

Let us set the following:

  • Side of a square = 1 m
    • Area of square = 1 m^s
  • Maximal radius (aka 1 side) of a hexagon = 1 m
    • Area of hexagon = 12 * sqrt(3) / 8 ~= 2.6 m^2

Now let's say we have a circle of radius 3 m. The area of it is 9pi m^2 or ~28.27. You can fit 28.27 squares in this circle, but only 10.8 hexagons.

At a more practical vision radius of 15 m, you get to see about 706.8 squares, but only 271.8 hexagons! In terms of standard sizing (as many tabletop games will equate a size 1 thing to take up either 1 square for a square grid or 1 hexagon in a hexagonal grid), you have dramatically less vision using a hexagonal grid because you see far less size 1 items.

Thus, allow me to introduce the idea of ring lighting (i.e. building rings of light around a player token).

Imagine you have a player token the size of a single hexagon. At ring level 0, they can only see 1 tile (themselves). At ring level 1, they can see themselves and every hexagon that immediately touches their player token, for a total of 1 + 6 = 7 visible tokens. At ring level 2, they can see themselves, every hexagon that touches the player token and every hexagon that touches the first ring of newly visible tokens, for a total of 1 + 6 + 12 = 19. It's similar to creating a series of concentric rings that hug each other.

Where k is the number of light rings you want to build, here are the number of visible tokens per grid type.

Square vision = image

Hexagonal vision = image

(as an aside, n-sided Regular Polygon vision = image)

Now if we return to the practical vision radius of 15 m, let's instead say 15 rings of light:

Square vision = 240 squares

Hexagonal vision = 720 hexagons

Oh my, how the turned tables have.

Thus, I implore that this ring lighting functionality be implemented as an optional vision mode along side the hexagonal grid mode (#136) in order for hexagonal grid players to have similar total tile viewings to square grid players, as many tabletop games don’t adjust the standard sizes of their objects to the various grid modes. (You may even set it as the default vision mode for gms that turn on hexagonal grid tiling). From dthv's comment on #136, the link provided has a nice interactive example that combines this ring lights + obstructions (i.e. dynamic lighting). I believe it may also link to the algorithm that does this.

Describe alternatives you've considered I believe that interactive also links a few nice alternative options, like the Duelo view, but these restricted FOV's are not the main way vision is set in most tabletop games.

Additional context Inspired out of my desire to play Lancer with PlanarAlly.

galaxyonfire avatar Oct 22 '20 06:10 galaxyonfire

The thing is that this seems to assume to me that vision is tile based (be it square or hex). And that a tile is thus either visible or not.

But this is not actually the case, vision/lighting is just radial outwards from the center of the tokens and does not care about how many tiles or in what shape those tiles are; The only thing it cares about is distance and walls.

Am I correct in that observation?

Kruptein avatar Oct 22 '20 19:10 Kruptein

I would agree with that. I suppose part of my concern is how one may interpret the "radial outward-ness" of vision if it is relegated by a cap on visible tiles. Take the vision system from Lancer: If you have Sensor 10, you can only see up to 10 hexagonal tiles away. For this system, you do care about how many tiles are visible. Thus, distance in Lancer, per say, is not measured in feet or meters, but in the raw number of tiles. You will always have an integer amount of visible tiles with this system as well.

galaxyonfire avatar Oct 22 '20 22:10 galaxyonfire

I see, I'm certainly willing to look into such a ring based system, but I'm already going to tell you that the first iteration of hex support will use the current lighting system.

That said circles centered on a hex will roughly match with the hexagonal rings, indeed not exactly, but it might be an okay-ish initial substitute maybe?

I'll add it to my backlog!

Kruptein avatar Oct 23 '20 07:10 Kruptein

Indeed, thank you! Take as long as you need. In terms of building the rings as hexagonal rings, that's exactly how I envisioned it to be implemented (for hex grids at least). It's like building a large honeycomb in the shape of a hexagon, with the player at the center.

I suppose one algorithm to build this would be to take the x/y of the center of the player token, compute the offsets for the 6 vertices of the final ring of the honeycomb, and fill in the inside as visible space.

galaxyonfire avatar Oct 23 '20 09:10 galaxyonfire

For algorithms on rings, see this section at redblobgames. The following section on Field of View might be of interest, too. :slightly_smiling_face:

I'm very excited for hex-grids! :smile:

dthv avatar Nov 01 '20 15:11 dthv