Skip to content
Rubens de Oliveira Moraes Filho edited this page Apr 29, 2021 · 1 revision

To create a script (AST) randomly, the framework provides one method defined in the class BuilderDSLTreeSingleton to produce an executable solution.

Example:

line 1. BuilderDSLTreeSingleton builder = BuilderDSLTreeSingleton.getInstance();
line 2. iDSL sol1 = builder.buildS1Grammar();

sol1 is an entire and runnable solution able to be executed in any map of the MicroRTS.

If you want to change the solution, producing some modifications in the AST, there are 2 examples, provided by us, in the framework to be used as guidance:

Example 1: Hard modification

iDSL sol2 = BuilderDSLTreeSingleton.getInstance().composeNeighbour(sol1);

Example 2: Soft modification

iDSL sol3 = BuilderDSLTreeSingleton.getInstance().composeNeighbourPassively(sol1);

The difference between these two methods consists of how the probability distribution is used to pick up a node to be changed. In the method composeNeighbour, all nodes have the same probability. And composeNeighbourPassively has more changes to select leaves of the AST, which means that the leaves have more probability to be selected.

BuilderDSLTreeSingleton has some parameters that can be changed to improve some characteristics in the generation process. Feel free to change them accordingly your necessities.

Clone this wiki locally