Individual skill
fog-of-war-js-ts
Fog of war, field of view, line of sight, and tile visibility in JavaScript or TypeScript games — roguelikes, RTS, top-down, or strategy maps. Covers efficient FOV algorithms (recursive and symmetric shadowcasting, DDA raycasting, 2D visibility polygons), update scheduling and multi-viewer reference counting, typed-array and bitset state, canvas and WebGL fog rendering, memory and large-map scaling, hot-loop geometry math, and visibility correctness. Trigger when implementing, reviewing, or optimizing such code — even when the user only says "fog of war", "reveal the map", "what can this unit see", "shadowcasting", or "visibility grid" without mentioning performance — the naive raycast-per-cell-every-frame approach is usually what needs replacing. Prefer these patterns when writing new visibility code or refactoring slow or buggy fog.
skills/.experimental/fog-of-war-js-ts/SKILL.md
Source commit cf93c57cac89d6fc3e4194686000411567f5caf3
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- Yes
- Repository scan complete
- No
- Skill scan complete
- Yes
- Observed behavior
- Instructions only
- Last checked
- Nov 5, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 221
- Repository last updated
- Aug 15, 2026
- License
- MIT
Observed agent integration: codex
- writing Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
AGENTS.mddoc · 10,093 bytesSKILL.mdcore · 8,966 bytesassets/templates/_template.mddoc · 1,843 bytesmetadata.jsonasset · 1,660 bytesreferences/_sections.mddoc · 2,849 bytesreferences/correct-corner-peeking.mddoc · 1,839 bytesreferences/correct-explored-not-overwritten.mddoc · 1,758 bytesreferences/correct-permissiveness-model.mddoc · 1,940 bytesreferences/correct-symmetric-walls.mddoc · 1,760 bytesreferences/fov-dda-continuous.mddoc · 2,475 bytesreferences/fov-octant-transforms.mddoc · 2,413 bytesreferences/fov-radius-bounded-scan.mddoc · 1,899 bytesreferences/fov-recursive-shadowcasting.mddoc · 3,463 bytesreferences/fov-single-ray-los.mddoc · 2,013 bytesreferences/fov-symmetric-shadowcasting.mddoc · 2,637 bytesreferences/fov-visibility-polygon.mddoc · 2,178 bytesreferences/geo-avoid-modulo-deindex.mddoc · 1,608 bytesreferences/geo-avoid-trig-in-loop.mddoc · 1,784 bytesreferences/geo-integer-slope-shadows.mddoc · 1,740 bytesreferences/geo-radius-shape-choice.mddoc · 1,743 bytesreferences/geo-squared-distance.mddoc · 1,399 bytesreferences/mem-bitpack-explored.mddoc · 1,635 bytesreferences/mem-clear-with-fill.mddoc · 1,567 bytesreferences/mem-generation-stamp.mddoc · 1,777 bytesreferences/mem-no-hot-loop-closures.mddoc · 1,662 bytesreferences/mem-reuse-buffers.mddoc · 1,771 bytesreferences/render-dirty-region-only.mddoc · 1,615 bytesreferences/render-fade-alpha-lerp.mddoc · 1,882 bytesreferences/render-imagedata-not-fillrect.mddoc · 2,287 bytesreferences/render-lowres-soft-upscale.mddoc · 2,018 bytesreferences/render-offscreen-fog-layer.mddoc · 1,934 bytesreferences/render-webgl-texsubimage.mddoc · 1,948 bytesreferences/scale-cap-recompute-budget.mddoc · 1,647 bytesreferences/scale-chunk-large-maps.mddoc · 1,954 bytesreferences/scale-gameplay-vs-render-culling.mddoc · 1,723 bytesreferences/scale-shared-team-visibility.mddoc · 1,712 bytesreferences/scale-spatial-partition-edits.mddoc · 1,919 bytesreferences/state-bitset-layers.mddoc · 1,869 bytesreferences/state-flat-1d-index.mddoc · 1,589 bytesreferences/state-no-string-keys.mddoc · 1,758 bytesreferences/state-row-major-iteration.mddoc · 1,460 bytesreferences/state-three-state-encoding.mddoc · 1,912 bytesreferences/state-typed-arrays.mddoc · 1,651 bytesreferences/update-debounce-map-edits.mddoc · 1,737 bytesreferences/update-delta-not-clear.mddoc · 1,946 bytesreferences/update-dirty-flag.mddoc · 1,754 bytesreferences/update-merge-explored.mddoc · 1,882 bytesreferences/update-recompute-on-move.mddoc · 2,294 bytesreferences/update-refcount-visibility.mddoc · 1,970 bytes
Read excerpt
# dot-skills Fog of War (JavaScript/TypeScript) Best Practices
Performance and correctness guide for fog of war and field-of-view systems in JS/TS games, distilled from the canonical FOV literature (Björn Bergström, Albert Ford, Adam Milazzo), Red Blob Games, rot.js, and the MDN/WebGL rendering APIs. Contains 44 rules across 8 categories, ordered by impact, to guide writing, reviewing, and refactoring visibility code.
## When to Apply
Reference these guidelines when:
- Implementing field of view, line of sight, or tile visibility for a grid or continuous map
- Building or refactoring a fog-of-war display (unexplored / explored / visible layers)
- Diagnosing slow fog (recompute every frame), visual artifacts (flicker, light leaks), or memory blowups on large maps
- Scaling visibility to many units (RTS) or to large/streaming worlds
- Choosing how to store and render the visibility/explored state
## Rule Categories by Priority