import java.io.File;
import java.io.FileNotFoundException;

public class Stage3 {
    public static void main(String[] args) {
        if (args.length != 2) {
            System.out.println("Usage: java Stage3 <pbm input file> <pbm output file>");
            System.exit(0);
        }

        try {
            // Create the new maze.
            Maze maze = new Maze(new File(args[0]));
            // Write the maze with whitespaces to visualize it.
            String fixedFile = args[0].split("\\.")[0] + "_fixed.pbm";
            maze.write(new File(fixedFile));
            // Create a new Maze wit the robot route.
            Maze route = new Maze(maze);

            MyWorld world = new MyWorld();

            Vector2D position = new Vector2D(15, 35);
            Vector2D velocity = new Vector2D(0.0,-1.0);
            world.setMaze(maze);
            double deltaTime = 1.0;
            double sensorRange = 3;

            Robot r = new Robot(position, velocity, sensorRange, world);
            world.setRobot(r);
            world.printStateDescription();
            world.simulate(deltaTime, 120, route); // delta time[s], total simulation time [s].
            route.write(new File(args[1]));
        } catch (FileNotFoundException e) {
            System.out.println("File " + args[0] + " not found.");
        }

    }
}