Chessalyzer
Heatmaps

Heatmap presets

Built-in heatmap functions for common tile and piece questions.

Presets are ready-made heatmap functions — pass one to generateHeatmap and you're done. They come in two flavors: plain presets are used as-is, and scoped presets are little factories you call with a piece or square first.

import { generateHeatmap, TileHeatmapPresets } from 'chessalyzer/trackers';

// plain preset — use directly
const busy = generateHeatmap(tiles.state, TileHeatmapPresets.TILE_OCC_ALL);

// scoped presets — call first, then pass
const queenPath = generateHeatmap(
    tiles.state,
    TileHeatmapPresets.PIECE_MOVED_TO_TILE({ color: 'w', name: 'Qd' }),
);
const e4ByPiece = generateHeatmap(tiles.state, TileHeatmapPresets.TILE_OCC_BY_PIECE('e4'));

On the quickstart file, queenPath.grid is all zeros except h5 and f7 (both 1) — white's queen traveled d1 → h5 → f7 and the game ended there. TypeScript autocompletes both the preset names and their arguments, so exploring from your editor is encouraged.

Referring to pieces

Scoped presets take a HeatmapPieceRef: { color, name }.

  • color: 'w' or 'b'
  • name: the piece's starting square — pawns PaPh, back rank Ra, Nb, Bc, Qd, Ke, Bf, Ng, Rh

Names encode the file, not just the piece type: Nb is specifically the knight that started on b1/b8. Both colors share the same names, which is why color is required.

tileTracker presets

Need tileTracker state.

PresetQuestion it answers
TILE_OCC_ALLHow often did any piece stand on each square? (% of half-moves)
TILE_OCC_WHITESame, white pieces only
TILE_OCC_BLACKSame, black pieces only
TILE_CAPTURE_COUNTHow many captures happened on each square?
TILE_OCC_BY_PIECE(square)Which pieces occupied square, and how much? (% per piece)
PIECE_MOVED_TO_TILE(piece)Where did piece move to? (counts per target square)

Some maps are about pieces, not places

In TILE_OCC_BY_PIECE('e4'), each cell represents a piece (by its starting square), not a board location: on the example file the only non-zero cell is e2 at 68.42 — the pawn that started on e2 accounted for all of e4's occupation. PIECE_CAPTURED and PIECE_CAPTURED_BY below use the same trick.

pieceTracker presets

Need pieceTracker state.

PresetQuestion it answers
PIECE_CAPTURED_BY(piece)Which opposing pieces captured piece, how often?
PIECE_CAPTURED(piece)Which opposing pieces did piece capture, how often?

When none of these quite ask your question, writing your own function is genuinely easy — see Custom heatmap functions.

On this page