Spielerando

Minimap and Fog of War

Fog of war hides the map until the player sees it. Every cell is never seen, in sight or remembered. Sight reaches a set distance and stops at walls. A remembered cell shows what it looked like when last seen, even if it has changed. The minimap is a window around the player that draws each cell by its fog.

Also called: Fog of war, Explored map, Map reveal.

A small mole cartographer with a lantern walks a winding path in an illuminated-manuscript landscape: clear colour in a circle around it, faded sepia sketch behind it, and pale parchment clouds hiding everything beyond.
Mappelmoss Leaves, an invented manuscript-style exploration game. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Minimap and Fog of War" to my game.

What it should do: Exploring means not knowing. Fog keeps the world unknown until the player has been there, remembers what they found, and gives the minimap something honest to draw: only what the player knows, as they last saw it.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> unseen
  unseen: Never seen
  visible: In sight
  remembered: Remembered
  unseen --> visible: comes into sight
  unseen --> remembered: a map scroll
  visible --> remembered: goes out of sight
  visible --> unseen: a new run starts
  remembered --> unseen: a new run starts
  remembered --> visible: comes back into sight
```

Use these starting values:
- sightRadius: 5 cells
- mapRadius: 8 cells
- scoutRadius: 12 cells

Watch out for these common mistakes:
- A map that shows the present: Tell your AI: draw a remembered cell from the memory, which holds what was last seen, and only update the memory for cells in sight.
- Seeing one way only: Tell your AI: always draw the line from the same end, so sight is the same in both directions.
- Light through a diagonal gap: Tell your AI: when the line steps diagonally and both cells beside the step are walls, the view is blocked.
- A door that opens out of sight: Tell your AI: recompute sight after every change in the world, and write into the memory only the cells in sight.
- Walls that look transparent: Tell your AI: the first wall on the line is part of what is seen. Only what lies behind it stays hidden.
- A map scroll that spoils too much: Tell your AI: a scroll fills the memory only. It does not change what is in sight.
- The edge of the world: Tell your AI: always draw a square of the same size and mark cells beyond the edge as outside.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

Exploring means not knowing. Fog keeps the world unknown until the player has been there, remembers what they found, and gives the minimap something honest to draw: only what the player knows, as they last saw it.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

comes into sighta map scrollgoes out of sighta new run startsa new run startscomes back into sightNever seenIn sightRemembered
How it runs, as a diagram
  • Never seen → In sight: comes into sight
  • Never seen → Remembered: a map scroll
  • In sight → Remembered: goes out of sight
  • In sight → Never seen: a new run starts
  • Remembered → Never seen: a new run starts
  • Remembered → In sight: comes back into sight

Good starting values

ValueStart withWhat it changes
sightRadius5 cellsHow far the player sees. Five cells shows the room they stand in and a little of the next, so a corridor still hides what is round the corner.
mapRadius8 cellsHow many cells the minimap shows on each side of the player. A bit more than the sight radius lets the player see what they remember around them.
scoutRadius12 cellsHow far a map scroll uncovers around the player. Zero turns scrolls off.

What usually goes wrong

A map that shows the present

If the minimap draws what is really there, it shows a door that was shut behind the player as it is now, and the player learns things they did not see.

Fix: Tell your AI: draw a remembered cell from the memory, which holds what was last seen, and only update the memory for cells in sight.

Seeing one way only

If the line from A to B is drawn differently than from B to A, the player sees a guard that cannot see them, or the other way round.

Fix: Tell your AI: always draw the line from the same end, so sight is the same in both directions.

Light through a diagonal gap

A line that squeezes between two walls touching at the corners lets the player see through a solid corner.

Fix: Tell your AI: when the line steps diagonally and both cells beside the step are walls, the view is blocked.

A door that opens out of sight

When something changes in a cell the player is not looking at, the memory should keep the old look until they see it again. When it changes in sight, it should update at once.

Fix: Tell your AI: recompute sight after every change in the world, and write into the memory only the cells in sight.

Walls that look transparent

If the wall that blocks the view is not itself seen, the player stands in front of a gap in the map.

Fix: Tell your AI: the first wall on the line is part of what is seen. Only what lies behind it stays hidden.

A map scroll that spoils too much

A scroll that puts cells in sight lets the player see monsters through walls, and one that wipes memory clears their own notes.

Fix: Tell your AI: a scroll fills the memory only. It does not change what is in sight.

The edge of the world

A minimap near an edge that simply gets smaller changes size and jumps around as the player walks.

Fix: Tell your AI: always draw a square of the same size and mark cells beyond the edge as outside.

How to check it works

Works well with

Common questions

how do i add fog of war and a minimap to my game

Give every cell three conditions: never seen, in sight and remembered. Work out what is in sight from the player's position after every move, and copy it into a memory. Draw the minimap from the memory, not from the real world.

why does my minimap show things the player has not seen

It is drawing the real world instead of the memory. Draw a cell in sight from the real world, a remembered cell from what was last seen there, and leave every other cell blank.

how do i stop the player seeing through walls

Draw a line from the player to each cell in range and stop at the first wall or closed door. Show that wall, hide what is behind it, and block diagonal gaps between two walls. Always draw the line from the same end so sight works both ways.

what do i tell my ai to add a minimap with fog of war

Paste this: Add fog of war and a minimap. The player sees 5 cells, stopped by walls and closed doors, and sees the face of the wall. Every cell is never seen, in sight or remembered, and fog never comes back. A remembered cell shows what was last seen. Draw a minimap of 8 cells each side of the player from that memory, and mark cells beyond the edge as outside.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it