2026-11-10 19:53:07 -06:00
|
|
|
|
extends TestBase
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
## Headless checks for the data model and roller.
|
2026-11-25 15:36:55 -06:00
|
|
|
|
## Run: tools/run_tests.sh roller
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
|
2026-11-25 15:36:55 -06:00
|
|
|
|
func run() -> void:
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var board := SampleBoard.create()
|
|
|
|
|
|
var rng := RandomNumberGenerator.new()
|
|
|
|
|
|
rng.seed = 12345
|
|
|
|
|
|
|
|
|
|
|
|
var trinkets := board.get_table("trinkets")
|
|
|
|
|
|
_check(trinkets.entries.size() == 100, "trinkets has 100 entries")
|
|
|
|
|
|
_check(trinkets.die_size() == 100, "trinkets rolls a d100")
|
|
|
|
|
|
var unique := {}
|
|
|
|
|
|
for e in trinkets.entries:
|
|
|
|
|
|
unique[e.text] = true
|
|
|
|
|
|
_check(unique.size() == 100, "trinket entries are unique")
|
|
|
|
|
|
_check(trinkets.num_label(trinkets.entries[0], 0) == "01", "first trinket is numbered 01")
|
|
|
|
|
|
_check(trinkets.num_label(trinkets.entries[99], 99) == "00", "last trinket is numbered 00")
|
|
|
|
|
|
|
|
|
|
|
|
var wild := board.get_table("wilderness")
|
|
|
|
|
|
_check(wild.is_ranged() and wild.die_size() == 100, "wilderness is a ranged d100")
|
|
|
|
|
|
_check(wild.range_problems() == "", "wilderness ranges have no gaps or overlaps")
|
|
|
|
|
|
_check(wild.num_label(wild.entries[5], 5) == "96–00", "last range reads 96–00")
|
|
|
|
|
|
for e in wild.entries:
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(e.pipes.size() == 1, "range %s has exactly one thread" % e.text)
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
# Range weighting: 01–30 should come up about 30% of the time.
|
|
|
|
|
|
var counts := {}
|
2026-11-25 15:36:55 -06:00
|
|
|
|
for i in 4000:
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var n := Roller.roll(board, "wilderness", rng)
|
|
|
|
|
|
var text: String = (n["entry"] as TableEntry).text
|
|
|
|
|
|
counts[text] = counts.get(text, 0) + 1
|
2026-11-25 15:36:55 -06:00
|
|
|
|
var share := float(counts.get("Travelers on the road", 0)) / 4000.0
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
_check(absf(share - 0.30) < 0.02, "01–30 rolls about 30%% of the time (got %.3f)" % share)
|
2026-11-25 15:36:55 -06:00
|
|
|
|
var rare := float(counts.get("An odd find", 0)) / 4000.0
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
_check(absf(rare - 0.05) < 0.01, "96–00 rolls about 5%% of the time (got %.3f)" % rare)
|
|
|
|
|
|
|
|
|
|
|
|
# Chains follow pipes.
|
|
|
|
|
|
var reached := false
|
|
|
|
|
|
for i in 500:
|
|
|
|
|
|
var n := Roller.roll(board, "wilderness", rng)
|
|
|
|
|
|
if Roller.reaches(n, "trinkets"):
|
|
|
|
|
|
reached = true
|
|
|
|
|
|
_check(Roller.flatten(n, []).size() == 2, "wilderness → trinkets chain has two steps")
|
|
|
|
|
|
break
|
|
|
|
|
|
_check(reached, "wilderness can reach trinkets")
|
|
|
|
|
|
|
|
|
|
|
|
# Gaps and overlaps are reported.
|
|
|
|
|
|
wild.entries[1].range_lo = 35
|
|
|
|
|
|
_check(wild.range_problems() == "No result for 31–34.", "gap reported: %s" % wild.range_problems())
|
|
|
|
|
|
wild.entries[1].range_lo = 25
|
|
|
|
|
|
_check(wild.range_problems() == "25–30 matches more than one result.", "overlap reported: %s" % wild.range_problems())
|
|
|
|
|
|
wild.entries[1].range_lo = 31
|
|
|
|
|
|
var n_gap := RollTable.new("g", "Gappy")
|
|
|
|
|
|
var only := TableEntry.new("e1", "Low")
|
|
|
|
|
|
only.has_range = true
|
|
|
|
|
|
only.range_lo = 1
|
|
|
|
|
|
only.range_hi = 50
|
|
|
|
|
|
n_gap.entries.append(only)
|
|
|
|
|
|
var stops := 0
|
|
|
|
|
|
for i in 200:
|
|
|
|
|
|
var b2 := TowerBoard.new()
|
|
|
|
|
|
b2.tables.append(n_gap)
|
|
|
|
|
|
if Roller.roll(b2, "g", rng).has("stop"):
|
|
|
|
|
|
stops += 1
|
|
|
|
|
|
_check(stops > 50 and stops < 150, "rolls into a gap stop with a message (%d/200)" % stops)
|
|
|
|
|
|
|
|
|
|
|
|
# JSON round trip keeps everything.
|
|
|
|
|
|
var copy := TowerBoard.new()
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(copy.load_json(board.to_json()), "spread JSON loads back")
|
|
|
|
|
|
_check(copy.to_json() == board.to_json(), "spread JSON round-trips unchanged")
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
_check(copy.get_table("trinkets").collapsed, "collapsed state is saved")
|
|
|
|
|
|
|
|
|
|
|
|
# Removing a table removes pipes into it.
|
|
|
|
|
|
copy.remove_table("loot")
|
|
|
|
|
|
var dangling := false
|
|
|
|
|
|
for t in copy.tables:
|
|
|
|
|
|
for e in t.entries:
|
|
|
|
|
|
if e.pipes.has("loot"):
|
|
|
|
|
|
dangling = true
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(not dangling and copy.get_table("loot") == null, "removing a table removes threads into it")
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
2026-11-10 19:53:07 -06:00
|
|
|
|
finish()
|