Skip to the content

Karakuriからくり

Play eight native puzzles, run bounded searches, step deterministic physics and mount a canvas player controlled by pointer or keyboard.

Karakuri is the Japanese word からくり for a mechanism or ingenious device. About the name

Contents

Getting started

Getting started

Use a native rule namespace or the common controller without a page.

Pour a small Tube Sort state

import { tubeSort } from "@johnmorrisdotca/karakuri";
const tubes=[[0,1],[1,0],[]];
console.log(tubeSort.canPour(tubes,0,2),tubeSort.pourTubes(tubes,0,2));
true [ [ 0 ], [ 1, 0 ], [ 1 ] ]

The eight rule groups remain named namespaces on the main entry. Each retains its native types and operations. /levels supplies the original level collections, /physics the deterministic core, and /play the common controller and canvas mount. The original six import paths remain unchanged.

Create a native controller

import { createController } from "@johnmorrisdotca/karakuri/play";
const controller=createController("tube-sort",1);
console.log(controller.status,controller.gesture,controller.snapshot());
controller.restart();
playing tap {
  tubes: [ [ 2, 0, 2, 1 ], [ 2, 1, 0, 1 ], [ 1, 0, 0, 2 ], [] ],
  pours: 0,
  status: 'playing',
  picked: -1,
  centres: [
    { x: 78, y: 218 },
    { x: 146, y: 218 },
    { x: 214, y: 218 },
    { x: 282, y: 218 }
  ]
}

Player level numbers start at 1; the level arrays use ordinary zero-based indices. The controller owns one level’s current state and translates input into its native rules. Continue with logic puzzles, physics or mounting.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/karakuri 0.2.1.