Skip to content

Running & Testing Rule Generators

Raluca D. Gaina edited this page Feb 12, 2018 · 1 revision

These instructions describes the steps need to run and test either a sample rule generator or your own rule generator.

Running Sample Rule Generators

Disable Other Generators

Comment any code in tracks/ruleGeneration/TestRuleGeneration.java that is related to running the game or generating rules for games. Make sure that is the only line uncommented.

// ArcadeMachine.playOneGame(recordGameFile, level1, recordActionsFile, seed);
// ArcadeMachine.runOneGame(recordGameFile, level1, visuals, sampleMCTSController, recordActionsFile, seed, 0);

Enable The Rule Generator

Uncomment the following line of code in tracks/ruleGeneration/TestRuleGeneration.java

// 1. Generate rules (Interaction and Terminations) for a fixed level
RuleGenMachine.generateRules(game, level1, randomRuleGenerator, recordGameFile, seed);

This code will generate a new VGDL file with the same name as the tested game followed by _ggame.txt. This file can be found in examples/gridphysics/ folder.

Switching the sample rule generator

Replace the third function parameter (e.g. randomRuleGenerator in the previous example) by any of the following variables: +randomRuleGenerator +constructiveRuleGenerator +geneticRuleGenerator

Testing the rule generator

Uncomment any of the following lines to test the current generator

ArcadeMachine.playOneGame(recordGameFile, level1, recordActionsFile, seed);
// ArcadeMachine.runOneGame(recordGameFile, level1, visuals, sampleMCTSController, recordActionsFile, seed, 0);

The first line allows you to test the generated game by yourself, while the second one uses sampleMCTSController to play the game.

Running Custom Rule Generators

Disable Other Generators

Comment any code in tracks/ruleGeneration/TestRuleGeneration.java that is related to running the game or generating rules for games. Make sure that is the only line uncommented.

// ArcadeMachine.playOneGame(recordGameFile, level1, recordActionsFile, seed);
// ArcadeMachine.runOneGame(recordGameFile, level1, visuals, sampleMCTSController, recordActionsFile, seed, 0);

Enable The Rule Generator

Uncomment the following line of code in tracks/ruleGeneration/TestRuleGeneration.java

// 1. Generate rules (Interaction and Terminations) for a fixed level
RuleGenMachine.generateRules(game, level1, randomRuleGenerator, recordGameFile, seed);

This code will generate a new VGDL file with the same name as the tested game followed by _ggame.txt. This file can be found in examples/gridphysics/ folder.

Using a custom rule generator

Replace the third function parameter (e.g. randomRuleGenerator in the previous example) by the full namespace of your custom RuleGenerator class. For example lets say your generator namespace is tracks.ruleGeneration.customRuleGenerator.RuleGenerator. Your rule generation code in tracks/ruleGeneration/TestRuleGeneration.java will look like the following:

// 1. Generate rules (Interaction and Terminations) for a fixed level
RuleGenMachine.generateRules(game, level1, "tracks.ruleGeneration.customRuleGenerator.RuleGenerator", recordGameFile, seed);

Testing the rule generator

Uncomment any of the following lines to test the current generator

ArcadeMachine.playOneGame(recordGameFile, level1, recordActionsFile, seed);
// ArcadeMachine.runOneGame(recordGameFile, level1, visuals, sampleMCTSController, recordActionsFile, seed, 0);

The first line allows you to test the generated game by yourself, while the second one uses sampleMCTSController to play the game.

Table of Contents:

Clone this wiki locally