Skip to content

About

A solver for [Logic Pad](https://logic-pad.com) based on cspuz

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

@logic-pad/cspuz-solver

Forked from semiexp/logic-pad-solver. Huge thanks to semiexp for the powerful cspuz solver and the original Logic Pad solver implementation.

A solver for Logic Pad based on cspuz.

Supported rules

  • Global rules
    • Forbidden patterns (Don't make this pattern)
    • Connectivity (Connect all light / dark cells)
    • Shape constraints (All light / dark areas have the same / different shape and size)
    • Region size (All light / dark regions have area N)
    • Total count (There are N light / dark cells in total)
    • Off by X (All numbers are off by X)
    • Underclued (Underclued grid: mark only what is definitely true)
    • Symbols per region (At most / at least / exactly N symbols per light / dark area)
  • Cell rules
    • Fixed tiles
    • Merged tiles
    • Area Number
    • Letter
    • Viewpoint
    • Dart
    • Lotus (with dual-color support)
    • Galaxy (with dual-color support)
    • Minesweeper

Repository layout

This repo has two parts:

  • packages/@logic-pad/cspuz-solver — the solver, published to npm as @logic-pad/cspuz-solver.
  • the web app at the repo root (a Vite + React front-end that consumes the package above via a file: dependency).

Build

Prerequisites:

  • Install Rust with the wasm32-unknown-emscripten target:

    rustup target add wasm32-unknown-emscripten
    
  • Install emscripten (emsdk). Activate it so that emcc is on your PATH before building.

  • Clone cspuz_core next to this repository (as a sibling directory, not inside it). The Rust solver refers to it through the relative path ../../../../cspuz_core, so the layout must be:

    <some-dir>/
    ├── cspuz_core/          # git clone --recursive https://github.com/semiexp/cspuz_core.git
    └── logic-pad-solver/    # this repository
    

    Use --recursive because cspuz_core has its own submodules.

Note: @logic-pad/core used to be vendored as a git submodule under src/logic-pad (which required a manual patch to streamCompressor.ts). It is now a plain npm dependency, so there is nothing to clone or patch — npm install handles it.

The build-rust script uses POSIX commands (cd, cp, &&); on Windows run it from a POSIX shell such as WSL or Git Bash.

Build & publish the npm package (@logic-pad/cspuz-solver)

Build the solver package:

cd packages/@logic-pad/cspuz-solver
npm install
npm run build-rust   # compiles the Rust solver to WebAssembly -> src/core/solver.js
npm pack             # produces @logic-pad/cspuz-solver-<version>.tgz

To publish, either run npm publish --provenance --access public from that directory, or trigger the Publish @logic-pad/cspuz-solver workflow (.github/workflows/publish.yml) on GitHub, which sets up the toolchain and publishes for you.

Build / run the web app

From the repo root:

npm install
# the app links @logic-pad/cspuz-solver via `file:`, so build the solver first:
(cd packages/@logic-pad/cspuz-solver && npm run build-rust)
npm run dev          # start the dev server
npm run build        # create a release build (dist/)

Test

cd packages/@logic-pad/cspuz-solver
npm test

About

A solver for [Logic Pad](https://logic-pad.com) based on cspuz

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages