Random Prompt Syntax
MooshieUI supports Dynamic-Prompts-compatible alternation syntax in both the positive and negative prompt boxes. Each time you generate, the expander resolves every alternation block before the prompt reaches ComfyUI or NovelAI. The gallery stores the resolved prompt, so importing its metadata restores the selected text without rerolling it. Identical pixels also depend on the model, settings and runtime; metadata alone is not a guarantee.
#Basic alternation
Pick one option at random:
{red|green|blue} carEach submission resolves the template using the generation seed. The same template and fixed seed pick the same options; seed -1 chooses a new seed.
#Picking multiple options
Pick exactly N distinct options, joined with ", ":
{2$$fluffy|sleek|shiny|matte} texturePick a random count in a range:
{1-3$$bokeh|depth of field|lens flare}Use a custom separator:
{2$$ and $$watercolor|oil paint|pencil sketch}#Weights
Make one option more likely with N:: prefix (default weight is 1):
{3::masterpiece|1::rough sketch}Here "masterpiece" is three times as likely as "rough sketch".
#Nesting
Inner blocks are expanded first:
{a sunny {morning|afternoon}|a rainy evening}This can produce: "a sunny morning", "a sunny afternoon", or "a rainy evening".
#Literal escapes
Use backslash to include a brace or pipe literally:
\{not random\} -> {not random}
{a\|b|c} -> picks from "a|b" or "c"Note: escapes are only processed when alternation syntax is present in the same prompt string.
#Braces without alternation
NovelAI uses {tag} for emphasis and {tag:1.5} for weighted emphasis.
Any {...} block that contains no top-level | is left completely untouched,
so existing NovelAI prompts and prompt scheduling tags work unchanged.
#UI indicator
When the prompt box contains alternation syntax, a small dice badge appears next to the prompt header. Hover over it to see an example roll. Click it to see a different roll. The prompt box always shows the template; only the submitted (resolved) prompt changes each generation.
#File wildcards
__name__ picks one line from a wildcard file in <app data>/wildcards/
(the Wildcards tab in the bottom panel lists, edits and creates them, and its
folder button opens the folder). The layout follows Dynamic Prompts, so packs
made for it work as they are:
| File | Typed as |
|---|---|
colors.txt (one option per line, # lines are comments) |
__colors__ |
hair/styles.txt |
__hair/styles__ |
pack.yaml or pack.json with outfits: { casual: [...] } |
__outfits/casual__ (also __pack/outfits/casual__) |
- A map key alone (
__outfits__) picks from every option under it, and*matches across names (__hair/*__). - Options may contain more wildcards and
{a|b}alternation. - Picks are seeded from the generation seed like alternation, so a fixed seed
repeats them. Brackets around a token (
[__hat__]) stay around the pick. - In order (per name, in the Wildcards tab) takes the next line each time a generation is sent instead of a random one, independent of the seed. With continuous generation this walks a list once per run.
- Unknown names are left as written. Expansion runs in
toParams(), so the gallery and MCP see the resolved prompt.
#Implementation notes
- Expander:
src/lib/utils/randomPrompt.ts; file wildcards:src/lib/utils/wildcards.ts,src/lib/stores/wildcards.svelte.ts,src-tauri/src/commands/wildcards.rs - Called from
toParams()insrc/lib/stores/generation.svelte.ts, right after inline preset resolution and before scheduling / regional tag parsing. - PRNG: splitmix32 seeded from
(userSeed >>> 0). When seed is -1 (random), a fresh random integer is chosen for this submission. - Negative prompt uses
rngSeed + 1to ensure a different stream from the positive prompt. - The resolved (expanded) prompt is what the workflow and gallery metadata receive; the template text stays in the UI.