本文整理汇总了Java中pacman.controllers.examples.Legacy类的典型用法代码示例。如果您正苦于以下问题:Java Legacy类的具体用法?Java Legacy怎么用?Java Legacy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Legacy类属于pacman.controllers.examples包,在下文中一共展示了Legacy类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBest
import pacman.controllers.examples.Legacy; //导入依赖的package包/类
@Override
public Genome getBest(List<Genome> population) {
// Populate
if (population == null)
population = newPopulation();
Genome bestGenome = null;
for(int g = 0; g < generations; g++){
// Test
double[] scores = new double[size];
int idx = 0;
for(Genome genome : population){
System.out.println("Testing fitness for: " + genome);
double score = runExperimentWithAvgScore(new GeneticPacman2(genome), new Legacy(), trials);
scores[idx] = score;
idx++;
}
// Stop if last generation
if (g == generations-1)
return bestGenome;
population = newPopulation();
}
return null;
}
示例2: MonteCarloPacManParameters
import pacman.controllers.examples.Legacy; //导入依赖的package包/类
/**
* Constructor. Sets default values for the parameters.
*/
public MonteCarloPacManParameters()
{
nodeExpansionThreshold = 30;
maximumSimulationLength = 10000000;
deathPenalty = 10000;
scaleDeathPenalty = false;
completionReward = 10000;
pacManModel = new StarterPacMan();
ghostModel = new Legacy();
selectionPolicy = new LevineUcbSelectionPolicy(4000);
additionalEvaluators = new ITreeEvaluator[] { new DistanceToOpportunityEvaluator(), new PowerPillDistanceEvaluator(), new PowerPillActiveEvaluator() };
discardTreeOnDecision = true;
opponent = new Legacy();
simulationCount = -1;
showGraph = false;
useGhostPositions = true;
eatGhostNode = true;
/*nodeExpansionThreshold = 50;
maximumSimulationLength = 10000000;
deathPenalty = 10000;
scaleDeathPenalty = false;
completionReward = 10000;
pacManModel = new StarterPacMan();
ghostModel = new Legacy2TheReckoning();
selectionPolicy = new LevineUcbSelectionPolicy(4000);
additionalEvaluators = new ITreeEvaluator[] { new DistanceToOpportunityEvaluator(), new PowerPillDistanceEvaluator(), new PowerPillActiveEvaluator() };
discardTreeOnDecision = true;
opponent = new Legacy();
simulationCount = -1;
showGraph = false;
useGhostPositions = true;
eatGhostNode = false;*/
}
示例3: main
import pacman.controllers.examples.Legacy; //导入依赖的package包/类
/**
* The main method. Several options are listed - simply remove comments to use the option you want.
*
* @param args the command line arguments
*/
public static void main(String[] args)
{
Executor exec=new Executor();
/*
//run multiple games in batch mode - good for testing.
int numTrials=10;
exec.runExperiment(new RandomPacMan(),new RandomGhosts(),numTrials);
*/
//run a game in synchronous mode: game waits until controllers respond.
int delay=0;
boolean visual=true;
//[pillValue=401, pillMultiplier=-8.043920635206801, powerPillValue=-49, ghostValue=7426, deathValue=-7269, winValue=-2327, stepValue=982, dangerDistance=47, killDistance=4]
//10793.333333333334 - [pillValue=754, pillMultiplier=-3.80047351578399, powerPillValue=855, ghostValue=5437, deathValue=-3029, winValue=-7990, stepValue=360, dangerDistance=37, killDistance=11]
//exec.runGame(new GeneticPacman1(new Genome(401, -8.043920635206801, -49, 7426, -7269, -2327, 982, 47, 4)),new StarterGhosts(),visual,delay);
//exec.runGame(new GeneticPacman2(new Genome(754, -3.80047351578399, 855, 5437, -3029, -7990, 360, 37, 4)),new StarterGhosts(),visual,delay);
//exec.runGame(new Ms2PacAstar2(),new StarterGhosts(),visual,delay);
//exec.runGame(new RandomJunctionPacman(), new StarterGhosts(), visual, delay);
//exec.runGame(new MCTSNIELS(), new Legacy(), visual, delay);
//exec.runGame(new QLearner(), new Legacy(), visual, delay);
for(int i = 1; i <= 40; i++){
System.out.print(i + "\t");
Executor execi=new Executor();
execi.runGame(new MCTSNIELS(), new Legacy(), true, delay);
//exec.runGame(new GeneticPacman2(new Genome(473, 3.1854737562458, 688, 9768, -8513, 3055, 521, 79, 4)),new Legacy2TheReckoning(),false,delay);
}
//[pillValue=473, pillMultiplier=3.1854737562458, powerPillValue=688, ghostValue=9768, deathValue=-8513, winValue=3055, stepValue=521, dangerDistance=79, killDistance=4, mutated=0]
///*
//run the game in asynchronous mode.
//boolean visual=true;
// exec.runGameTimed(new NearestPillPacMan(),new AggressiveGhosts(),visual);
//exec.runGameTimed(new GeneticPacman(),new StarterGhosts(),visual);
//exec.runGameTimed(new HumanController(new KeyBoardInput()),new StarterGhosts(),visual);
//*/
//run the game in asynchronous mode but advance as soon as both controllers are ready - this is the mode of the competition.
//time limit of DELAY ms still applies.
//boolean visual=true;
/*
boolean fixedTime=false;
exec.runGameTimedSpeedOptimised(new GeneticPacman(), new StarterGhosts(),fixedTime,visual);
*/
/*
//run game in asynchronous mode and record it to file for replay at a later stage.
boolean visual=true;
String fileName="replay.txt";
exec.runGameTimedRecorded(new HumanController(new KeyBoardInput()),new RandomGhosts(),visual,fileName);
//exec.replayGame(fileName,visual);
*/
}