71 lines
2.1 KiB
Java
71 lines
2.1 KiB
Java
package dk.itu.mario.level.grammar;
|
|
|
|
import dk.itu.mario.level.LevelArchetype;
|
|
import dk.itu.mario.level.LevelComponent;
|
|
import dk.itu.mario.level.PlayerProfile;
|
|
|
|
|
|
public class LevelGrammarFactory {
|
|
public static LevelGrammar createGrammar(PlayerProfile playerProfile, LevelArchetype archetype) {
|
|
LevelGrammar grammar = new LevelGrammar();
|
|
|
|
Variable v_START = new Variable("S", LevelComponent.TYPE.LEVEL);
|
|
Variable v_LAND_SEGMENT = new Variable("HALF_LVL", LevelComponent.TYPE.LEVEL_SEGMENT);
|
|
Variable v_LO_HI = new Variable("LO_HI", LevelComponent.TYPE.LO_HI);
|
|
Variable v_HI_LO = new Variable("HI_LO", LevelComponent.TYPE.HI_LO);
|
|
Variable v_LO_PATH = new Variable("LO_PATH", LevelComponent.TYPE.LO_PATH);
|
|
Variable v_HI_PATH = new Variable("HI_PATH", LevelComponent.TYPE.HI_PATH);
|
|
Variable v_lo_path = new Variable("lo_path", LevelComponent.TYPE.LO_PATH);
|
|
Variable v_hi_path = new Variable("hi_path", LevelComponent.TYPE.HI_PATH);
|
|
|
|
grammar.addVariable(v_START);
|
|
grammar.addVariable(v_LAND_SEGMENT);
|
|
grammar.addVariable(v_LO_HI);
|
|
grammar.addVariable(v_HI_LO);
|
|
grammar.addVariable(v_LO_PATH);
|
|
grammar.addVariable(v_HI_PATH);
|
|
|
|
grammar.addProductionRule(new ProductionRule(v_START,v_LAND_SEGMENT,v_LAND_SEGMENT));
|
|
|
|
grammar.addProductionRule(
|
|
new ProductionRule(v_LAND_SEGMENT,
|
|
new OrClause( new double[] {0.25,0.65,0.10},
|
|
new AndClause(v_LO_HI,v_HI_LO),
|
|
v_LO_PATH,
|
|
new AndClause(v_LAND_SEGMENT,v_LAND_SEGMENT)
|
|
)
|
|
)
|
|
);
|
|
|
|
grammar.addProductionRule(
|
|
new ProductionRule(v_LO_HI, v_LO_PATH, v_HI_PATH)
|
|
);
|
|
|
|
grammar.addProductionRule(
|
|
new ProductionRule(v_HI_LO, v_HI_PATH, v_LO_PATH)
|
|
);
|
|
|
|
grammar.addProductionRule(
|
|
new ProductionRule(v_HI_PATH,
|
|
new OrClause( new double[] {0.25,0.75},
|
|
new AndClause(v_HI_PATH,v_HI_PATH),
|
|
v_hi_path
|
|
)
|
|
)
|
|
);
|
|
|
|
grammar.addProductionRule(
|
|
new ProductionRule(v_LO_PATH,
|
|
new OrClause( new double[] {0.25,0.75},
|
|
new AndClause(v_LO_PATH,v_LO_PATH),
|
|
v_lo_path
|
|
)
|
|
)
|
|
);
|
|
|
|
grammar.setStart(v_START);
|
|
|
|
return grammar;
|
|
}
|
|
}
|