Test bot
What Test with bot checks in the editor 0.4.0, how it builds its route from the rules, what it can and cannot do, how to mark steps for it and how to read the panel when the test fails.
DescribesEditor 0.4.0 For creating without programming
On this page
The test bot is an automatic player. It plays your game from start to finish to check one thing only: that it can be finished. If the bot reaches the end on every difficulty, the game can be exported.
What it checks#
Test with bot (Ctrl+F5) runs six complete matches: the three difficulties, each with two random seeds. It plays them with no screen and at full speed, so it takes little time.
Each match has to end with the expected result, which is normally a win. If all six manage it, the test is passed.
It is the same test Export runs before writing the file, and the same one the command-line tools use: see Testing with the bot.
How it builds its route#
You do not have to tell the bot what to do: it works it out from your rules. It looks at what is needed to win (the goal, the things to collect, the buttons that open doors) and builds a route that goes through them.
That is controlled by a box in the Test bot section, at the end of the Rules panel: Build the route from the rules (the goal, things to collect, buttons). It comes checked.
In the Blank template, for example, the only rule that ends the match is the goal one, so the route has a single step: go to the meta zone.
In a Blocks project there are no rules to work the route out from, and no such box. The panel says so: "With no steps of yours, the bot uses the blocks project script (it heads to the "meta" zone if there is one). If you mark steps, it follows them in order and then waits for the game to end."
What it can and cannot do#
| It can | It cannot |
|---|---|
| Walk around walls you put in the way. | Dodge hazards: if the shortest path crosses a danger zone, it steps on it. |
| Walk around gaps. | Plan jumps from platform to platform. |
| Go to a piece, a zone or a point. | Wait for the right moment, unless you mark it. |
The panel says it in these words: "It heads for the goals (the finish, things to collect, buttons) walking around walls and gaps by itself. It cannot plan jumps between platforms or dodge hazards: mark steps for that."
Steps you mark#
When the bot does not get there by itself, you mark where it should go. The steps you add go before the final goal, in the order of the list.
They are in Rules, Test bot section, under Steps you mark (they go before the final goal). With none, the list says "No steps of your own: the bot heads straight for the goals."
| Button | Which step it adds |
|---|---|
| + Point the camera looks at | Go to the place you have in the center of the viewport. It lets you mark a corner or a point on the floor. |
| + Go to selection | Go to the piece or the zone you have selected in the scene. |
| + Wait for and board the selected platform | Wait for the selected platform to come close and get on. For moving platforms. |
| + Wait 1 s | Stand still for one second. |
+ Go to selection and + Wait for and board the selected platform need something to be selected; otherwise they are disabled.
Each step in the list has three controls:
| Control | What it does |
|---|---|
| go around | Ticked: finds a path around walls and gaps. Unticked: goes straight and jumps (platforms, steps). |
| Arrow | Moves the step up in the order. |
| × | Removes the step. |
An example: going around a hazard#
In the tutorial game there is a danger zone between the start and the goal. The first test fails: the bot goes to the goal by the shortest path, which crosses the hazard, and does not get there.
- Select in the scene a coin that is to one side of the hazard.
- In Rules, Test bot section, press + Go to selection. The list shows the step go to piece "moneda-2".
- Repeat with another coin, on the other side, to complete the detour.
- Run Test with bot again.
With those two steps before the goal, the six matches end in a win.
Reading the panel#
The result stays in the Test bot panel, which opens by itself when the test finishes.
Test passed#
At the top it says Test passed, how many matches passed and how much the resulting .ggx would weigh. The Run again and Watch the bot play buttons are always at hand.
Each row is a match:
| Item | What it is |
|---|---|
| "Easy · seed 1" | The difficulty, with the name the player sees, and the random seed. |
| "victory" | How it ended: victory, defeat or game over. |
| "score 2" | The final score. |
| "3.0 s" | How long the match lasted, in game time. |
| "bot steps 2/3" | How many steps of its route the bot did before the match ended. |
| "script … ms" | How long the game's code takes on average in each step. |
The drawn path#
After a test, the bot's route stays drawn in the scene. You show and hide it with B, with the path button over the viewport or with the Show the bot path in the scene box in the Rules panel. It lets you see what the route goes through before testing.
Test failed#
A match that does not pass carries the mark failed and, in red, the reason. The two most common:
| Reason | What it means |
|---|---|
| "The bot got stuck on step N of M (go to zone "meta"): it did not reach the destination (… units short horizontally and … vertically). The bot ended up at […] after … s." | The bot could not reach the place of that step in the time it had. The message says which step it was, how far it was and where it ended up. |
| "The game ended in defeat and the script expected victory." | The match ended, but not as it should. For example, the clock ran out. |
The See where button takes the camera to the place where the bot ended up. The cause is almost always there: a wall with no way through, a gap, a hazard that sends it back to the start.
If you do not understand why it fails, press Watch the bot play: the same match, on screen.
The side view and jumps#
In a 2D platformer game the bot does not plan the jumps. If the test fails in a side-view game, the panel shows a collapsible help at the top: The bot does not plan jumps in side view: how to mark them.
Its full text:
This game is played from the side (side view). The bot can walk around walls and gaps, but in 2D it does not plan jumps from platform to platform by itself, so it can get stuck even when the level can be finished. Mark the jumps by hand: under Rules, "Test bot" section, add a "Go to selection" step for each platform, in order, and untick "go around" on those steps so it heads straight and jumps. If the route is written in pruebas/bot.json, add a "ir" step per platform there. "See where" moves the camera to the spot where it got stuck.
In short:
- Select the first platform of the route.
- Press + Go to selection.
- Untick go around on that step, so it heads straight and jumps.
- Repeat with each platform, in order.
The export dialog shows the same explanation if the test fails there.
Games with a hand-written route#
The examples made with code come with their own route in the file pruebas/bot.json: it has jumps, waits and buttons that cannot be worked out from rules that do not exist.
In those games the Build the route from the rules box comes unchecked and the panel says "The route is hand-written in pruebas/bot.json (N steps). The editor leaves it alone." The test uses that route as it is.
To change it you edit the file with a text editor; its format is in Testing with the bot. If you check the box, the editor switches to building the route from the rules and your steps.
A game that has no rules, no steps and no written route is tested with a basic route.
The test repeats by itself#
Very occasionally a test match dies from an internal physics failure, unrelated to your game. Test with bot and Export repeat it by themselves and you see nothing: since the game is reproducible, the result is the same it would have given.
That same failure, in a live match with Play, can cut it off: see Playing inside the editor.
Next#
- Game card, export and share: with the test passed, export.
- Common editor problems: when the bot does not finish.
- Testing with the bot: the format of
pruebas/bot.json.