Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24.x"
cache: true

- name: Check formatting
run: test -z "$(gofmt -l .)"

- name: Run tests
run: go test -count=1 ./...

- name: Run race tests
run: go test -count=1 -race ./...

- name: Run vet
run: go vet ./...

- name: Build
run: go build ./...
14 changes: 7 additions & 7 deletions documentation/plans/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Save compatibility is intentionally out of scope. Each iteration only needs to c

Point 1 is complete: the woods snake redesign was merged in PR #26. The remaining order is:

2. **Playtest the full five-map run** — entry/exit flow, FOV blockers, lanterns, bridges, huts, population and the Meteor Field → caves transition.
3. **Woods hardening iteration** — generator invariant validation, exhaustive theme × entry/exit matrix tests, end-to-end run test and a CI gate for format/tests/race/vet/build.
2. **Playtest the full five-map run** — done for the functional pass via automated walk-to-portal, full-run transition and render smoke tests. Manual feel/tuning remains part of step 4.
3. **Woods hardening iteration** — done: generator invariant validation, exhaustive theme × entry/exit matrix tests, end-to-end run test and the CI gate are implemented.
4. **Woods polish iteration** — theme-specific signature loot, difficulty curve, theme atmosphere, map name/exit-direction cues and remaining modal-screen tests.
5. **Next major feature selection** — choose from the roadmap only after the woods run is stable. Keep HUD depth and poisonous-food confirmation as smaller deferred extras.

The individual work items below are grouped by area; the sequence above is the intended order.

## Gameplay and generation

- [ ] **Generator invariant validation** — after generation, verify the sealed border, exactly one entry/exit, connected roads, reachable portal, one landmark, no void tiles and valid bridges.
- [ ] **Exhaustive map matrix tests** — cover every theme × entry/exit combination across many seeds instead of relying on random sampling.
- [ ] **End-to-end run test** — walk Church → shuffled middle themes → Meteor Field → caves through `UsePortal`, not only direct level jumps.
- [x] **Generator invariant validation** — after generation, verify the sealed border, exactly one entry/exit, connected roads, reachable portal, one landmark, no void tiles and valid bridges.
- [x] **Exhaustive map matrix tests** — cover every theme × entry/exit combination across many seeds instead of relying on random sampling.
- [x] **End-to-end run test** — walk Church → shuffled middle themes → Meteor Field → caves through `UsePortal`, not only direct level jumps.
- [ ] **Theme-specific signature loot** — map loot categories to themes instead of using a random category assignment.
- [ ] **Difficulty curve** — make the Church clearly safest and the Meteor Field clearly hardest; tune zombie pressure, villager presence and loot by theme.
- [ ] **Theme atmosphere** — add cemetery fog/smoke, stronger meteor glow, and more mill/pond and church graveyard detail.
Expand All @@ -38,6 +38,6 @@ The individual work items below are grouped by area; the sequence above is the i
## Engineering and process

- [x] **Code cleanup** — remove leftover nine-level woods helpers, unused `ExitMode`, and obsolete water-generation paths if no longer used.
- [ ] **CI gate** — add GitHub Actions running format checks, tests, race tests, vet and build on every PR.
- [x] **CI gate** — add GitHub Actions running format checks, tests, race tests, vet and build on every PR.
- [x] **Docs cleanup** — fix remaining historical 80×46 and nine-level references where they could confuse current behaviour.
- [ ] **Playtest the full five-map run** — verify entry/exit flow, FOV blockers, lanterns, bridges, huts, population and the Meteor Field → caves transition in actual play.
- [x] **Full five-map run walkthrough** — automated walk-to-portal, portal-transition and render smoke tests cover entry/exit flow, connectivity, FOV blockers, lanterns, bridges, huts and the Meteor Field → caves transition.
9 changes: 6 additions & 3 deletions internal/game/woods_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ func (g *Game) generateWoodsLevel(level int) {
if !validWoodsRun(&g.WoodsRun) {
g.WoodsRun = newWoodsRun(g.RNG)
}
theme := g.WoodsRun.Themes[index]
entryEdge := g.WoodsRun.Entries[index]
exitEdge := g.WoodsRun.Exits[index]
g.generateWoodsMap(level, g.WoodsRun.Themes[index], g.WoodsRun.Entries[index], g.WoodsRun.Exits[index])
}

