Commands

On this page

gozen reads a game directory (game.yaml, data/, assets/) and checks, simulates, documents and packages it. Results go to stdout and diagnostics to stderr.

gozen <command> [<sub-command>] [OPTIONS] [ARGUMENTS]
gozen help <command> [<sub-command>]   # the same as the command with --help
gozen help GZN1101                     # explain a diagnostic code
CommandWhat it does
checkCheck definitions, references, expressions, assets and text layout
simMeasure play without a window: battle, dive, floors, design
playRead and shoot real plays: trace, notes, shots
bookWrite the definitions and events as Markdown
packBuild what you ship: release, trial
artPicture and asset tools: prompt, mosaic, fetch, faces, puppet
themeDungeon themes: add the pictures of a theme to a game, list the themes
version and helpPrint the version; show a command’s help or explain a diagnostic code

A group alone (gozen sim) exits 2 and lists its commands. gozen sim --help shows the group’s page.

Conventions #

  • Exit status: 0 for success and help, 1 when a check, I/O, simulation or capture fails, 2 for invalid arguments. A name the command line gives that the game does not have (a troop, a location, a persona, a shot) is an invalid argument.
  • A diagnostic may end with a code such as [GZN1101]; its first digit is the exit status. gozen help GZN1101 explains it, and Error codes lists them all.
  • Options follow the GNU style. --seed 7 and --seed=7 both work, a few common options have a one-letter form (-n 100, -o DIR, -v, -h), options may come before or after the arguments, and -- ends the options. A single-dash long option such as -seed is rejected with exit status 2.
  • Commands that write a directory (sim design, play notes, pack release, pack trial, play shots) refuse one that already exists, even if empty, and an output inside an input. They never overwrite.
  • Every command except play shots, art faces and art mosaic detection needs nothing beyond the gozen binary: no cgo, display or sound device.

The examples below use game as the game directory, lesson as a troop and grotto as a dungeon location.

check #

Loads every definition, resolves references and expressions, checks that the assets exist, and lays out dialogue with the game’s font. Warnings go to stderr and do not fail the check.

gozen check game
gozen check --only structure game  # structure only, before the game has fonts
gozen check -- -draft              # a directory whose name starts with a dash
gozen check --format json game     # every error and warning as JSON, for a tool or an agent
ok: 2 locations, 1 events, 1 actors, 2 skills, 0 items, 1 enemies, 1 troops, 0 ai sets
data/world.yaml:26:5: locations.grotto.encounters: unknown troop "lessn" [GZN1101]
OptionMeaning
--only structureCheck definitions, references, expressions and assets only; do not read the font or check the text layout. stdout says so.
--only layoutCheck only that dialogue and choices fit the message window, with the game’s font and display rules.
--formattext (the default) or json: a JSON array on stdout with one object per problem, {"file", "line", "col", "path", "message", "severity", "code"}, where severity is error or warning and code is the diagnostic code when the problem has one. An empty game check prints []. It exits 1 when one is an error.
[
  {
    "file": "data/world.yaml",
    "line": 8,
    "col": 15,
    "path": "events.bad.do[0].battle",
    "message": "unknown troop \"wolves\"",
    "severity": "error",
    "code": "GZN1101"
  }
]

--only layout lays out every line of dialogue and every choice with the game’s font and display rules, and reports the ones that overflow. Warnings alone exit 0.

gozen check --only layout game

sim #

Plays the game by its rules alone, with no window or sound. --seed, --turns and --format mean the same in every sim command: the same --seed gives the same result.

sim battle #

Fights the troop with the starting party (or --party, or a saved state) under AUTO and prints the win, loss, flight and draw rates and the average turns. The numbers are the same as the F7 balance panel. The same --seed gives the same result.

