Skip to content

Store cell memory on discovery, so cells discovered unseen aren't a "chilly void" - #871

Open
MildlyMeticulous wants to merge 16 commits into
tmewett:releasefrom
MildlyMeticulous:fix/telepathy-cell-memory
Open

MildlyMeticulous wants to merge 16 commits into
tmewett:releasefrom
MildlyMeticulous:fix/telepathy-cell-memory

Conversation

@MildlyMeticulous

@MildlyMeticulous MildlyMeticulous commented Jul 25, 2026 •

Copy link
Copy Markdown

Fixes the "a chilly void" case from #200 for cells that are discovered without ever being visible.

Correction to the original description of this PR: I first wrote that telepathy and clairvoyance were affected. That was wrong. updateFieldOfViewDisplay() already calls storeMemories when a cell ceases to be clairvoyantly or telepathically visible, so both systems work correctly on master. See the discussion below.

The remaining case

rememberedTerrain starts as NOTHING (Architect.c:2770), and NOTHING renders and describes as "a chilly void" (Globals.c:321). The only routine that normally writes it is storeMemories (Movement.c:2233), which runs on the transitions where a cell stops being visible.

A cell that becomes DISCOVERED while never having been visible in any sense reaches none of those transitions, so it keeps NOTHING.

Three call sites do that:

site situation
Movement.c:1237 walking into an obstruction you cannot see; discovered on the bump
RogueMain.c:881 the 3x3 around the up-stairs when connectingStairsDiscovered is set on arrival
Items.c:3397 the alarm trap; the following line branches on !playerCanSee(x, y)

The change

One storeMemories(x, y) call inside the !DISCOVERED guard in discoverCell(), so a cell gets its memory written the moment it is discovered.

This adds to rather than replaces the existing calls. Those fire when a cell leaves view and capture the terrain as it stands at that moment, which is what keeps memory current for a cell that changed while you were watching it. For a normally seen cell this change means one extra write at discovery.

Not verified in a live game

I found this by reading the code, not by playing. The mechanism above is traceable statically, but I have not sat down and bumped into a wall in the dark to confirm the message. Worth someone doing before this lands.

@Hectocotylus

Hectocotylus commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

I'm not opposed to centralizing the storeMemories call, but I don't think the rationale is right. Both telepathy and clairvoyance are completely functional on master, as far as I can tell. Did you reproduce this bug in either system recently?

In any case, the existing callsites in Time.c and Movement.c should be removed in conjunction with this change. Otherwise, I think they'll be doing redundant writes.

@MildlyMeticulous

Copy link
Copy Markdown
Author

You're right, and thank you for pushing on it. I did not reproduce this in a live game. I found it by reading, and my rationale in the PR description is wrong.

Telepathy and clairvoyance are fine on master. updateFieldOfViewDisplay() has "ceased being clairvoyantly visible" and "ceased being telepathically visible" branches that both call storeMemories, so those cells do get their memory written when the effect drops. I misread that as only the VISIBLE/WAS_VISIBLE case. My description of the cause should not have said telepathy or clairvoyance.

What I think is still real is narrower: cells that become DISCOVERED without ever being any kind of visible, so they never reach a "ceased being X visible" branch at all. rememberedTerrain is initialised to NOTHING in Architect.c:2770, and storeMemories in Movement.c:2233 is the only thing that normally writes it, so those cells keep NOTHING, which is "a chilly void" in Globals.c:321.

Three paths reach discoverCell() that way:

  • Movement.c:1237 walking into an obstruction you cannot see. The cell is marked discovered on the bump, and in an unlit area it was never visible.
  • RogueMain.c:881 the 3x3 around the up-stairs when connectingStairsDiscovered is set on arrival.
  • Items.c:3397 the alarm trap, where the very next line branches on !playerCanSee(x, y), so the discovered cell can be off-screen.

On removing the existing callsites: I don't think they are redundant, and I'd rather not touch them. They fire when a cell stops being visible, which captures whatever the terrain looks like at that moment. A cell you watched change while it was in view, a door that opened, something that burned or flooded, needs that later write to update its memory. If discovery were the only write, memory would freeze at first sight. What my change adds is only the initial write for cells that would otherwise never get one, so for a normally seen cell it is one extra write at discovery rather than a replacement.

If that reading is still off, or the three cases above aren't worth the extra write on every discovery, I'm happy to narrow this to just discoverCell's callers that can't be visible, or to close it. Either way I'll correct the PR description so it isn't claiming something untrue about telepathy.

@nstoddard

Copy link
Copy Markdown
Collaborator

Do either of you know of any cases where storeMemories should not be called when calling discoverCell? I'm trying to decide between this PR or #870; currently I'm leaning towards this PR because it'll automatically fix all instances of this issue while the other PR has to specifically handle each situation that can cause the "chilly void" text (and it's hard to verify it fixes all of them).

