This is the text format of Anchorfall's Puzzle Maker, from https://playanchorfall.com/puzzle-maker. If you are an AI assistant helping a player, write the whole puzzle as plain text in this format, ready to paste. The player pastes it into the Puzzle Maker, which the PUZZLE arc on the mode wheel of the game's Play tab opens. If the game refuses the puzzle, the player will paste the refusal back to you: it names the line or the limit at fault, so fix that and give the whole puzzle again.

## Puzzle Maker: the puzzle text format

A puzzle is a board written as plain text. In the game's Play tab, choose PUZZLE on the mode wheel
to open the Puzzle Maker: a small editor with a text box for the puzzle, a Round field and START.
Paste the text, press START, and you are dropped into that board in the Planning phase, playing
against the game's practice AI.
Nothing is at stake: a puzzle pays no Marks, moves no rating, advances no quest and is not kept in
your match history. You leave it by conceding. The syntax is Artifact Foundry's Puzzle Maker's, so a
board typed for Foundry reads here, but what it means is defined below, not by Foundry. One addition
is Anchorfall's own: `Enchant(...)` (below) has no counterpart in Foundry's Puzzle Maker, so a board
that uses it does not read in Foundry.

### Players and how the board starts

- **Player 1 is you, the solver.** Player 0 is played by the AI.
- The board starts in the Planning phase of the round you choose (the editor offers round 3, by
  which every hero in the Fountain may deploy; the first round with a Planning phase is round 1).
- You act first, unless a `Mode Rules` line states `[starting_initiative_player=0]`, which gives the
  AI the first action.
- Randomness (shuffles, random effects, what the AI plays) is the match's own: two attempts at one
  puzzle can play out differently.
- The Shop runs between rounds as in any match.
- A player with no `Deck` section has an empty deck. A `Deck` is drawn as written: its first line is
  the first card drawn. A card that shuffles a deck in play still shuffles it.
- A player's creep faction (which lane creeps it spawns) is the faction of its first non-neutral unit,
  or the first faction when it has none.

### Sections

A line that names a section starts it; every later line belongs to it until the next section. Text
after `//` on a line is a comment. Blank lines are ignored. Lanes are numbered 1 to 3. A section
may appear more than once; its entries add up.

| Section | Holds |
| --- | --- |
| `Mode Rules` | `[starting_initiative_player=0]` or `[starting_initiative_player=1]`. Any other rule is noted, not posed. |
| `Player 0`, `Player 1` | `[Mana=…, UsedMana=…, Gold=…]`. The Mana a player has left is `Mana` minus `UsedMana`. A player with no `Mana` or `Gold` stated has none. |
| `Player N Hand` | One card per line. |
| `Player N Deck` | One card per line, first line drawn first. |
| `Player N Fountain` | One hero per line, resting in the Fountain. |
| `Player N Combat L` | The units in lane `L`, filling its five slots from the first in line order. `Empty` leaves a slot open. A hero placed here is deployed. |
| `Player N Improvements L` | Up to five improvements in lane `L`. |
| `Player N Tower L` | `Defense Tower`, optionally `[Damage=n]` (0 to 29 of its 30 Health). `Ancient Tower` is noted, not posed. |
| `Solution` | Free text; every line is noted, not posed. |

### Entries

An entry is `Name #Tag [Key=Value, Flag] Equip(Item) Enchant(Enchantment)`. Names are card names, in
any letter case.

- `#Tag` names the entry (units and improvements only); a tag is used once.
- **A stated value adds to what the card prints; it does not set it.** `Attack=5` is five more Attack,
  `Attack=-2` two less; `Health` and `Armor` work the same way.
- Keywords: `Cleave`, `Retaliate`, `Siege`, `Trample`, `Regeneration`, `Decay`, `Piercing`, `Feeble`,
  `Quickstrike`, `DeathShield`, `Stunned`, `Silenced`, `Disarmed`, `Rooted`, `DamageImmune`. A bare
  flag or `=true` grants the keyword at its usual value, `=N` at value N, `=0` or `=false` grants
  nothing. A keyword is granted on top of a printed one, so `=false` does not remove a printed keyword.
- `Damage=n` on a unit in a `Combat` section is damage it has already taken.
- `TurnsUntilDeployment=n` on a Fountain hero is the rounds until it can deploy (0 to 255).
- `AbilityCooldown=0` readies the unit's abilities and its items'. Without it a hero's Active has
  as many rounds left as in a match at that round: its printed cooldown less the chosen round, so
  Axe's Active 2 has 1 round left in round 1 and is ready from round 2.
- `Equip(Item)` (only on a hero, up to its item slots, each item once) puts an item on it. On a hero on
  the board it is a real equip: the item's On Equip effects happen. On a Fountain hero the item rests
  with it and attaches when the hero deploys.