gozen sim battle game lesson -n 100
gozen sim battle game lesson -n 100 --party scout --level 5 --seed 7
gozen sim battle game lesson --state memo.save --hp                 # from a note, HP left after a win
gozen sim battle game lesson --state memo.save --as-is --streak 10  # keep the saved HP, count wins in a row
gozen sim battle game lesson -n 1 -v                                # the messages of the first battle
lesson: 100 battles  win 100%  lose 0%  fled 0%  draw 0%  avg turns 1.0  avg standing after a win 1.0
OptionMeaning
--party IDSThe party, as actor IDs separated by commas (default: the starting party)
--level NThe party’s level (default: each actor’s own)
--gear IDSItems to give the party and wear where they fit best
--no-treeDo not spend skill points (by default they go evenly to the open nodes of the lowest level)
--state FILEStart from a saved state (a note’s .save from F9) with everyone recovered
--as-isWith --state, keep the saved HP, MP and states
-n, --battles NBattles to fight (default: 200)
--turns NA battle longer than this is a draw (default: 60)
--seed NThe random seed (default: 1)
--streak NAlso fight again and again without recovery, up to N wins, and print the wins in a row
--hpAlso print the party’s HP left after a win (10th, 50th and 90th percentile)
-v, --verbosePrint the messages of the first battle

sim dive #

Takes the starting party down a dungeon location, fighting --battles battles on each floor, buying better equipment from --shops, resting, and fighting the bosses. Prints the level, HP, gold and win rates of each floor.

gozen sim dive game grotto --floors 3 --battles 5
gozen sim dive game grotto --floors 3 --boss 3:lesson --grind 0.8
gozen sim dive game grotto --floors 4 --rest 2 --boss 2:lesson --tries 50
floor Lv   battles lost   turns  hp_left mp     gold   scenes boss    troops
B1    1    5       0      1.0    1.00    1.00   15     0      -       lesson
B2    1    5       0      1.0    1.00    1.00   30     0      -       lesson
B3    1    5       0      1.0    1.00    1.00   45     0      -       lesson
OptionMeaning
--floors NHow many floors to go down (default: 20)
--battles NBattles fought on each floor (default: 7)
--boss FLOOR:TROOPBosses, separated by commas, fought before going down from that floor
--tries NBattles against each boss to measure its win rate (default: 30)
--grind RATEBefore a boss, fight more on its floor until the win rate reaches RATE (0 to 1)
--turns NA battle longer than this is a draw (default: 60)
--seed NThe random seed (default: 1)
--shops IDSShops whose equipment is bought when better and affordable
--rest NRest (HP and MP full) only every N floors and after a boss; 0 rests on every floor
--supplies ITEM:COUNTItems bought at each rest (with --rest)
--rest-cost EXPRThe gold a rest costs, such as "members * 10"
--rest-event EVENTAn event run at each rest
--back-item ITEMThe item used up to go back to rest
--worn-hp RATE, --worn-mp RATEGo back early when the party’s HP or MP is below RATE
--eventsRun the game’s after_win event after each win and game_over after a loss
--scene-event EVENT, --scene-when EXPRAn event the player sees after a won battle whenever EXPR holds

sim floors #

Generates the floors of a dungeon location and prints each map with the steps to the stairs and the expected encounters. With --try, compares seeds on one floor.

gozen sim floors game grotto --from 1 --to 3
gozen sim floors game grotto --floor 1 --try 3
gozen sim floors game grotto --no-map
OptionMeaning
--from N, --to NThe first and last floor to show (default: 1 to 20)
--floor NShow only this floor; with --try, the floor whose seeds are compared
--try NCompare seeds 0 to N-1 on --floor, one line each
--no-mapPrint the numbers only

sim design #

Plays the game headless with the personas of designeval.yaml (players, rewards and time weights) and writes summary.json, the timelines, band.png and report.md to a new directory. A simulation error keeps the report and exits 1. A small configuration is in the CLI test fixture.

gozen sim design game -o report
gozen sim design game -o report --only walker -v
OptionMeaning
--config FILEThe personas and measures (default: designeval.yaml in the game directory)
--only IDSRun only these personas
-o, --out DIRWrite the run to this new directory (default: <root>/<date>)
--root DIRWhere runs go when --out is not given (default: build/designeval)
--memos DIRWrite notes on marked places to this directory
-v, --verboseWrite each persona’s dives, choices and stumbles to debug.log

sim campaign #

