mwg API
    Preparing search index...

    Function huffEncode

    • Canonical Huffman plus base64, the game decodes with this same dependency-free code. Two dictionary schemes were tried first and both lost to the data: run-length encoding collapsed because a solved ending is a fine win/draw/loss mosaic rather than broad regions, and LZ77 barely beat raw size on the 4-piece mosaics while tripping over its own match flags. Huffman matches the actual skew (draws dominate, distances cluster near zero) with a decoder a reader can hold in their head.

      Parameters

      • raw: Uint8Array

      Returns string

      import { huffDecode, huffEncode } from '@datamoc/mwg/board';

      console.log(huffDecode(huffEncode(new Uint8Array([2, 2, 2, 3])))); // Uint8Array([2, 2, 2, 3])