- `Enchant(Enchantment)` (Anchorfall only; on a unit in a `Combat` section or a hero in the
  `Fountain`) puts an enchantment on it, already attached: from then on it works as if its card
  had been played on that unit, but the rest of that card's play effect does not happen. State it
  yourself where it matters (Caught Unprepared's Stun is `[Stunned]`). Write it once per copy:
  `Enchant(Soul of Spring) Enchant(Soul of Spring)` gives two. The unit has to be one the card can
  enchant: a card that enchants a hero goes only on a hero, one that enchants its caster on a hero
  or a creep that is a caster (such as Acolyte of the Radiant). An enchantment that targets
  enemies belongs to the other player, so its effects are that player's; every other one belongs
  to the unit's player. On a Fountain hero the enchantment rests with it, as if the hero
  had been returned to the Fountain enchanted, and acts again once the hero deploys.

### What is noted and not posed

This game cannot pose these Foundry constructs. The game lists each with its line and asks before
it starts the board without them: mode rules other than `starting_initiative_player` (for example
`dcg_shop_exists=0` or a tower-health rule), `LaneProhibition`, `LaneRequirement`,
`LovesToBeBlocked`, `HatesToBeBlocked`, `CombatImmune`, `Charges`, `AbilityCharges`,
`PassiveCharges`, an `AbilityCooldown` other than 0, a hand or deck card's `ManaCost`, `GoldCost`,
`Repeated`, `Quick`, `Revealed` or `Color`, a tower's `Armor` or `LaneAffinity`, an `Ancient Tower`,
and every `Solution` line.

### What is refused

The game refuses a puzzle, naming the line, when a line does not mean something where it stands:
an unknown card, attribute or section; an attribute or `#Tag` stated twice on one entry, a `#Tag`
used twice, or a player's `Mana`, `UsedMana` or `Gold`, a lane's tower or `starting_initiative_player`
stated twice; a tag, item or enchantment where the section takes none (hand, deck and tower entries
take none of them, improvements take a tag); `Empty` outside a `Combat` section or with anything
stated on it; an item on anything but a hero, of anything but an item a hero wears, or the same item
twice; an enchantment that is not a card that enchants a unit, or that does not enchant that kind
of unit; anything stated inside `Enchant(...)` but the card's name; a card that is not an
improvement in an `Improvements` section; a value out of range; more entries than a lane or its
improvements hold; `UsedMana` above `Mana`.

It refuses without a line what only the built board shows: a unit left with no Health, a wound past
its Health, an item its hero has no room for, a unit an item's On Equip moves out of its slot, or a
round in which the board cannot be in Planning.

### Limits

| What | At most |
| --- | --- |
| Puzzle text | 65,536 bytes and 2,048 lines |
| Round | 99 |
| Heroes per player (board and Fountain together) | 10 for Player 1, 3 for Player 0 (the AI) |
| Items worn by a player's heroes, together | 5 |
| Enchantments on a player's units, together | 5 |
| Cards in a player's Deck | 40 |
| Cards in a player's Hand | 10 |
| Improvements of Player 0 (the AI), all lanes together | 3 |
| Entries in one section | 64 |
| Constructs that are not posed | 64 |
| A stated Attack, Health or Armor | 99 more or 99 less |
| A stated keyword value | 99 either way |
| A unit's stated Damage | 99 |
| A player's Mana left | 99 |
| A player's Gold | 999 |

A refusal over a limit names the number the text had and the limit. The limits keep a puzzle near an
ordinary match's size, because the time the AI takes to think about each move it considers grows with
every card on the board and in the hands and decks, and most with its own heroes and improvements, so
those two AI limits are tighter. The AI also considers a limited number of moves each turn, in a
puzzle as in a practice match, so on a busy board it may miss a move, and some card combinations
(many units with auras beside rows of improvements) can still make each of its moves take longer:
about three seconds by our estimate, and a combination nobody has tried may take longer still.

### What the game answers

When the game refuses a puzzle it shows the server's answer as plain text, which you can copy (for
example to paste into an AI assistant). The answer starts with a short cause word: for example
`puzzle_unreadable:line 27: no card named "Anti-Mgae"`, or
`puzzle_over_budget:the puzzle text is 70000 bytes long; a puzzle may be at most 65536 bytes`. When
the only problem is constructs that are not posed, the answer starts with `puzzle_unposed:` and lists
each construct with its line, and the START button becomes START ANYWAY, which starts the board
without them.

### A complete example

```
// The AI acts first.
Mode Rules
[starting_initiative_player=0]

Player 1
[Mana=6,UsedMana=1,Gold=5]

Player 1 Combat 2
Melee Creep
Empty
Ursa #ursa [Damage=2,Trample,Attack=1] Equip(Short Sword)

Player 1 Improvements 2
Selemene's Favor

Player 1 Hand
Leather Armor

Player 1 Fountain
Luna [TurnsUntilDeployment=1] Enchant(Soul of Spring)

Player 1 Deck
Short Sword
Traveler's Cloak

Player 0
[Mana=4]

Player 0 Combat 2
Axe
Melee Creep

Player 0 Hand
Traveler's Cloak

Player 0 Tower 2
Defense Tower [Damage=12]
```

You hold Ursa (two damage taken, one more Attack, Trample, wearing a Short Sword) in the middle lane
beside a creep and an open slot, with 5 Mana and Leather Armor in hand; Luna, enchanted with Soul of Spring, can deploy next
round, and you draw the Short Sword first. The AI holds Axe and a creep in the middle lane, 4 Mana and a
Traveler's Cloak, and its middle tower has taken 12 damage. The AI acts first.
