Now with file-based level grammar.

This commit is contained in:
Woody Folsom
2012-03-18 10:56:25 -04:00
parent b431d5efeb
commit d6516388ad
8 changed files with 234 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
package dk.itu.mario.level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -76,9 +77,16 @@ public class PCGLevel extends Level {
System.out.println("LevelArchetype: " + archetype);
System.out.println("Creating level grammar");
LevelGrammar grammar = LevelGrammarFactory.createGrammar(profile,
archetype);
LevelGrammar grammar;
try {
String grammarFileName = "grammars/overland.grm";
grammar = LevelGrammarFactory.createGrammar(new File(grammarFileName));
System.out.println("Read grammar from file: " + grammarFileName);
} catch (Exception ex) {
System.out.println("Failed to parse grammar file due to exception: " + ex.getMessage());
System.out.println("Defaulting to basic overland grammar.");
grammar = LevelGrammarFactory.createGrammar();
}
System.out
.println("Tuning grammar for PlayerProfile & LevelArchetype using RETE");
GrammarTuner.tune(grammar, profile, archetype);