Skip to content

jengine-sudoku

Sudoku under six rules - generated with one answer, graded by the logic a person uses - and Ninefold.

KindProject package: linked into the builds of the projects that list it
Sourcepackages/jengine-sudoku
Version0.1.0
Entry pointjengine_sudoku::SudokuPackage
Script namespaceSudoku
Listed byprojects/arcade-classics

List it in the top-level "packages" array of project.jengine:

{
"packages": [
{ "name": "jengine-sudoku", "source": { "type": "path", "path": "../../packages/jengine-sudoku" } }
]
}

Then rebuild the editor viewport for the project (jengine viewport-build projects/<name>, or the editor’s Rebuild viewport banner). Native and web builds link it on their own.

A scene that uses its components must be a v2 scene ("version": 2): a v1 scene has no field for a package component and keeps it as inert custom data.

A script can check that the package is linked with if Sudoku == nil then return end.

Scene keyRust type
nf_boardBoardpackage only: needs a v2 scene

Commands run in every runtime and return nothing; a package publishes what scripts read onto components (see the notes below). The flat name also works.

CallFlat name
Sudoku.new(e, variant, difficulty, seed)nf_new
Sudoku.resume(e, variant, difficulty, seed, values, notes, time, hints, mistakes)nf_resume
Sudoku.stop(e)nf_stop
Sudoku.press(e, x, y)nf_press
Sudoku.move(e, dx, dy)nf_move
Sudoku.digit(e, d)nf_digit
Sudoku.erase(e)nf_erase
Sudoku.notes(e)nf_notes
Sudoku.undo(e)nf_undo
Sudoku.hint(e)nf_hint
Sudoku.pause(e, paused)nf_pause
Sudoku.assist(e, on)nf_assist
  • projects/arcade-classics/assets/scenes/ninefold.scene

From packages/jengine-sudoku/src/lib.rs.

Sudoku under six rules - and Ninefold, the arcade’s number puzzle.

rules says what a grid is: a list of houses (and, for Killer, cages), so Classic, Mini (6 x 6), Diagonal, Windoku and Jigsaw are one rule over different houses. solve counts solutions; logic solves the way a person does and says how hard that was; generate makes a puzzle from a seed that has exactly one answer and needs no harder logic than its difficulty allows; game is a puzzle being played.

This module draws it. The board, the notes and the number pad are all entities the package owns - sprites for cells and lines, world text in the arcade’s large .font for digits - and a tap is one command, Request::Press, hit-tested here against the same rects that were drawn. So a game is playable with nothing but a finger, and a test plays it by the same points.

One nf_board on a manager entity: centre and size of the board, pad_centre and key (the number pad’s key size), font with its digit_top / digit_height (where a digit sits in its line, which tools/gen_tabletop_font.py prints), white (a white texture) and round (a rounded square drawn nine-sliced for keys).

CallDoes
Sudoku.new(e, variant, difficulty, seed)a new puzzle: classic, mini, diagonal, windoku, jigsaw, killer; easy … expert
Sudoku.resume(e, variant, difficulty, seed, values, notes, time, hints, mistakes)the same puzzle again, with a saved grid
Sudoku.stop(e)clear the board
Sudoku.press(e, x, y)a tap at a world point: a cell selects, a key acts
Sudoku.move(e, dx, dy)move the selection
Sudoku.digit(e, d) / Sudoku.erase(e) / Sudoku.notes(e) / Sudoku.undo(e) / Sudoku.hint(e)what the keys do
Sudoku.pause(e, paused)stop the clock and hide the digits
Sudoku.assist(e, on)show wrong entries in red as they are made

The nf_board bag: active, variant, difficulty, seed, n, clues, filled, cells, time, mistakes, hints, notes (note mode), selected, solved, level (the logic grade), values and notes_text (what nf_resume takes back), and events: started, placed (correct), noted, erased, undone, given, hint (text), house, solved (time, hints, mistakes), full_wrong.