public void printEndWorld() { try { environment.printEnvironment(); System.out.println("Final score: " + currScore); System.out.println("Last action: " + Action.printAction(lastAction)); } catch (Exception e) { System.out.println("An exception was thrown: " + e); } }
public Simulation(Environment wumpusEnvironment, int maxSteps, boolean nonDeterministic) { // start the simulator simulationRunning = true; // outputWriter = outWriter; transferPercept = new TransferPercept(wumpusEnvironment); environment = wumpusEnvironment; agent = new Agent(environment, transferPercept, nonDeterministic); environment.placeAgent(agent); environment.printEnvironment(); printCurrentPerceptSequence(); StateSeq.add(lastAction); try { System.out.println("Current score: " + currScore); // outputWriter.write("Current score: " + currScore + "\n"); while (simulationRunning == true && stepCounter < maxSteps) { System.out.println("Last action: " + Action.printAction(lastAction)); // outputWriter.write("Last action: " + Action.printAction(lastAction) + "\n"); System.out.println("Time step: " + stepCounter); // outputWriter.write("Time step: " + stepCounter + "\n"); int action = agent.chooseAction(); handleAction(action); StateSeq.add(action); wumpusEnvironment.placeAgent(agent); environment.printEnvironment(); printCurrentPerceptSequence(); System.out.println("Current score: " + currScore); // outputWriter.write("Current score: " + currScore + "\n"); // Scanner in = new Scanner(System.in); // in.next(); stepCounter += 1; if (stepCounter == maxSteps || simulationRunning == false) { System.out.println("Last action: " + Action.printAction(lastAction)); // outputWriter.write("Last action: " + Action.printAction(lastAction) + "\n"); System.out.println("Time step: " + stepCounter); // outputWriter.write("Time step: " + stepCounter + "\n"); lastAction = Action.END_TRIAL; StateSeq.add(lastAction); } if (agent.getHasGold() == true) { System.out.println("\n" + agent.getName() + " found the GOLD!!"); // outputWriter.write("\n" + agent.getName() + " found the GOLD!!\n"); } if (agent.getIsDead() == true) { System.out.println("\n" + agent.getName() + " is DEAD!!"); // outputWriter.write("\n" + agent.getName() + " is DEAD!!\n"); } } } catch (Exception e) { System.out.println("An exception was thrown: " + e); e.printStackTrace(); } printEndWorld(); }