Skip to content

Configuration Files

Miguel Duarte edited this page Apr 5, 2015 · 3 revisions

Experiments in JBotEvolver are configured through the use of plain-text configuration files. These configuration files have a specific syntax, have a .conf extension, and are composed of several sets of arguments. The advantage of using plain-text is that files are lightweight, command-line editable, and human-readable.

While it is possible to configure experiments manually, it is recommended that the Configuration GUI is used to create the file in an interactive way.

Each set of arguments in the configuration file starts with a "--" identifier:

--argumentname argument1=value1,argument2=value2

JBotEvolver checks for specific sets of arguments in order to setup an experiments, such as --robots, --environment, --controllers, etc. These sets of arguments are parsed and then used to change the way the experiment will run without having to recompile the code. Below is an example of arguments that will load a specific environment with particular options:

--environment classname=ExampleEnvironment,usepreys=1,preydistance=2.0

The classname argument indicates which Environment class will be loaded through Java's Reflection API. This allows us to create new elements for the simulation without having to register them in central provider. After loading the class, the other arguments can be used to change the class's configuration. In the example, we change the width and height of the environment. In order to use these values, we have to read them in the constructor of the environment:

public ExampleEnvironment(Simulator simulator, Arguments args) {
	//in order to set a boolean, check if it's equal to 1
	this.usePreys= args.getArgumentAsIntOrSetDefault("usepreys", 0) == 1;
	this.preyDistance= args.getArgumentAsDoubleOrSetDefault("preydistance", 0);
}

Using the Arguments class, you can use several helper methods that can give you the value of a specific argument in Int, Double, String, etc.