Skip to content

A game against the computer

For creators

You give the red side of your base map a computer player, add victory and defeat, and get a minimap. The result is a complete game.

▶ Play against the computer: the controls of tutorial 17. Destroy every red building to win. The red side builds, trains and attacks; if you do nothing, it reaches your base and destroys every building in about three minutes.

  1. Give a team to the computer. Add the scene tag rts.ai = 1. The computer now plays team 1.

  2. Write its plan. In Blender’s Text Editor, make a text named data/ai.json. Each row is a key and a value (see The computer’s table). Leave out a row and its default is used.

  3. State the goal. Add a HUD Text line, hud.text = Destroy every red building, with hud.at = upper.

  4. React to the end (optional). When the game ends, your graphs hear it. An On Message node on the channel world:rts.victory or world:rts.defeat can play a sound or show your own banner.

  5. Press ▶ Play. Train an army, find the red base on the minimap, and destroy every red building. The screen shows VICTORY with a Play again button.

Key Default What it does
think 10 Ticks between decisions (20 ticks = one second)
workers 12 It trains workers up to this many and sends every idle one to the crystals
supplyMargin 3 It builds a depot when it gets this close to its supply cap (one at a time)
plan barracks,depot,barracks,factory,depot The buildings it raises, in order
army trooper:3,tank:1 The mix its production buildings train, in turn
wave 8 The size of its first attack, which attack-moves at your nearest building
waveGrow 4 How much larger each wave is
waveMax 24 The largest wave
defendRadius 18 Metres round its base. Enemies inside, and its whole army turns on them

When there is nothing left to mine, it goes all-in: every idle unit attacks.

The computer gives only the orders any player can give, and it pays for everything the same way you do.

A side with no building left is defeated. The screen shows VICTORY or DEFEAT, with Play again.

The whole map sits in a corner and shows:

  • rock and crystal nodes;
  • your units and buildings in your colour, and enemies only where you see them now;
  • the fog: unexplored ground dark, explored ground dim;
  • the outline of what your camera sees.

A click or a drag on it moves the camera there. A right-click orders the selection there (an attack-move after A). On a phone it is smaller, at the top right, and a tap moves the camera.

Tag Values What it does
rts.ai team numbers, such as 1 The teams the computer plays
rts.aiTable default data/ai.json The computer’s table

Next: play it online against a friend.