import java.io.PrintStream;

public class MyWorld {
    private Robot r;
    private double t;
    private PrintStream out;
    private Maze maze;


    public MyWorld() {
        this(System.out);
    }

    public MyWorld(PrintStream output) {
        this.out = output;
        this.r = null;
        this.t = 0;
    }

    public void setRobot(Robot r) {
        this.r = r;
    }

    public void setMaze(Maze m) {
        this.maze = m;
    }

    public boolean isThere_a_wall(int x, int y) {
        return maze.isThere_a_wall(x, y);
    }

    public void printStateDescription() {
        String s = "Time" + ",\t" + r.getDescription();
        this.out.println(s);
    }

    private void printState(double t) {
        this.out.println(String.format("%.3f", t) + ",\t" + r.toString());
    }

    public void simulate (double delta_t, double endTime, Maze maze) {
        for ( ; t < endTime; t += delta_t) {
            r.moveDelta_t(delta_t);
            maze.markPoint(r.getPosition());
            printState(t);
        }
    }
}
