Difficulty Settings
Difficulty settings let the player choose how hard the game is. Each choice is a few multipliers for damage taken, enemy health and loot, and every other rule asks them. A hit never rounds down to nothing, an enemy is never born dead, and changing the setting mid-fight keeps each enemy's share of health.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Difficulty Settings" to my game.
What it should do: Players come with very different skill and patience. A choice they make themselves lets a newcomer finish the game and gives an expert a real challenge, without building two games.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> normal
relaxed: Relaxed
normal: Normal
hard: Hard
locked: Locked in
relaxed --> normal: picks normal
relaxed --> hard: picks hard
normal --> relaxed: picks relaxed
normal --> hard: picks hard
hard --> relaxed: picks relaxed
hard --> normal: picks normal
relaxed --> locked: locks the choice
normal --> locked: locks the choice
hard --> locked: locks the choice
locked --> [*]
```
Use these starting values:
- damageStep: 0.5 x
- healthStep: 0.25 x
- lootStep: 0.25 x
- minDamage: 1 points
Watch out for these common mistakes:
- A small hit rounds to nothing: Tell your AI: round the damage, then never go below the smallest damage you chose, and let a hit of zero stay zero.
- Changing the setting in the middle of a fight: Tell your AI: keep the same share of health on the new maximum, and never let a living enemy round down to zero.
- Small loot never improves: Tell your AI: round loot with a random roll that is passed in, so 1.25 gives one most of the time and two now and then, and the average is right.
- The multiplier is applied twice: Tell your AI: ask for the multiplier in exactly one place, where the damage reaches the player, and nowhere else.
- A locked choice that can be bypassed: Tell your AI: keep the lock beside the setting itself and check it in the one place that changes the level.
- Mixing the setting with other help: Tell your AI: keep help options separate from the setting, so the player can combine them.
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
Players come with very different skill and patience. A choice they make themselves lets a newcomer finish the game and gives an expert a real challenge, without building two games.
How it runs, as a diagram
Everything it can be in, and what moves it on. Your AI builds from exactly this.
How it runs, as a diagram
- Relaxed → Normal: picks normal
- Relaxed → Hard: picks hard
- Normal → Relaxed: picks relaxed
- Normal → Hard: picks hard
- Hard → Relaxed: picks relaxed
- Hard → Normal: picks normal
- Relaxed → Locked in: locks the choice
- Normal → Locked in: locks the choice
- Hard → Locked in: locks the choice
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| damageStep | 0.5 x | How far damage taken moves from normal. At 0.5, relaxed takes half and hard takes half as much again. It stays below one, or relaxed would take no damage at all. |
| healthStep | 0.25 x | How far enemy health moves from normal. Smaller than the damage step on purpose, because a fight that lasts twice as long is felt more than a hit that hurts twice as much. |
| lootStep | 0.25 x | How far loot moves from normal, the opposite way: relaxed gives more and hard gives less. A small move keeps hard players from being starved. |
| minDamage | 1 points | The least a hit that was meant to hurt can do. One keeps every hit worth dodging, even on the most relaxed setting. |
What usually goes wrong
A small hit rounds to nothing
A hit of 1 on a setting that halves damage rounds to 0 or 1 depending on how it is written, and with a stronger cut it rounds to nothing, so a whole weapon or trap stops mattering.
Fix: Tell your AI: round the damage, then never go below the smallest damage you chose, and let a hit of zero stay zero.
Changing the setting in the middle of a fight
If enemy health is recalculated, an enemy on half health can jump back to full, or die on the spot because its new maximum is below what it has left.
Fix: Tell your AI: keep the same share of health on the new maximum, and never let a living enemy round down to zero.
Small loot never improves
A drop of 1 times a multiplier of 1.25 rounds back to 1 every time, so the relaxed setting never gives more of the things that come one at a time.
Fix: Tell your AI: round loot with a random roll that is passed in, so 1.25 gives one most of the time and two now and then, and the average is right.
The multiplier is applied twice
If the weapon scales the damage and the enemy scales it too, a relaxed player takes a quarter and a hard player more than twice.
Fix: Tell your AI: ask for the multiplier in exactly one place, where the damage reaches the player, and nowhere else.
A locked choice that can be bypassed
A challenge mode that locks the setting is spoiled if the menu, a saved file or a hotkey can still change it.
Fix: Tell your AI: keep the lock beside the setting itself and check it in the one place that changes the level.
Mixing the setting with other help
If extras like a shorter timer are tied to the same setting, a player who wants easy fights but a hard clock cannot have both.
Fix: Tell your AI: keep help options separate from the setting, so the player can combine them.
How to check it works
- The setting is normal. The player takes a hit of 10 from an enemy with 80 health and the enemy drops 4 coins: The hit is 10, the enemy has 80 and the drop is 4.
- The setting is relaxed, with the starting values. A hit of 10 lands on an enemy with 80 health: The player takes 5 and the enemy has 60 health.
- The setting is hard, with the starting values. A hit of 10 lands on an enemy with 80 health: The player takes 15 and the enemy has 100 health.
- The setting is relaxed with the damage step at its largest, 0.9. Hits of 1 and 3 land: Both do 1, and a hit of 0 still does 0.
- The setting is relaxed with the health step at its largest, 0.9. An enemy with 1 health and one with 4 health are made: Both start with 1 health.
- A drop of 3 coins on relaxed, and rolls spread evenly from 0 to 1. You take the average of the loot over all the rolls: The average is 3.75, and on hard the average is 2.25.
- The game starts on normal. The player chooses hard: A hit of 10 now does 15, and the change is counted once.
- The setting is normal. The player chooses normal again: Nothing changes and no change is counted.
- The player chose hard and locked the choice. The player tries to choose relaxed: The setting stays hard.
- An enemy with 30 of 60 health. The setting changes so its maximum becomes 90: It has 45 of 90 health, still half.
Works well with
- Health and Damage: The multiplier belongs where damage reaches the player, so the weapon and the enemy never scale it again. Let the damage rules work out the hit first, then apply the multiplier once.
- Loot Table: The loot setting multiplies the amount, not the odds. Roll what drops first, then scale how many.
- Meta-Progression: Upgrades earned over many runs and a difficulty the player picked both change how hard the game is. Show both, so the player knows what they chose.
Clashes with Dynamic Difficulty: A game that adapts quietly can undo the setting the player chose, so a player on hard finds the game easing off. Make the adapting part work inside the chosen setting, or switch it off on the hardest setting and tell the player.
Common questions
what do i tell my ai to add difficulty settings
Paste this: Add difficulty settings with relaxed, normal and hard. Each is a set of multipliers for damage taken, enemy health and loot, asked in one place. A hit never rounds to zero, an enemy never has zero health, and changing mid-fight keeps each enemy's share of health.
how many difficulty levels should a game have
Three is a good start: one for people who want the story, one for the intended game and one for people who want a fight. More levels only help if each feels clearly different.
should the player be able to change difficulty during the game
Usually yes, because a wall that stops someone is worse than an easy game. Let them change it freely, apart from a challenge mode that locks it on purpose.
what should a difficulty setting change besides damage
Enemy health, loot, and how much help the player gets. Keep each as a separate number so you can tune them one by one, and keep the player's help options apart from the setting.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 17 tests pass on the reference code.
- The state diagram was checked against the code, at the default values and at every listed low and high value.
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