public void saveTrace(String filename) {
		try {
			BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
			for  (AgentState s : state){
				if (s instanceof BacktrackingAgentState){
					BacktrackingAgentState b = (BacktrackingAgentState)s;
					int touch = (b.isHasTouched()) ? 1 : 0;
					double sonar = b.getSonar();
					int sound = b.getSound();
					writer.append(touch + "|" + sonar + "|" + sound + "|" + s.getAction().toString() + "\n");
				}
			}
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}