CHALLENGE rule randomly generates challenges.
This commit is contained in:
@@ -7,15 +7,39 @@ VAR LO_PATH = LO_PATH
|
||||
VAR HI_PATH = HI_PATH
|
||||
VAR lo_path = FLAT_LO
|
||||
VAR hi_path = FLAT_HI
|
||||
VAR pipes = PIPE_JUMP
|
||||
|
||||
###
|
||||
#Coin Dive (Some empty blocks. The user climbs them and runs off; coins line their path as they fall back to the ground.)
|
||||
#Free power-up. (Sets the player up to get a power-up with little or no challenge.)
|
||||
#Straight. (A straight stretch of land with maybe one enemy and maybe some coins or blocks.)
|
||||
#Single Pit (A pit that the user must jump over; rocks on either side.)
|
||||
#Bowling Alley (A red koopa right before a long line of enemies. Kill them all in a row by throwing the shell.)
|
||||
#Cannon Line (A stack of 2-3 canons.)
|
||||
#Maze (A... y’know... maze.)
|
||||
#Lemming Trap (A little pit with a few enemies that jump down into it.)
|
||||
#Platform Jump (A bunch of platforms to jump between.)
|
||||
#Pipe Jump (A bunch of thin pipes to jump between. This can be rendered much easier, because sometimes the space between the pipes is filled.)
|
||||
###
|
||||
|
||||
VAR coin_dive = COIN_DIVE
|
||||
VAR power_up = POWER_UP
|
||||
VAR single_pit = SINGLE_PIT
|
||||
VAR bowling_alley = BOWLING_ALLEY
|
||||
VAR cannon_line = CANNON_LINE
|
||||
VAR maze = MAZE
|
||||
VAR lemming_trap = LEMMING_TRAP
|
||||
VAR platform_jump = PLATFORM_JUMP
|
||||
VAR pipe_jump = PIPE_JUMP
|
||||
VAR CHALLENGE = CHALLENGE
|
||||
|
||||
#RULE name -> {probabilities}, (clause) [+,|] (clause)...
|
||||
RULE S -> LAND_SEGMENT + LAND_SEGMENT
|
||||
RULE LAND_SEGMENT -> {0.25,0.65,0.10}, (LO_HI + HI_LO) | (LO_PATH) | (LAND_SEGMENT + LAND_SEGMENT)
|
||||
RULE LO_HI -> LO_PATH + HI_PATH
|
||||
RULE HI_LO -> HI_PATH + LO_PATH
|
||||
RULE HI_PATH -> {0.25,0.75}, (HI_PATH + HI_PATH) | (hi_path)
|
||||
RULE LO_PATH -> {0.10,0.60,0.30}, (LO_PATH + LO_PATH) | (lo_path + pipes + lo_path) | (lo_path)
|
||||
RULE LO_HI -> LO_PATH + CHALLENGE
|
||||
RULE HI_LO -> CHALLENGE + LO_PATH
|
||||
#RULE HI_PATH -> {0.10,0.60,0.30}, (HI_PATH + HI_PATH) | (hi_path + CHALLENGE + hi_path) | (hi_path)
|
||||
RULE LO_PATH -> {0.10,0.60,0.30}, (LO_PATH + LO_PATH) | (lo_path + CHALLENGE + lo_path) | (lo_path)
|
||||
RULE CHALLENGE -> {0.10,0.10,0.10,0.10,0.10,0.10,0.10,0.10,0.10,0.10}, coin_dive | power_up | lo_path | single_pit | bowling_alley | cannon_line | maze | lemming_trap | platform_jump | pipe_jump
|
||||
|
||||
#START variable name
|
||||
START = S
|
||||
@@ -9,6 +9,6 @@ public class FitnessEvaluator {
|
||||
System.out.println("Evaluating LevelParseTree for fitness");
|
||||
List<LevelComponent> levelTemplate = parseTree.getLevelTemplate();
|
||||
//a good level has 8-16 components, plus some additional complexity depending on the player's skill level
|
||||
return levelTemplate.size() > 7 && levelTemplate.size() < 17;
|
||||
return levelTemplate.size() > 9 && levelTemplate.size() < 25;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,26 @@ package dk.itu.mario.level;
|
||||
|
||||
public class LevelComponent {
|
||||
public enum TYPE {
|
||||
BLOCKS, COINS, FLAT_HI, FLAT_LO, FLAT_SAFE, HI_LO, HI_PATH, LEVEL_SEGMENT, LEVEL, LO_HI, LO_PATH, MAZE, PIPE_JUMP, PLATFORM_JUMP, POWER_UP
|
||||
BLOCKS,
|
||||
BOWLING_ALLEY,
|
||||
CANNON_LINE,
|
||||
COIN_DIVE,
|
||||
FLAT_HI,
|
||||
FLAT_LO,
|
||||
FLAT_SAFE,
|
||||
HI_LO,
|
||||
HI_PATH,
|
||||
LEMMING_TRAP,
|
||||
LEVEL_SEGMENT,
|
||||
LEVEL,
|
||||
LO_HI,
|
||||
LO_PATH,
|
||||
MAZE,
|
||||
PIPE_JUMP,
|
||||
PLATFORM_JUMP,
|
||||
POWER_UP,
|
||||
SINGLE_PIT,
|
||||
CHALLENGE
|
||||
};
|
||||
|
||||
public enum MazeLevel {
|
||||
|
||||
@@ -1145,6 +1145,28 @@ public class PCGLevel extends Level {
|
||||
case MAZE:
|
||||
length += buildMaze(length, width - 64 - length);
|
||||
break;
|
||||
case BLOCKS:
|
||||
length += buildMaze(length, width - 64 - length);
|
||||
break;
|
||||
case BOWLING_ALLEY :
|
||||
length += buildBowlingAlley(length, width - 64 - length);
|
||||
break;
|
||||
case CANNON_LINE :
|
||||
length += buildCannonLine(length, width - 64 - length);
|
||||
break;
|
||||
case COIN_DIVE :
|
||||
length += buildCoinDive(length, width - 64 - length);
|
||||
break;
|
||||
case LEMMING_TRAP :
|
||||
length += buildLemmingTrap(length, width - 64 - length);
|
||||
break;
|
||||
case POWER_UP :
|
||||
length += buildFreebie(length, width - 64 - length);
|
||||
//length += buildStraight(length, lcomp.getEnd(), true);
|
||||
break;
|
||||
case SINGLE_PIT :
|
||||
length += buildSinglePit(length, width - 64 - length);
|
||||
break;
|
||||
default:
|
||||
System.out
|
||||
.println("Cannot build level segment for unrecognized LevelComponent type: "
|
||||
|
||||
@@ -83,6 +83,9 @@ public class LevelGrammarFactory {
|
||||
}
|
||||
|
||||
String remainder = clause.substring(rBraceIndex);
|
||||
if (remainder.startsWith("}, ")) {
|
||||
remainder = remainder.substring(3);
|
||||
}
|
||||
List<String> rhsClauseStrings = new ArrayList<String>();
|
||||
if (remainder.contains("(")) {
|
||||
int nextLeftIndex = -1;
|
||||
|
||||
Reference in New Issue
Block a user