Spielerando

Turn-Based Combat

Turn-based combat lets characters act one at a time in a fixed order, each once per round, until one side has nobody left standing. It usually goes wrong around death and order: a fallen character loses their turn, the round still moves on, and a minimum damage and a round limit make sure every battle ends.

Also called: Round-based combat, Initiative order, Turn order system, Turn-based battle.

On a hexagonal island board, one blue salamander knight stands on a glowing tile under a yellow arrow, with its move range highlighted and an arc aimed at a crab pirate, while the other figures wait and a row of portraits shows the turn order.
Shoal Regiment, an invented tabletop tactics game. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Turn-Based Combat" to my game.

What it should do: Turn-based combat gives the player time to think. Every action is a decision, made in full view of what it will do.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> setup
  setup: Line-up
  first: First turn
  turn: Later turn
  won: One side wins
  draw: Draw
  setup --> first: both sides stand
  setup --> won: one side is empty
  setup --> draw: nobody is standing
  first --> turn: attack, guard or wait
  first --> won: last enemy falls
  turn --> turn: next character acts
  turn --> first: round is over
  turn --> won: last enemy falls
  turn --> draw: round limit reached
  won --> [*]
  draw --> [*]
```

Use these starting values:
- minDamage: 1
- guardPercent: 50 %
- maxRounds: 30

Watch out for these common mistakes:
- A character falls before their turn: Tell your AI to skip fallen characters when it moves to the next turn.
- The last character of a round falls: Tell your AI to start a new round whenever nobody is left to act, however that came about.
- Two tough sides never finish: Tell your AI to keep a minimum damage above zero and add a round limit.
- A block that lasts too long: Tell your AI to end a character's block when their own next turn begins.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

Turn-based combat gives the player time to think. Every action is a decision, made in full view of what it will do.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

both sides standone side is emptynobody is standingattack, guard or waitlast enemy fallsnext character actsround is overlast enemy fallsround limit reachedLine-upFirst turnLater turnOne side winsDraw
How it runs, as a diagram
  • Line-up → First turn: both sides stand
  • Line-up → One side wins: one side is empty
  • Line-up → Draw: nobody is standing
  • First turn → Later turn: attack, guard or wait
  • First turn → One side wins: last enemy falls
  • Later turn → Later turn: next character acts
  • Later turn → First turn: round is over
  • Later turn → One side wins: last enemy falls
  • Later turn → Draw: round limit reached

Good starting values

ValueStart withWhat it changes
minDamage1The least a hit does. Keep it above zero, so two sides can always hurt each other and a fight keeps moving.
guardPercent50 %How much of a hit gets through a block. Lower makes blocking stronger.
maxRounds30After this many rounds the battle is a draw, so it always ends. Lower means shorter fights.

What usually goes wrong

A character falls before their turn

The game moves on to the fallen character, who then acts, or the round hangs waiting for them.

Fix: Tell your AI to skip fallen characters when it moves to the next turn.

The last character of a round falls

If a new round starts only after the last character has acted, losing that character means the round never moves on.

Fix: Tell your AI to start a new round whenever nobody is left to act, however that came about.

Two tough sides never finish

If defence can cut damage to zero, or both sides only block, the battle never ends.

Fix: Tell your AI to keep a minimum damage above zero and add a round limit.

A block that lasts too long

A block that ends with the round does not hold against a faster enemy, and one that never ends lasts the whole battle.

Fix: Tell your AI to end a character's block when their own next turn begins.

How to check it works

Common questions

how do you code turn based combat

Keep a fixed list of who goes next and a note of who has acted this round. After each action, move to the next living character who has not acted, and start a new round when there is none.

what do i tell my ai to add turn based combat

Paste this: Add turn-based combat where characters act in a fixed order by speed, each once per round, fallen characters are skipped, every hit does a minimum damage, and the battle is a draw after a round limit.

how is turn order decided

Usually by speed, with a fixed tie-break such as the listed order, so the same battle can be replayed. Sorting once per battle keeps it easy to follow; sorting again each round lets speed changes matter.

how do i stop a turn based battle from never ending

Keep a minimum damage above zero, so a hit always counts, and a round limit, so two sides that only block still finish.

Where it comes from

Earliest example we could find: Versuch eines aufs Schachspiel gebaueten taktischen Spiels (Johann Christian Ludwig Hellwig) (1780). Hellwig's chess-derived war game let a player move one piece, or one rectangular block of pieces, per turn. Capture worked as in chess, and infantry and artillery could also shoot. This is the oldest rule set located here that models fighting between military arms in discrete turns. The turn rule comes from a Wikipedia summary, not from the rulebook.

  1. 1780 Versuch eines aufs Schachspiel gebaueten taktischen Spiels (Johann Christian Ludwig Hellwig): Hellwig's chess-derived war game let a player move one piece, or one rectangular block of pieces, per turn. Capture worked as in chess, and infantry and artillery could also shoot. This is the oldest rule set located here that models fighting between military arms in discrete turns. The turn rule comes from a Wikipedia summary, not from the rulebook. [Recreational wargaming (Wikipedia)][Johann Christian Ludwig Hellwig (Wikipedia)][The Brunswick Wargame (Megan Anderson, Leiden Security and Global Affairs, 2014)]
  2. 1824 Kriegsspiel rules (Georg Heinrich Rudolf Johann von Reisswitz): Players wrote orders instead of moving pieces, and an umpire carried them out and settled fights with dice and tables. Play was split into turns of a fixed span of battle time. Wikipedia's summary of the English translation says both sides' turns ran at once; another source says alternate moves (see notes). [Shall We Play a Game? Interview with Jon Peterson (Asterisk, issue 14, 2026)][Kriegsspiel (Wikipedia)][Brief History Of Wargaming (wargaming.info)]
  3. 1913 Little Wars (H. G. Wells): Wells's printed rules for toy soldiers have the players toss for the opening move. In his account of how the game began, one side moved its whole force and then the other did. Firing guns is part of a player's move and comes before moving men. [Little Wars, full text (Project Gutenberg eBook 3691)][Little Wars, catalogue record (Project Gutenberg)]
  4. 1971 Chainmail (Gary Gygax and Jeff Perren, Guidon Games): Miniatures rules for medieval battles with a fantasy supplement. They offered two turn structures: a die roll that decides who moves first, followed by move and counter-move, or written orders that both sides carry out at the same time. The rulebook was not read directly; the turn rules come from two blogs. [Chainmail (game) (Wikipedia)]['Chainmail' vs 5th Edition 'D&D': Miniature Combat Compared (James Floyd Kelly, GeekDad, 2015)][The Original Game Part 2 - Chainmail #1 (Diegetic Advancement Blog)]
  5. 1981 Wizardry: Proving Grounds of the Mad Overlord (Andrew Greenberg and Robert Woodhead, Sir-tech): The manual splits combat into rounds. The computer settles what the monsters will do, the player picks one activity for each character, and the game then resolves the round and reports actions as messages. It is the oldest computer RPG in this timeline whose round structure is confirmed from a rules text. [Wizardry rules, text copy of the manual (textfiles.com mirror)][The History of Computer Role-Playing Games Part 1: The Early Years (Matt Barton, Gamasutra/Game Developer, 2007)]
  6. 1991 Active Time Battle, Final Fantasy IV (US patent 5390937, Square): Square's patent, naming Hironobu Sakaguchi and Hiroyuki Itou as inventors, describes conventional RPG battles as proceeding in turns, then covers a variant in which an enemy can attack while the player is still entering a command. The year is the patent's priority date. The patent text does not name Final Fantasy; the link to Final Fantasy IV comes from Den of Geek and Wikipedia. [US5390937A, Video game apparatus, method and device for controlling same (Google Patents)][Final Fantasy Creators Reveal the Secret Origins of the ATB Combat System (Aaron Greenbaum, Den of Geek, 2023)][Active Time Battle (Wikipedia)]

SCOPE: Older alternate-move board games are not counted. Hellwig's game is included because it reworked chess to model battlefield arms. No source opened here documents an earlier rule set as a turn-based combat simulation, but the search was not exhaustive. SOURCE STRENGTH: Primary texts were read for Little Wars, the Wizardry manual and the Square patent. Strong secondary: the Jon Peterson interview and Matt Barton's article. Weak: Hellwig's turn rule rests on Wikipedia alone (the paragraph cites Peterson 2012 and Nohr and Boehme 2009, neither read), and Chainmail's turn rules rest on two blogs. Wikipedia is used because nothing better could be opened. Little Wars' year comes from an automatically generated summary on the Project Gutenberg record, because the text itself states none. The Wizardry manual copy is undated, so its year comes from Barton. DISPUTES: (1) Reisswitz: Wikipedia's summary of the Leeson translation says turns ran simultaneously; wargaming.info says the game began with alternate moves. Neither the 1824 text nor the translation was read, and Peterson does not address turns in the interview. Unresolved. (2) OpAnalytics says Helwig's game was the 'King's Game' or Koenigspiel, while the Leiden article says Hellwig borrowed from Christoph Weickmann's Chess Game of 1644. That earlier game is not documented here as turn-based combat. (3) Spelling varies between Hellwig and Helwig, and sources disagree on the board size; the figures are left out under the no-constants rule. (4) The Wikipedia summary states a fixed time per Reisswitz turn; the figure is left out for the same reason. CLAIMS OF 'FIRST', RECORDED AS THE SOURCES' OWN: wargaming.info calls Helwig the first to see that markers need not stand for individual soldiers. Barton says of the mainframe CRPGs, 'The first of these appears to be Rusty Rutherford's pedit5'. CRPG Addict says the earliest surviving CRPG seems to be a 1975 game called The Dungeon, which is pedit5. Wikipedia says Active Time Battle was first used in Final Fantasy IV (1991), citing PC Gamer and Eurogamer, neither opened. POINTER DROPPED: pedit5 is not a turn-based combat example. CRPG Addict's play report says choosing to fight simulates the whole battle at once, and that round-based combat was a planned upgrade that was never built. Wikipedia agrees that the fight is settled without further player input. The other PLATO game, dnd, is not covered: its combat was not documented, and the one dating analysis found could not be opened. CRPG Addict's 2011 post also carries a later update about m199h and the order of the PLATO RPGs, which was not followed up. GAP: Dungeons & Dragons (1974) is left out of the timeline because neither its rulebook nor a strong source on its round structure could be read, though it is the likely bridge from wargames to CRPGs. What is documented: the Museum of Play dates it to 1974, Evan Torner (MIT Press, excerpted by Rascal News) says it moved combat space into the imagination and turned to individuals, and Barton says CRPGs were deeply inspired by it. A blog quotes the rulebook on rounds inside a turn; the quote contains a game constant and is not reproduced.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it