/* give him unseen letters
/* run simulation
/* get result
/* return average */
GameEnvironment localEnv = internalEnv.clone();
Player simPlayer = localEnv.getPlayer(usedPlayer.getID());
//filling opponents racks with unseen letters
for (Player p : localEnv.getPlayerList())
if (p.getID()!=simPlayer.getID())
p.getRack().fill();
//playing submitted move
move.play(localEnv.board(), simPlayer);
simPlayer.addScore(localEnv.board().getWordPoints());
try {
localEnv.board().validate(true);
} catch (BoardWrongWordPlace e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
simPlayer.getRack().fill();
//completing first turn
for (Player p : localEnv.getPlayerList()) {
if (p.getID()!=simPlayer.getID()) {
generationAlgo.generate(localEnv.board(), p.getRack());
generationAlgo.getBestMove().play(localEnv.board(), p);
p.addScore(localEnv.board().getWordPoints());
try {
localEnv.board().validate(true);
} catch (BoardWrongWordPlace e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//playing remaining turns
for (int i=0 ; i<simulationDepth ; i++) {
for (Player p : localEnv.getPlayerList()) {
generationAlgo.generate(localEnv.board(), p.getRack());
generationAlgo.getBestMove().play(localEnv.board(), p);
p.addScore(localEnv.board().getWordPoints());
try {
localEnv.board().validate(true);
} catch (BoardWrongWordPlace e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//computing point differences
Player first=localEnv.getPlayer((simPlayer.getID()==0?1:0));
for (Player p : localEnv.getPlayerList()) {
if (p!=simPlayer && p.getScore()>first.getScore())
first=p;
}
return simPlayer.getScore()-first.getScore();