-
Notifications
You must be signed in to change notification settings - Fork 104
A Simple Algorithm Using the Framework
In this section, we will present how to use the framework to create a simple local search algorithm, based on the algorithm called "Self play with local search" wrote by Mariño et. al. in his paper Programmatic Strategies for Real-Time Strategy Games (see Publications for more information). Below we have a copy of the algorithm:
line 1. BuilderDSLTreeSingleton builder = BuilderDSLTreeSingleton.getInstance();
line 2. int n = 10; //number of steps
line 3. iDSL p = builder.buildS1Grammar();
line 4. for (int k = 0; k < n; k++) {
line 5. .......iDSL PBR = localSearch(p);
line 6. .......if(defeats(p, PBR)){
line 7. ...........p = PBR;
line 8. .......}
line 9. }
line 10. return p;
In this example localSearch
can be a simple method that produces a new AST and, if this new AST is better than the old, select the new one as a good solution. Defeats
is a simple method that runs battles between the iDSL's returning if the second is better than the first. To reproduce the function defeats
please visit one of these classes to have some guidance about how to run battles using iDSL, scripts, and agents pre-existents.