Plays the game’s campaign (Campaigns) many times, headless, with a strategy for the player, and prints the win rate, the turns the campaigns ended in, the mean of the regions each faction held at the start of each turn, the factions that fell and when, the orders given, and how the marches went. Campaign i uses the seed --seed + i, so the same --seed gives the same result.

gozen sim campaign game
gozen sim campaign game --as random -n 500 --format json
gozen sim campaign game --tactic guard
OptionMeaning
-n, --campaigns NCampaigns to play (default: 200)
--as STRATEGYgreedy marches when the odds of the clash (its formulas with rand() at its middle) are good, else gives another order, one with a general first; random gives any order it can; ai plays the player’s faction by its own ai rules (default: greedy)
--tactic IDEvery general marches with this tactic in a clash shown as units (campaign.clash.tactics, or the engine’s front, weakest, strongest, leader, guard), and a march takes the most generals it can; the orders are counted as order:tactic. Compare the win rates of the tactics this way (default: each general’s own)
--orders NOrders a campaign may give before it is cut (default: 2000)

play #

Reads and takes pictures of real plays. The game binary itself is run by its own --dev.

play trace #

Prints a trace written by the game’s --trace in time order. With --check, lists faults of the standing pictures and the music instead and exits 1 if there are any.

gozen play trace run.jsonl
gozen play trace run.jsonl --only say,battle --from 10 --to 60
gozen play trace run.jsonl --check
OptionMeaning
--only KINDSPrint only these kinds, separated by commas: say, scene, battle, menu, view, state, act, problem and so on
--from SECOND, --to SECONDThe time window; --to 0 is the end
--inputAlso print the player’s input
--checkList faults of standing pictures and music; exit 1 if any
--music-late SECONDSWith --check, a song heard later than this after it was asked for is late (default: 0.5)

play notes #

Reads the notes the game writes with F9 and builds an HTML page with thumbnails in a new directory. The notes are not changed.

gozen play notes notes                 # writes notes-html/
gozen play notes notes -o review-html
OptionMeaning
-o, --out DIRWrite the HTML to this new directory (default: <memo-dir>-html)

play shots #

Launches the game binary once per entry of a list and writes PNG, JPEG, an HTML index and shots.json to a new directory. Each shot runs with its own save directory.

gozen play shots game shots.yaml --bin ./mygame --raw -o shots
gozen play shots game shots.yaml --bin ./mygame --raw --only camp --timeout 1m
xvfb-run -a gozen play shots game shots.yaml --bin ./mygame --raw     # unattended on Linux

A list:

shots:
  - id: camp
    title: Camp overview
    start: camp
    wait: 30

id becomes the file name. An entry can also start a scene or an event, stop at a picture, line or answers, or run a script.

OptionMeaning
--bin FILEThe game binary, built with the Gozen runner; required
--rawUse the original assets without checking approval (for local review)
--overlay DIRTake approved replacements from this directory and check approval; pending approval exits 1
--timeout DURATIONThe time limit of one shot, such as 90s or 2m (default: 4m)
-o, --out DIRWrite the shots to this new directory (default: build/shots/<date-time>)
--only IDSTake only these shots

play shots needs what the game window needs: a display and the graphics libraries (on Linux, Xvfb for unattended runs). A failed launch is recorded in the work tree and exits 1.

book #

Writes the locations, events, scenes, troops and items of the game to stdout as one Markdown document. A quick way to review a whole game, or what an agent wrote. The headings follow the game’s language.

gozen book game > book.md

pack #

Copies the game to a new directory. --overlay takes replaced assets from a directory, and --inspect reads the approval records every asset of the overlay must have.

pack release #

Checks the approval records and the assets the game refers to, then copies the game to a new directory, taking replaced assets from an overlay. Any unapproved reference fails the build.

gozen pack release game release --inspect inspect.jsonl
gozen pack release game release --overlay overlay --inspect inspect.jsonl
OptionMeaning
--inspect FILEThe inspection records (JSON Lines) from production; required
--overlay DIRTake replaced assets from this directory (default: the game’s approval settings)
--prefix DIRThe asset directory inside the game, separated by / (default: assets)

pack trial #

Keeps only the definitions and assets reachable within the range of trial.yaml and writes them to a new directory: a demo version of the game.

