Spielerando

Mana Pool

A mana pool is a store of magic that spells spend and time slowly refills. A spell costs its full price or does not happen at all. The pool refills at a steady rate, faster while the caster stands still, and it never refills in the same moment a spell is cast.

Also called: Mana, Magic points, Spell points, Energy pool.

A tall heron-like sorceress in a night pond flings a turquoise spell while the glass urn of glowing liquid in front of her has dropped below half, with light motes drifting back in.
Lanternmere, an invented watercolour pond-witch adventure. 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 "Mana Pool" to my game.

What it should do: A mana pool makes strong spells a choice about when, not just whether. The player spends in bursts and then has to play without magic while it comes back.

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

```mermaid
stateDiagram-v2
  [*] --> full
  full: Pool full
  refill: Refilling
  cast: Just cast
  empty: Pool empty
  full --> full: nothing cast
  full --> cast: casts a spell
  full --> empty: spends it all
  cast --> cast: casts again
  cast --> refill: pool starts refilling
  cast --> empty: spends the last of it
  cast --> full: refills in one go
  refill --> refill: refilling goes on
  refill --> cast: casts a spell
  refill --> empty: spends the last of it
  refill --> full: pool is full
  empty --> refill: pool starts refilling
  empty --> full: refills in one go
```

Use these starting values:
- maxMana: 100 units
- regenRate: 4 units/s
- restBonus: 2.5 x
- minCost: 1 units

Watch out for these common mistakes:
- A spell you cannot pay for still goes off: Tell your AI: check the price against the pool first. If it does not fit, cast nothing and spend nothing.
- Discounts make spells free: Tell your AI: cap the total discount at 100 percent and give every spell a minimum price above zero.
- A bigger pool starts out full: Tell your AI: when the top grows, leave the mana as it is. New room is not new mana.
- The pool holds more than its top: Tell your AI: when the top shrinks, cut the mana down to it right away.
- Refilling and spending in the same moment: Tell your AI: decide the spell from the pool as it was, and never refill in the same moment a spell goes through.
- A price of zero or below: Tell your AI: treat a price as a spell only when it is a real number above zero. Anything else casts nothing.

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

A mana pool makes strong spells a choice about when, not just whether. The player spends in bursts and then has to play without magic while it comes back.

How it runs, as a diagram

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

nothing castcasts a spellspends it allcasts againpool starts refillingspends the last of itrefills in one gorefilling goes oncasts a spellspends the last of itpool is fullpool starts refillingrefills in one goPool fullRefillingJust castPool empty
How it runs, as a diagram
  • Pool full → Pool full: nothing cast
  • Pool full → Just cast: casts a spell
  • Pool full → Pool empty: spends it all
  • Just cast → Just cast: casts again
  • Just cast → Refilling: pool starts refilling
  • Just cast → Pool empty: spends the last of it
  • Just cast → Pool full: refills in one go
  • Refilling → Refilling: refilling goes on
  • Refilling → Just cast: casts a spell
  • Refilling → Pool empty: spends the last of it
  • Refilling → Pool full: pool is full
  • Pool empty → Refilling: pool starts refilling
  • Pool empty → Pool full: refills in one go

Good starting values

ValueStart withWhat it changes
maxMana100 unitsHow big the full pool is. A bigger pool lets the player cast more spells in a row before they must wait.
regenRate4 units/sHow fast the pool refills while moving about. At 4 an empty pool of 100 takes 25 seconds, slow enough that a spell is a real cost. It is never zero, because a pool that cannot refill would lock the caster out for good.
restBonus2.5 xHow many times faster the refill is while standing still. It rewards pausing to recover. At 1 there is no bonus.
minCost1 unitsThe least any spell can cost, whatever discounts apply. It is never zero, because free spells would never run out.

What usually goes wrong

A spell you cannot pay for still goes off

With 5 mana left, a spell of 30 empties the pool and still happens, or the pool goes to minus 25. The player gets a spell they could not afford.

Fix: Tell your AI: check the price against the pool first. If it does not fit, cast nothing and spend nothing.

Discounts make spells free

Two discounts of 60 percent stack to 120 percent, and the price drops to zero or below. Spells become free, or even refill the pool.

Fix: Tell your AI: cap the total discount at 100 percent and give every spell a minimum price above zero.

A bigger pool starts out full

A ring raises the top from 100 to 300, and the game fills the pool to 300 at once. Putting the ring on and off becomes a free refill.

Fix: Tell your AI: when the top grows, leave the mana as it is. New room is not new mana.

The pool holds more than its top

The ring comes off while the pool holds 250 of a top of 100. The bar overflows, and the player casts 2 more spells for free.

Fix: Tell your AI: when the top shrinks, cut the mana down to it right away.

Refilling and spending in the same moment

The pool refills first and a spell is paid from the new amount. With 9 mana, a spell of 10 then works. Fast tapping gets a bit of free magic every frame.

Fix: Tell your AI: decide the spell from the pool as it was, and never refill in the same moment a spell goes through.

A price of zero or below

A broken formula hands over a price of minus 10, or not-a-number. The pool is raised by it, or turns into not-a-number and stays that way.

Fix: Tell your AI: treat a price as a spell only when it is a real number above zero. Anything else casts nothing.

How to check it works

Works well with

Common questions

how does a mana system work in games

A pool of points that spells spend and time refills. A spell costs its full price or does not happen. The refill is slow enough that the player has to choose which spells are worth it.

how fast should mana regenerate

Start with a full refill in about 25 seconds of walking, and about 10 seconds standing still. Faster makes spells cheap, slower makes a fight feel like a single shot.

what happens when mana runs out

Spells that cost more than what is left do not happen, and the player waits. Show this clearly, for example with a sound and a flash on the bar, so it never feels like a broken button.

what do i tell my ai to add a mana bar

Paste this: Add a mana pool of 100. A spell costs its full price or does not happen, at least 1. The pool refills 4 per second, 2.5 times faster when standing still, and never in the same moment a spell is cast.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

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