// generateWoodsMap builds a single woods map for an explicit theme and edge
// pair. The normal run path supplies these from WoodsRun; tests use it to cover
// the full theme/edge matrix.
func (g *Game) generateWoodsMap(level, theme, entryEdge, exitEdge int) {
m := NewMap(mapWidth, woodsMapHeight)
m.Theme = 0
m.Name = woodsThemeName(theme)
Expand Down
139 changes: 139 additions & 0 deletions internal/game/woods_hardening_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package game

import (
"strings"
"testing"
)

func TestWoodsMapInvariantMatrix(t *testing.T) {
seed := int64(17000)
for theme := 0; theme < numWoodsMaps; theme++ {
for entry := EdgeNorth; entry <= EdgeWest; entry++ {
for exit := EdgeNorth; exit <= EdgeWest; exit++ {
if entry == exit {
continue
}
for repeat := 0; repeat < 4; repeat++ {
g := NewGame(seed)
g.SetupNewGame(0, "tester")
g.generateWoodsMap(0, theme, entry, exit)
seed++
if problems := woodsMapProblems(g.Map, theme, entry, exit, g.Player.X, g.Player.Y); len(problems) > 0 {
t.Fatalf("theme %d entry %d exit %d seed %d: %s", theme, entry, exit, seed-1, strings.Join(problems, "; "))
}
}
}
}
}
}

func TestWoodsValidatorDetectsBrokenMaps(t *testing.T) {
cases := []struct {
name string
mutate func(g *Game)
}{
{"extra border gap", func(g *Game) { g.Map.SetTile(0, 0, 2) }},
{"missing portal", func(g *Game) {
px, py := findPortal(g)
g.Map.SetTile(px, py, 2)
}},
{"void tile", func(g *Game) { g.Map.SetTile(10, 10, 0) }},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
g := NewGame(17500)
g.SetupNewGame(0, "tester")
g.GenerateLevel(0)
tc.mutate(g)
problems := woodsMapProblems(g.Map, g.WoodsRun.Themes[0], g.WoodsRun.Entries[0], g.WoodsRun.Exits[0], g.Player.X, g.Player.Y)
if len(problems) == 0 {
t.Fatalf("validator accepted a map with %s", tc.name)
}
})
}
}

func TestWoodsRunMapsPassInvariants(t *testing.T) {
for seed := int64(0); seed < 40; seed++ {
g := NewGame(seed + 18000)
g.SetupNewGame(0, "tester")
for level := 0; level < numWoodsMaps; level++ {
g.GenerateLevel(level)
theme := g.WoodsRun.Themes[level]
if problems := woodsMapProblems(g.Map, theme, g.WoodsRun.Entries[level], g.WoodsRun.Exits[level], g.Player.X, g.Player.Y); len(problems) > 0 {
t.Fatalf("seed %d level %d: %s", seed, level, strings.Join(problems, "; "))
}
}
}
}

func TestWoodsRunIsWalkableToEachPortal(t *testing.T) {
for seed := int64(0); seed < 4; seed++ {
g := NewGame(seed + 19500)
g.SetupNewGame(0, "tester")
g.State = StatePlaying
g.Options["optGameUseAI"] = 0
for level := 0; level < numWoodsMaps; level++ {
g.Critters = nil
px, py := findPortal(g)
path := g.findPath(g.Player, px, py)
if len(path) == 0 {
t.Fatalf("seed %d level %d has no walkable path to the portal", seed, level)
}
for _, p := range path {
dx, dy := p.x-g.Player.X, p.y-g.Player.Y
beforeX, beforeY := g.Player.X, g.Player.Y
g.MovePlayer(dx, dy)
if g.Player.X == beforeX && g.Player.Y == beforeY {
// A closed door opens on the first attempt; step through on the second.
g.MovePlayer(dx, dy)
}
if g.Player.X != p.x || g.Player.Y != p.y {
t.Fatalf("seed %d level %d could not walk from %d,%d to %d,%d", seed, level, beforeX, beforeY, p.x, p.y)
}
}
if g.Player.X != px || g.Player.Y != py {
t.Fatalf("seed %d level %d did not reach the portal", seed, level)
}
g.UsePortal()
}
}
}

func TestWoodsRunEndToEndViaPortal(t *testing.T) {
for seed := int64(0); seed < 8; seed++ {
g := NewGame(seed + 19000)
g.SetupNewGame(0, "tester")
for level := 0; level < numWoodsMaps; level++ {
if g.Level != level {
t.Fatalf("seed %d reached level %d, want %d", seed, g.Level, level)
}
if g.WoodsRun.Themes[level] != g.currentWoodsTheme() {
t.Fatalf("seed %d level %d theme mismatch", seed, level)
}
entry := g.WoodsRun.Entries[level]
gaps := edgeGapTiles(g.Map, entry)
if len(gaps) != 1 {
t.Fatalf("seed %d level %d entry edge %d has %d gaps", seed, level, entry, len(gaps))
}
if manhattan(g.Player.X, g.Player.Y, gaps[0][0], gaps[0][1]) > 4 {
t.Fatalf("seed %d level %d player did not start near the entry edge", seed, level)
}

px, py := findPortal(g)
if px < 0 {
t.Fatalf("seed %d level %d has no portal", seed, level)
}
g.Player.X, g.Player.Y = px, py
g.UpdateFOV()
g.UsePortal()
if level < numWoodsMaps-1 {
if g.Level != level+1 || g.Theme != 0 {
t.Fatalf("seed %d portal from level %d reached level %d theme %d", seed, level, g.Level, g.Theme)
}
} else if g.Level != 9 || g.Theme != 1 {
t.Fatalf("seed %d Meteor Field portal reached level %d theme %d, want caves", seed, g.Level, g.Theme)
}
}
}
}
Loading
Loading