I wouldn't worry too much about redundant writes; storeMemories looks quite cheap so it's fine if it's sometimes called redundantly.

If we choose this PR instead of the other one: the PR/commit title and the comment in the code will need to be updated to reflect that this applies to stairs/alarm traps/etc instead of telepathy/clairvoyance, and it should probably have a changes file.

@MildlyMeticulous
MildlyMeticulous force-pushed the fix/telepathy-cell-memory branch from b359f7a to e0f0258 Compare July 25, 2026 06:58
@MildlyMeticulous MildlyMeticulous changed the title Store cell memory on discovery, fixing "chilly void" for telepathy/clairvoyance (#200) Store cell memory on discovery, so cells discovered unseen aren't a "chilly void" Jul 25, 2026
@MildlyMeticulous

Copy link
Copy Markdown
Author

Do either of you know of any cases where storeMemories should not be called when calling discoverCell?

I went looking for one and could not find any that causes harm. Working through what it writes:

pmap[x][y].rememberedTerrainFlags = terrainFlags((pos){ x, y });
pmap[x][y].rememberedTMFlags      = terrainMechFlags((pos){ x, y });
pmap[x][y].rememberedCellFlags    = pmap[x][y].flags;
pmap[x][y].rememberedTerrain      = pmap[x][y].layers[highestPriorityLayer(x, y, false)];

The one worth a second look is rememberedCellFlags, because it copies the whole flag word, including transient bits like HAS_ITEM and HAS_MONSTER. So discovery-time memory can record that something was standing there.

Two things make me think that is acceptable rather than a problem:

  • It is not a new class of behaviour. A normally seen cell already snapshots those same bits when it stops being visible, so the memory can already be stale in exactly this way. This change applies the existing behaviour to more cells, it does not introduce a new kind of staleness.
  • It does not leak item identity. What the player remembers seeing on the floor lives in rememberedItemCategory / rememberedItemKind / rememberedItemQuantity, which are written in IO.c around line 1289, not by storeMemories. So a cell discovered by bumping a wall in the dark does not gain a remembered item.

The only readers of the remembered flag word are monsterAvoids() and populateCreatureCostMap(), both via getLocationFlags(..., limitToPlayerKnowledge), so the blast radius is pathing rather than display.

There is also a small argument the other way, which surprised me. initializeLevel sets

pmap[i][j].rememberedTerrainFlags = (T_OBSTRUCTS_EVERYTHING);

so a cell that is DISCOVERED but has never been through storeMemories is remembered as obstructing everything. For the stairs neighbourhood in RogueMain.c those are ordinary floor cells, and until the player actually lays eyes on them the player's own cost map treats them as obstructions. Storing memory at discovery corrects that too. I have not confirmed that one in a live game, so treat it as reading rather than a report.

On the two PRs, the difference in coverage is one case. #870 patches Items.c and RogueMain.c, which covers the alarm trap and the stairs. Neither touches Movement.c:1237, where walking into an obstruction you cannot see marks it DISCOVERED on the bump. In an unlit area that cell was never visible, so it reaches no "ceased being visible" branch either and stays a void. Centralising in discoverCell() picks that up without anyone having to notice it.

I have pushed the changes you asked for:

  • commit and PR title now describe stairs, alarm traps and bumped obstructions rather than telepathy
  • the code comment is rewritten to match
  • added changes/871-store-memories-on-discovery

The branch is still named fix/telepathy-cell-memory from before I understood the bug properly. Say the word if you would rather I opened a fresh PR under an accurate name and closed this one.

A cell stores its memory in storeMemories() when it stops being visible.
A cell that becomes DISCOVERED without ever having been visible reaches no
such transition, so it keeps rememberedTerrain as NOTHING, which describes
as "a chilly void".

Three call sites discover a cell that way: bumping into an obstruction in
the dark (Movement.c), the cells around the up-stairs on arrival
(RogueMain.c), and an alarm trap sprung out of sight (Items.c).

Calling storeMemories() from discoverCell() covers all of them at once,
including any future caller, rather than patching each site.
@MildlyMeticulous
MildlyMeticulous force-pushed the fix/telepathy-cell-memory branch from e0f0258 to c32ec4f Compare July 25, 2026 07:02
@nstoddard

Copy link
Copy Markdown
Collaborator

Thanks! I don't think the branch name is a big deal. Tiles no longer always being considered obstructions probably isn't an issue, or at least it wasn't in the (limited) testing I did.

After testing this with a chasm+stairs, I feel it's a little odd that tiles are described with text like "You remember seeing the ground here" when the player hasn't technically seen that tile. I wonder if it would sound more natural if in these cases, such tiles were marked as magic mapped instead of discovered, so it would be printed as "You expect the ground to be here"? If this would be difficult to implement, or would cause other issues, don't worry about it; it's already much better than the "chilly void" text.

@MildlyMeticulous

Copy link
Copy Markdown
Author

Thanks for testing it, especially the chasm and stairs case.

I looked into the magic-mapped idea and I think it pulls against the centralising, so I'd lean towards leaving it, but here is what I found so you can decide.

The wording comes from Movement.c around line 246:

if (pmap[x][y].flags & DISCOVERED) {          // "you remember seeing %s here."
    ...
} else if (pmap[x][y].flags & MAGIC_MAPPED) { // "you expect %s to be here."

DISCOVERED is tested first, so a cell holding both flags still reads as remembered. To get "you expect" the cell has to be MAGIC_MAPPED and not DISCOVERED.

That is the part that causes trouble. discoverCell() cannot make that choice, because it is also the function called when a cell genuinely becomes visible, from the "became visible this move" branch in updateFieldOfViewDisplay() (Movement.c:2272). If it stopped setting DISCOVERED, or set MAGIC_MAPPED instead, ordinary seen tiles would be affected. It would also change rogue.xpxpThisTurn, which only counts on the !DISCOVERED transition.

So the distinction has to be made by the caller, since only the caller knows whether the player actually laid eyes on the cell. Which puts us back at enumerating each site, the thing #870 does and the reason you were leaning this way instead.

Two ways forward that keep the centralised fix:

  1. Leave it. The tile is described accurately even if the verb is generous, and as you say it beats "a chilly void".
  2. Do it properly in a follow-up: give the unseen sites (RogueMain.c stairs, Items.c alarm trap, Movement.c bump) MAGIC_MAPPED alongside DISCOVERED, and change the check in Movement.c to prefer the "expect" wording when the cell has never been visible. That needs a way to know "never actually seen", which no flag currently records, so it is its own change with its own risks.

My preference is 1 for this PR and 2 later if it still bothers anyone, but I am happy to attempt 2 here if you would rather it landed in one go.

@nstoddard

Copy link
Copy Markdown
Collaborator

Thanks for looking into the magic mapping idea. I agree with your conclusion: let's keep this PR as it is rather than trying the magic mapping version. After thinking about it a bit more, I'm not sure if the magic mapping idea is worth pursuing, since there's so many other issues that seem higher priority than a small wording improvement (though you can work on it if you want, of course).

For this PR we should still test the other 2 cases: the alarm trap, and walking into a wall you can't see.

@MildlyMeticulous

Copy link
Copy Markdown
Author

Agreed on leaving the magic mapping alone. It was a wording nicety and you clearly have higher priorities in the queue.

That leaves the alarm trap and the unseen wall bump to test. I'd rather set those up properly than poke at them and report something half-checked, so let me come back to it. The trap case needs one triggered while it's off screen, and the bump case needs an unlit dead end, so both want a seeded run rather than a quick look. I'll post what I actually see, including if either of them turns out not to behave the way I described.

Thanks for the testing you've already put into this one.

@Hectocotylus

Copy link
Copy Markdown
Contributor

@MildlyMeticulous I'd personally appreciate it if you avoid copy-pasting Claude output in these comment chains. I'm not criticizing your usage (I recognize it because I use it myself), but it's exceedingly verbose and I'd rather hear your direct takes.

As for the other callsites, I agree with your assessment that they are not redundant.

I support this PR over #870, and I have a setup for testing the alarm trap case. I'll report back once I have a chance to check it against this branch.

@Hectocotylus

Copy link
Copy Markdown
Contributor

Tested it out on both alarms and stairs and it looks good to me 👍

@MildlyMeticulous

Copy link
Copy Markdown
Author

Hectocotylus has covered alarms and stairs. I said I'd test the wall bump myself and I haven't — no working build on this machine, so I'd rather say so than leave it hanging.

Both cases go through the single storeMemories call in discoverCell, so stairs passing means the bump takes the identical path. Happy for someone to confirm it directly rather than take that on inference.

@tmewett
tmewett changed the base branch from master to release August 5, 2026 12:45
@tmewett

tmewett commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Thanks, as you all discussed, let's go with this PR.

Please could you rebase onto 'release'?

And please could you disclose AI usage in the description or commit message, such as in a co-authored-by tag?

@brturn

brturn commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

@MildlyMeticulous - please rebase to drop the unrelated commits. Thanks!

Confirmed that bumping into unseen walls is not described as chilly void.

@brturn brturn linked an issue Oct 17, 2026 that may be closed by this pull request
@brturn

brturn commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Looks abandoned, marking it for attention.

@brturn brturn added the help wanted Extra attention is needed label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cells remembered from telepathy are described as "chilly void"

7 participants