The dds.control.simulation.ai package contains all classes that are responsible for affecting simulations according to externally defined scripts. The scripts are modeled individually as AIScript objects. The objects are then capable of sending commands to the simulation to cause simulated objects to move or change according to the logic defined within the script.
AI Script files end with a .bsh extension and contain Java code. The AIScript class is an extension of BeanShell, which allows the script files containing Java code to be executed. Since the script is in Java, users are able to use any Java logic to model behavior of simulated objects.
AI Scripts should follow the following format:
// This is the base script file which lays out the basic funtionality // and organization of an AI script. import dds.model.simulation.Vector3D; public void setup() { //Sets up anything that needs to be set up beforehand. } public boolean isTriggered() { //Determines if the script is to be executed. return true; } public void simulate(float time) { //Dynamic part of the script, allows for simulation of timeslices } public boolean isCompleted() { //Determines if the script is completed return !HasCuedCommands(); } public void tearDown() { //Performs clean-up for the script RemoveSimObject(targetObject); }
The methods should be overridden when a different functionality is required.