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);
    }
 }

@@ -595,85 +595,520 @@
     
-int%5B%5D payload = new int%5Bpath.size()%5D;%0A%0A        for(int i = 0; i %3C path.size()
+ArrayList%3CInteger%3E payload = new ArrayList%3C%3E();%0A        %0A        int previousDirection = path.get(0) - origin;%0A%0A        for(int i = 1; i %3C path.size(); i++) %7B%0A            int newDirection = path.get(i) - path.get(i-1);%0A            if (newDirection != currentDirection) %7B%0A                path.add(i-1);%0A                currentDirection = newDirection;%0A            %7D%0A        %7D%0A        %0A        path.add(path.size() - 1);%0A%0A        int payloadArr = new int%5Bpath.size()%5D;%0A        for (int i = 0; i %3C payloadArr.length
 ; i+
@@ -1129,16 +1129,19 @@
  payload
+Arr
 %5Bi%5D = pa
@@ -1151,16 +1151,24 @@
 get(i);%0A
+        
 %0A       
@@ -1215,16 +1215,19 @@
  payload
+Arr
 );%0A    %7D

add algorithm for removing intermediate squares in a path