mwg API
    Preparing search index...

    Function xpAutotilePattern

    • Which XP pattern a cell's 8-neighbourhood bakes to, for maps computed procedurally rather than read from baked data. sameTerrain is asked once per direction, with (dx, dy) offsets ((0, -1) is north); off the map is the caller's to answer (false reads as a border, the edge cell's own value clamps like the editor).

      Parameters

      • sameTerrain: (dx: number, dy: number) => boolean

      Returns number

      import { xpAutotilePattern } from '@datamoc/mwg/two-d/render';

      const filled = new Set(['0,0', '1,0', '0,1', '1,1', '-1,0', '0,-1', '2,1', '1,2']);
      console.log(xpAutotilePattern((dx, dy) => filled.has(`${dx},${dy}`))); // 0 - the interior
      console.log(xpAutotilePattern(() => false)); // 46 - isolated on all sides