modl.ai
Use modl features

You can use modl:test features to customize and optimize your test runs.

The table below describes modl:test features and what they do:

Feature Description
Terminal states Deter a bot from loading a game state again.
Waypoints Encourage your bot towards a predefined point.
Custom events Track specific events in your game.
Checkpoints Clear the previous state your bot has explored.

Use terminal states

During exploration, your bot regularly reloads the game state to previously observed states. If you have states that you don’t want your bot to explore, mark those states as Terminal. If your bot enters a terminal state, modl:test will force your bot to restart exploration in a different state.

Use the following code to implement terminal states in your project:

void Update()
{
if(GameOver())
{
#if MODL_AUTOMATIC_TESTING
ModlPublicController.InvokeTerminalStateUpdate();
#else
ShowGameOverScreen();
#endif
}
}

Use custom events

A custom event enables you to record specific events in your project. The modl.ai platform adds any custom events to your test report.

You can use custom events throughout your project but some common use cases are:

  • Level finish
  • Item pickup
  • Checkpoints
  • Player out of bounds

To implement a custom event in your project, use Modl.EventReporter.Report("youreventhere");.

To implement a player out of bounds custom event, complete the following steps:

  1. Add a collider to catch your bot outside of the boundaries of your game.
  2. Call Modl.EventReporter.Report("OutOfBounds"); when the player hits the collider.

Stop your bot from re-exploring previous states

If you want your bot to avoid re-exploring a previous state, create a custom event and use the MODL::STATE_ARCHIVE_CLEAR keyword. To implement this in your game, add Modl.EventReporter.Report("MODL::STATE_ARCHIVE_CLEAR") to any scene you want to clear. It is best practice to use MODL::STATE_ARCHIVE_CLEAR if a part of your level becomes unreachable. For example, if a door closes and stops the player from backtracking.

Note: The keyword changed in version 3.1.0. If you’re using an older version of the modl Unity plugin, you need to use the checkpoint keyword instead. To implement checkpoints in your game, add Modl.EventReporter.Report("checkpoint") to any scene you want to clear. Avoid naming your events checkpoint unless you want to use this feature. Checkpoints force modl:test to clear all previously explored states.