<commit_before>package edu.utdallas.robotchess.robot;

import java.util.*;

public class Path
{
    private int robotID;
    private int origin;
    private ArrayList<Integer> path;

    public Path(int robotID, int origin)
    {
        this.robotID = robotID;
        this.origin = origin;
        path = new ArrayList<>();
    }
    
    protected void add(int location)
    {
        path.add(location);
    }
    
    public ArrayList<Integer> getPath()
    {
        return path;
    }
    
    public int getRobotID()
    {
        return robotID;
    }

    public Command generateCommand()
    {
        int[] payload = new int[path.size()];

        for(int i = 0; i < path.size(); i++)
            payload[i] = path.get(i);

        return new MoveToSquareCommand(robotID, payload);
    }
 }
<commit_msg>add algorithm for removing intermediate squares in a path<commit_after>package edu.utdallas.robotchess.robot;

import java.util.*;

public class Path
{
    private int robotID;
    private int origin;
    private ArrayList<Integer> path;

    public Path(int robotID, int origin)
    {
        this.robotID = robotID;
        this.origin = origin;
        path = new ArrayList<>();
    }
    
    protected void add(int location)
    {
        path.add(location);
    }
    
    public ArrayList<Integer> getPath()
    {
        return path;
    }
    
    public int getRobotID()
    {
        return robotID;
    }

    public Command generateCommand()
    {
        ArrayList<Integer> payload = new ArrayList<>();
        
        int previousDirection = path.get(0) - origin;

        for(int i = 1; i < path.size(); i++) {
            int newDirection = path.get(i) - path.get(i-1);
            if (newDirection != previousDirection) {
                path.add(i-1);
                previousDirection = newDirection;
            }
        }
        
        path.add(path.size() - 1);

        int[] payloadArr = new int[path.size()];
        for (int i = 0; i < payloadArr.length; i++)
            payloadArr[i] = path.get(i);
        
        return new MoveToSquareCommand(robotID, payloadArr);
    }
 }

{'fraction_non_alphanumeric': 0.11095439586271744, 'fraction_numerical': 0.003291020216267043, 'mean_word_length': 1.887381275440977, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 11, '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': '3096255', 'n_tokens_mistral': 649, 'n_tokens_neox': 633, 'n_words': 159}