EvolvingBehavior  0.1.0
Experiment Results: Saving, Loading, Evaluating

Once you have set up your experiment, you may want to save the results, load them and resume the experiment, or evaluate and use the behavior trees.

Ending the Experiment

The experiment will end after the specified number of trials (generations) from the LifeCycle component. You can also interrupt the experiment early by stopping the game, and you can then load and resume it later if you wish.

You can set a specific Map to load when the experiment ends, as well as the map to load to restart the level when each individual Trial ends, in the LifeCycle component.

Note that, if you stop an experiment in the middle of a Trial, that partly-completed Trial will not be saved.

Saving and Loading the Experiment In Progress

After testing every generation (a single trial), the experiment will automatically save its state. If you stop running the experiment and then start it again, it will automatically load and pick up at the beginning of the next generation/trial.

The settings for saving and loading an experiment in LifeCycle.

In the LifeCycle Component, you can change properties to affect the saving and loading:

Slot Name: Changes the name of the save file to use for saving and loading.

User Index: If you want to save multiple experiments into the same file, you can change this number to switch between them.

By changing these to new values, you can switch which experiment you are loading and saving to, or start a totally new experiment while keeping your old ones available.

You can also delete the currently-specified save file by clicking "Delete Current Save."

Saving and Examining Behavior Trees

Each behavior tree evolved to populate each trial will be saved in a folder corresponding to the Trial Number (the number of generations that have been generated so far).

You can find all of these saved trees listed by ID in the /Content/EvolvingBehavior/Trial<num>/ folder in the Asset Browser or on disk.

The filename also indicates the Fitness of the tree, to help you sort through them.

Thus, the full filename for a specific behavior tree is: <fitness>-Tree-<id>.asset

You can load these behavior trees in the Unreal Editor as you would any other Behavior Tree asset, though they will be shown with an automatically-generated layout that may not exactly match your preferred placement of the nodes. You may need to manually drag nodes around to look at the tree with your preferred layout.

You can also manually edit these behavior trees, and you can use these behavior trees as static assets on any NPC, by dragging them into the Behavior Tree property for the AI Controller. Essentially, they work just like hand-crafted behavior trees.

You may note that the first time you open the Behavior Tree, it shows as having unsaved changes. This is due to the Editor needing to generate the initial, automatic layout of the nodes. You can safely save the layout without affecting the basic workings of the tree.

If you open a behavior tree immediately after it is generated, you may find that you get an error saying that the tree cannot be fully saved. This is because the tree has not yet been fully loaded in the editor. You can either restart the editor or manually tell the asset to fully load, after which you should be able to save it normally.

Additional Logs and Information

You can also find additional information about the experiment as it is in progress or after it has completed by examining the log files.

The "Output Log" (in Window->Developer->Output Log) contains the relevant log messages. You can also find this log as a text file on disk under your project's directory at "Saves/Logs/". Look for messages with the LogEvolvingBehavior and LogEvolvingBehaviorError categories to find information about the agents and fitnesses, and about errors or problems with the settings, respectively. If you find that agents are not evolving, or the experiment does not seem to be working, these logs are the first place to check for problems. They are also another way to see representations of the behavior trees and their fitnesses without opening each file.