private void evaluateServerMode()
{
Server server = new Server(evaluationOptions.getServerAgentPort(), Environment.numberOfObservationElements, Environment.numberOfButtons);
evaluationOptions.setAgent(new ServerAgent(server, evaluationOptions.isFastTCP()));
Simulation simulator = new BasicSimulator(evaluationOptions.getSimulationOptionsCopy());
while (server.isRunning())
{
String resetData = server.recvUnSafe();
if (resetData.startsWith("ciao"))
{
System.out.println("Evaluator: ciao received from client; restarting server");
server.restartServer();
continue;
}
if (resetData.startsWith("reset"))
{
resetData = resetData.split("reset\\s*")[1];
evaluationOptions.setUpOptions(resetData.split("[\\s]+"));
//TODO: Fix this in more general way
((ServerAgent)evaluationOptions.getAgent()).setFastTCP(evaluationOptions.isFastTCP());
init(evaluationOptions);
// Simulate One Level
EvaluationInfo evaluationInfo;
long startTime = System.currentTimeMillis();
String startMessage = "Evaluation started at " + GlobalOptions.getDateTime(null);
LOGGER.println(startMessage, LOGGER.VERBOSE_MODE.ALL);
simulator.setSimulationOptions(evaluationOptions);
evaluationInfo = simulator.simulateOneLevel();
evaluationInfo.levelType = evaluationOptions.getLevelType();
evaluationInfo.levelDifficulty = evaluationOptions.getLevelDifficulty();
evaluationInfo.levelRandSeed = evaluationOptions.getLevelRandSeed();
evaluationSummary.add(evaluationInfo);