feat: gate terrain behind live vision and let armies see - #14
Closed
JJiang28 wants to merge 1 commit into
Closed
Conversation
Terrain was the only thing in the game not filtered by vision. Cities, buildings, armies and tiles all went through the fog filters; the map did not, so any authenticated client could read the whole world — where the fertile land is, where the chokepoints are, where the gold sits. That is exactly what an opponent should have to scout for. Vision is now ephemeral and contested rather than a property of ownership. It comes from watchers: a city watches its footprint, an army watches the tile it stands on. Ground is lit only while something is actually looking at it and goes dark again when that thing leaves, so holding sight of the map becomes a thing to maintain rather than something granted permanently by founding a city. Replace the cities-only vision helpers with a Watcher box so any entity can contribute. Armies previously could not see at all — they were merely filtered by city vision — which meant marching one across the map revealed nothing and a player's view never changed after founding. GetTerrain now returns only currently visible ground, and StreamState carries a fresh VisibleTerrain whenever that set moves. It is always sent whole rather than as a reveal-only delta: tiles leave the set as readily as they enter it, and replacing it outright is the only way client and server cannot drift about what is still lit. Recomputation is skipped on ticks that cannot have moved vision, since it costs a query per subscriber. This is groundwork for buildable watchtowers and fortresses on captured neutral tiles: vision you build, and can lose. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetTerrainnow returns only currently visible ground.Watcherbox so any entity can grant sight, and makes armies see. They previously could not: they were merely filtered by city vision, so marching one across the map revealed nothing and a player's view never changed after founding.StreamStatecarries a freshVisibleTerrainwhenever the visible set moves.Notes for reviewers
Vision is ephemeral by design. Ground is lit only while a city or army is actually watching it and goes dark when that thing leaves. There is deliberately no remembered-terrain model: holding sight of the map is meant to be maintained, which is the groundwork for buildable watchtowers and fortresses on captured neutral tiles — vision you build, and can lose.
VisibleTerrainis always sent whole, never as a reveal-only delta. Because vision is ephemeral, tiles leave the set as readily as they enter it. Sending only reveals would require the client and server to agree on concealments too, and any drift leaves ground permanently lit that should be dark. Replacing the set outright makes that unrepresentable.Recomputation is skipped on stream ticks that cannot have moved vision (resource-only updates), since it costs a query per subscriber and most ticks change nothing.
Follow-up, not in this PR
Watchtower and fortress buildings, and conquering neutral tiles, are deliberately out of scope. A fortress that grants defence is meaningless until combat exists — armies can currently move and merge but not fight.
VisionRadiusis still 3. With ephemeral vision and no remembered terrain, that is a fairly small window on a 75×75 map; it may want raising once watchtowers land and there is a way to extend sight deliberately.Test plan
go build ./...,go vet ./...andgofmt -l internal/ cmd/cleanbuf lintclean;buf generatereproduces the committed output