- Implemented the reward weighting.
- Fixed a balance issue with the blocks and coins on straight stretches of even length.
This commit is contained in:
@@ -17,9 +17,9 @@ import dk.itu.mario.level.matcher.ArchetypeMatcher;
|
||||
import dk.itu.mario.level.matcher.ProfileMatcher;
|
||||
|
||||
public class PCGLevel extends Level {
|
||||
public static double POWERUP_PROBABILITY = .1;
|
||||
public static double BLOCKS_PROBABILITY = .3;
|
||||
public static double COINS_PROBABILITY = .5;
|
||||
public double powerupProbability;
|
||||
public double blocksProbability;
|
||||
public double coinsProbability;
|
||||
public static int COIN_REWARD = 1;
|
||||
public static int POWERUP_REWARD = 2;
|
||||
|
||||
@@ -103,6 +103,13 @@ public class PCGLevel extends Level {
|
||||
GrammarTuner.tune(grammar, profile, archetype);
|
||||
|
||||
System.out.println("Creating level.");
|
||||
|
||||
// TODO Refactor into a probability setter function so that we can set
|
||||
// the challenge probabilities, too.
|
||||
blocksProbability = profile.getProbability(TYPE.BLOCKS);
|
||||
coinsProbability = profile.getProbability(TYPE.COINS);
|
||||
powerupProbability = profile.getProbability(TYPE.POWER_UP);
|
||||
|
||||
create(seed, profile, archetype, grammar);
|
||||
}
|
||||
|
||||
@@ -134,7 +141,8 @@ public class PCGLevel extends Level {
|
||||
private void create(long seed, PlayerProfile profile,
|
||||
LevelArchetype archetype, LevelGrammar grammar) {
|
||||
|
||||
System.out.println("PlayerProfile.getProbability(COINS): " + profile.getProbability(TYPE.COINS));
|
||||
System.out.println("PlayerProfile.getProbability(COINS): "
|
||||
+ profile.getProbability(TYPE.COINS));
|
||||
|
||||
if (dataRecorder == DataRecorder.BLANK_RECORD) {
|
||||
System.out
|
||||
@@ -486,7 +494,7 @@ public class PCGLevel extends Level {
|
||||
setBlock(
|
||||
xo + x,
|
||||
floor - 6,
|
||||
(random.nextDouble() <= POWERUP_PROBABILITY) ? Level.BLOCK_POWERUP
|
||||
(random.nextDouble() <= powerupProbability) ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
}
|
||||
|
||||
@@ -539,7 +547,7 @@ public class PCGLevel extends Level {
|
||||
setBlock(
|
||||
xo + x,
|
||||
floor - 7,
|
||||
random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
}
|
||||
}
|
||||
@@ -681,9 +689,9 @@ public class PCGLevel extends Level {
|
||||
private int shouldAddReward() {
|
||||
double guess = random.nextDouble();
|
||||
|
||||
if (guess < COINS_PROBABILITY) {
|
||||
if (guess < coinsProbability) {
|
||||
return 1;
|
||||
} else if (guess < COINS_PROBABILITY + BLOCKS_PROBABILITY) {
|
||||
} else if (guess < coinsProbability + blocksProbability) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -1079,12 +1087,12 @@ public class PCGLevel extends Level {
|
||||
setBlock(
|
||||
xo + length + 1,
|
||||
this.height - heightMod - 3,
|
||||
random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + length + 2,
|
||||
this.height - heightMod - 3,
|
||||
random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
}
|
||||
|
||||
@@ -1152,7 +1160,8 @@ public class PCGLevel extends Level {
|
||||
|
||||
else {
|
||||
setSpriteTemplate(xo + (length / 2), floor - 1,
|
||||
new SpriteTemplate(enemyType, shouldAddChallenge(ChallengeType.HARDER_ENEMY)));
|
||||
new SpriteTemplate(enemyType,
|
||||
shouldAddChallenge(ChallengeType.HARDER_ENEMY)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1175,32 +1184,34 @@ public class PCGLevel extends Level {
|
||||
xo + (start - 2),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + (start - 1),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + start,
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + (start + 2),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + (start + 1),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
if (length % 2 != 0) {
|
||||
setBlock(
|
||||
xo + (start + 2),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
}
|
||||
}
|
||||
|
||||
else if (length >= 5) {
|
||||
@@ -1211,19 +1222,19 @@ public class PCGLevel extends Level {
|
||||
xo + (start - 1),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + start,
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
setBlock(
|
||||
xo + (start + 1),
|
||||
floor - 3,
|
||||
coins ? Level.COIN
|
||||
: random.nextDouble() < POWERUP_PROBABILITY ? Level.BLOCK_POWERUP
|
||||
: random.nextDouble() < powerupProbability ? Level.BLOCK_POWERUP
|
||||
: Level.BLOCK_COIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,16 @@ import java.util.Set;
|
||||
import dk.itu.mario.level.matcher.ProfileMatcher.SKILL;
|
||||
|
||||
public class PlayerProfile {
|
||||
//From Bartle/Yee models of player psychology: achiever, killer, explorer, manipulator
|
||||
public enum TYPE { BUMPER, COLLECTOR, RUNNER, SHOOTER, JUMPER}
|
||||
// From Bartle/Yee models of player psychology: achiever, killer, explorer,
|
||||
// manipulator
|
||||
public enum TYPE {
|
||||
BUMPER, COLLECTOR, RUNNER, SHOOTER, JUMPER
|
||||
}
|
||||
|
||||
// Dreyfus model of skill acquisition:
|
||||
public enum SKILL_LEVEL { NOVICE, BEGINNER, COMPETENT, PROFICIENT, EXPERT}
|
||||
public enum SKILL_LEVEL {
|
||||
NOVICE, BEGINNER, COMPETENT, PROFICIENT, EXPERT
|
||||
}
|
||||
|
||||
private Set<LevelComponent.TYPE> enabledComponents = new HashSet<LevelComponent.TYPE>();
|
||||
|
||||
@@ -18,7 +24,8 @@ public class PlayerProfile {
|
||||
private Map<SKILL, Integer> skillVector;
|
||||
private TYPE type;
|
||||
|
||||
public PlayerProfile(SKILL_LEVEL skillLevel, TYPE type, Map<SKILL,Integer> skillVector) {
|
||||
public PlayerProfile(SKILL_LEVEL skillLevel, TYPE type,
|
||||
Map<SKILL, Integer> skillVector) {
|
||||
this.skillLevel = skillLevel;
|
||||
this.type = type;
|
||||
this.skillVector = skillVector;
|
||||
@@ -61,13 +68,37 @@ public class PlayerProfile {
|
||||
if (!isEnabled(type)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// SKILLs: { BUMP, COLLECT, JUMP, RUN, SHOOT, STOMP }
|
||||
// TYPEs: { BUMPER, COLLECTOR, RUNNER, SHOOTER, JUMPER}
|
||||
|
||||
switch (type) {
|
||||
case BLOCKS:
|
||||
return 0.3;
|
||||
return (.5) * (skillVector.get(SKILL.BUMP) / 100.0);
|
||||
case COINS:
|
||||
return 0.5;
|
||||
return (.5) * (skillVector.get(SKILL.COLLECT) / 100.0);
|
||||
case POWER_UP:
|
||||
return 0.1;
|
||||
double skillMod = 0;
|
||||
switch (skillLevel) {
|
||||
case BEGINNER:
|
||||
skillMod = .8;
|
||||
break;
|
||||
case COMPETENT:
|
||||
skillMod = .6;
|
||||
break;
|
||||
case PROFICIENT:
|
||||
skillMod = .4;
|
||||
break;
|
||||
case EXPERT:
|
||||
skillMod = .2;
|
||||
break;
|
||||
default:
|
||||
skillMod = 1;
|
||||
}
|
||||
|
||||
skillMod = (skillMod + (skillVector.get(SKILL.SHOOT) / 100.0)) / 2.0;
|
||||
|
||||
return (.3) * skillMod;
|
||||
default:
|
||||
return 0.1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user