gozen pack trial game -n                            # count what would be kept, write nothing
gozen pack trial game trial --list trial.txt        # build, and list what was kept and dropped
gozen pack trial game trial --overlay overlay --inspect inspect.jsonl
OptionMeaning
--config FILEThe range settings, relative to the game directory (default: trial.yaml)
--overlay DIR, --inspect FILETake replaced assets from an overlay; the two go together
--list FILEWrite what was kept and dropped to this new file
-n, --dry-runWrite nothing; print only how much would be kept

art #

Tools for the pictures of a game. art prompt assembles image-generation text from a catalog, and art mosaic pixelates regions of images; both are described on Production tools.

art fetch #

Downloads fixed revisions of the detection models (censor, face, head) into the user cache and checks each file against a SHA-256 written in gozen. art mosaic and art faces use a model in the cache when --model is omitted.

gozen art fetch --list     # the models and whether each is in the cache
gozen art fetch face       # the face detector of art faces

art faces #

Finds the face in each standing picture a painted scene (stage:) cuts a balloon face from (the people placed in a stage and the actors’ face pictures) with the anime face detector that gozen art fetch face downloads, and writes the boxes with each picture’s size and SHA-256 to assets/faces.json. The game only reads that file and runs no model, so a web build shows the same faces. A doll’s icon (a face drawn for the balloons) comes first and is not searched, then its face_at, then the box; a picture without a box gets a guessed face, and gozen check warns of it and of a picture changed since.

gozen art fetch face                          # download the model once
gozen art faces game                                 # find the faces
gozen art faces game --preview faces-check           # and look at the boxes and the cut faces
OptionMeaning
--model MODELThe face detection model (default: the one in the cache).
--ort LIBRARYThe ONNX Runtime shared library (default: $ONNXRUNTIME_LIB).
--min SCOREThe lowest score of a face (0.3).
--preview DIRAlso write each picture with its face box and its balloon face to this new directory.

It needs a gozen built with cgo, an ONNX Runtime shared library and the model, as gozen art mosaic does; a build without cgo says so and fails.

art puppet #

Loads a moving portrait (a puppet YAML for the puppet package) with the same checks as puppet.Load and prints where each face, closed-eyes and mouth picture lies on the base picture. A difference picture as large as the base is cut down to the part that differs.

gozen art puppet streamer/puppet.yaml                        # check it and show the positions
gozen art puppet streamer/puppet.yaml --out streamer-packed  # write it with small difference pictures
OptionMeaning
-o, --out DIRWrite the puppet YAML and the cut pictures (each with at) to this new directory. The written YAML has no comments.

It needs nothing beyond the gozen binary: no cgo, display or sound device.

theme #

A dungeon theme is a wall, a floor, a ceiling and a door picture with colors that go together. The gozen binary carries five themes (cave, ice, ruins, castle, crystal); gozen theme add copies one into a game, and theme: cave in a dungeon or one of its looks then fills the walls, floor, ceiling, door and colors that the YAML does not write. The pictures are not part of the game runtime, so a game that uses no theme does not carry them.

theme list #

Prints the name of each theme with a line on how it looks.

gozen theme list

theme add #

Copies wall.jpg, floor.jpg, ceiling.jpg, door.jpg (1024x1024) and theme.yaml (the far fog and map colors), with LICENSE.txt for the pictures, to assets/dungeon/themes/<name>/ of the game. No network is used. A file the game already has is kept, so your own edits stay.

gozen theme add cave game          # the files of the cave theme go to game/assets/dungeon/themes/cave/
gozen theme add cave game --force  # replace the files that are already there
OptionMeaning
--forceReplace the files the game already has.

An unknown theme name exits 2 (GZN2402), and a directory without game.yaml exits 1 (GZN1110). A game that says theme: cave without the folder fails gozen check with GZN1111 and the line run gozen theme add cave <game-dir>. The pictures are CC BY 4.0, see ASSETS.md.

version and help #

gozen version
gozen -v

Prints the version recorded by go install, or devel for a build from source.

gozen help takes the words of a command (gozen help sim battle is gozen sim battle --help), or a diagnostic code:

gozen help sim battle
gozen help GZN2101