<commit_before>package dpm.lejos.project;

import dpm.lejos.orientation.Coordinate;
import dpm.lejos.orientation.Mapper;
import dpm.lejos.orientation.Node;
import lejos.nxt.comm.RConsole;

import java.util.ArrayList;

/**
 * Provides all the necessary navigation capabilities
 *
 * All motion is managed by this class
 *
 * @author <NAME>
 * @version 1.5
 */
public class Navigation {

    private Odometer m_Odometer;
	public Mapper mapper;

    private Robot m_robot;

    private boolean movingForward = false;

    /**
     * default constructor
     *
     * @param robot the robot object
     * @param odometer the odometer object reference
     */
	public Navigation(Robot robot, Odometer odometer){
        m_robot = robot;
        mapper = new Mapper(Mapper.MapID.Lab5);
        m_Odometer=odometer;
        m_Odometer.setNavigation(this);
	}

    public Navigation(Robot robot, Odometer odometer, Mapper.MapID id){
        m_robot = robot;
        mapper = new Mapper(id);
        m_Odometer=odometer;
        m_Odometer.setNavigation(this);
        m_Odometer.startCorrection();
    }

    /**
     * perform the navigation planning to get to the desired coordinate
     *
     * call to <code>computeMoveList</code> that will move the robot
     * @param endingCoordinate the desired finish point
     */
    public void navigate(Coordinate endingCoordinate){

        Coordinate startingCoordinate = m_robot.getPositionOnGrid();
        RConsole.println("start x = " + Integer.toString(startingCoordinate.getX()) + " y = " + Integer.toString(startingCoordinate.getY()));
        //TODO: make sure that this is not BACKWARDS!!!!
        Node current = mapper.graphPlane[startingCoordinate.getX()][startingCoordinate.getY()];
        Node finish = mapper.graphPlane[endingCoordinate.getX()][endingCoordinate.getY()];

        ArrayList<Node> reverseDirections = new ArrayList<Node>();
        ArrayList<Node> queue = new ArrayList<Node>();
        queue.add(current);
        current.setVisited(true);

        while(!queue.isEmpty()){
            current = queue.remove(0);
            if (current.equals(finish)){
                break;
            } else {
                for(Node node : current.getNeighbours()){
                    if(!node.getVisited()){
                        queue.add(node);
                        node.setVisited(true);
                        node.setPrevious(current);
                    }
                }
            }
        }

        RConsole.println(Integer.toString(reverseDirections.size()));

        for(Node node = finish; node != null; node = node.getPrevious()) {
            reverseDirections.add(0, node);
        }

        mapper.printDirections(reverseDirections);
        ArrayList<Coordinate> moveList = computeMoveList(reverseDirections);
        performMoves(moveList);
    }

    /**
     * preform the list of movements
     * @param directions the list of movements to follow
     */
    public ArrayList<Coordinate> computeMoveList(ArrayList<Node> directions) {

        ArrayList<Coordinate> coorList = new ArrayList<Coordinate>();
        int index = 0;
        while (directions.size()>1) {
            Node initial = directions.get(0);
            Node next = directions.get(1);
            if (initial.getX() == next.getX()) {

                //next has same x
                while (index + 1< directions.size()) {
                    if (directions.get(index).getX() == directions.get(index + 1).getX()) {
                        index++;
                    } else {
                        break;
                    }
                }
                removeBefore(directions, index);

                //reset index to 0 since we remove everything before it.
                index = 0;

                RConsole.println("X: " + directions.get(index).getX() + ", Y: " + directions.get(index).getY());
                coorList.add(directions.get(index).getCoordinate());
<commit_msg>attempt to fix the build<commit_after>package dpm.lejos.project;

import dpm.lejos.orientation.Coordinate;
import dpm.lejos.orientation.Mapper;
import dpm.lejos.orientation.Node;
import lejos.nxt.comm.RConsole;

import java.util.ArrayList;

/**
 * Provides all the necessary navigation capabilities
 *
 * All motion is managed by this class
 *
 * @author <NAME>
 * @version 1.5
 */
public class Navigation {

    private Odometer m_Odometer;
	public Mapper mapper;

    private Robot m_robot;

    private boolean movingForward = false;

    /**
     * default constructor
     *
     * @param robot the robot object
     * @param odometer the odometer object reference
     */
	public Navigation(Robot robot, Odometer odometer){
        m_robot = robot;
        mapper = new Mapper(Mapper.MapID.Lab5);
        m_Odometer=odometer;
        m_Odometer.setNavigation(this);
	}

    public Navigation(Robot robot, Odometer odometer, Mapper.MapID id){
        m_robot = robot;
        mapper = new Mapper(id);
        m_Odometer=odometer;
        m_Odometer.setNavigation(this);
        m_Odometer.startCorrection();
    }

    /**
     * perform the navigation planning to get to the desired coordinate
     *
     * call to <code>computeMoveList</code> that will move the robot
     * @param endingCoordinate the desired finish point
     */
    public void navigate(Coordinate endingCoordinate){

        Coordinate startingCoordinate = m_robot.getPositionOnGrid();
        RConsole.println("start x = " + Integer.toString(startingCoordinate.getX()) + " y = " + Integer.toString(startingCoordinate.getY()));
        //TODO: make sure that this is not BACKWARDS!!!!
        Node current = mapper.graphPlane[startingCoordinate.getX()][startingCoordinate.getY()];
        Node finish = mapper.graphPlane[endingCoordinate.getX()][endingCoordinate.getY()];

        ArrayList<Node> reverseDirections = new ArrayList<Node>();
        ArrayList<Node> queue = new ArrayList<Node>();
        queue.add(current);
        current.setVisited(true);

        while(!queue.isEmpty()){
            current = queue.remove(0);
            if (current.equals(finish)){
                break;
            } else {
                for(Node node : current.getNeighbours()){
                    if(!node.getVisited()){
                        queue.add(node);
                        node.setVisited(true);
                        node.setPrevious(current);
                    }
                }
            }
        }

        RConsole.println(Integer.toString(reverseDirections.size()));

        for(Node node = finish; node != null; node = node.getPrevious()) {
            reverseDirections.add(0, node);
        }

        mapper.printDirections(reverseDirections);
        ArrayList<Coordinate> moveList = computeMoveList(reverseDirections);
        performMoves(moveList);
    }

    /**
     * preform the list of movements
     * @param directions the list of movements to follow
     * @return the list
     */
    public ArrayList<Coordinate> computeMoveList(ArrayList<Node> directions) {

        ArrayList<Coordinate> coorList = new ArrayList<Coordinate>();
        int index = 0;
        while (directions.size()>1) {
            Node initial = directions.get(0);
            Node next = directions.get(1);
            if (initial.getX() == next.getX()) {

                //next has same x
                while (index + 1< directions.size()) {
                    if (directions.get(index).getX() == directions.get(index + 1).getX()) {
                        index++;
                    } else {
                        break;
                    }
                }
                removeBefore(directions, index);

                //reset index to 0 since we remove everything before it.
                index = 0;

                RConsole.println("X: " + directions.get(index).getX() + ", Y: " + directions.get(index).getY());
                coorList.add(directions.get(index).getCoordinate());

{'fraction_non_alphanumeric': 0.10875298254426724, 'fraction_numerical': 0.003265101092553058, 'mean_word_length': 2.1060842433697347, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3816095', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2137, 'n_words': 493}