# C# Pathing algorithm for moving a object from point(X, Y) to point(X, Y)

Given a object which may move forward, backward, left and right at a given X,Y point. How to efficiently direct the object to a X,Y point using the given movement mechanics in the most efficient and human natural way.

The object is available for movement in real time, you may tell them to "startMoving|Direction|()" and "stopMoving|Direction|()" to any heading of 360 degrees. Though as a additional twist and the part I am having trouble with, is the facing of the object is never known, only its current location is known, so the algorithm must "detect" direction. The location of the object is updated in a separate thread in 500-1second intervals. A "Request" to update the location within the algorithm made be made at any point, but it is not immediately available and the algorithm must keep that in consideration. Doing something like requestAndWaitForCoordUpdate() is perfectly acceptable, however likely not needed.

In addition, no obstacles appear, it can be assumed you are on a MOSTLY open plane, stray to far from the direct straight line between the paths and you may run into obstacles. It is safe to assume that 1/4th the distance between a target and source, should be available in width on a given direct path.

I would also mention I am not sure A* applys in this scenario, if it does I am unsure how to implement it given the constraints. The only real variable here is the facing of the object.

Here is some example code:

public int[] currentCoords;
public void movement() {
currentCoords[0] = 1005; // starting y coord
currentCoords[1] = 1007; // starting x coord
moveTo(1050, 1025);
}

public void moveTo(int x, int y) {
... how?
}

... periodically check for source coord updates
... between 200ms and 1000ms apart.
}

• What means of rotating does the object has available? Commented Mar 23, 2011 at 2:37
• Not sure if I understand the question. The object may only move horizontally and vertically and cannot rotate? Is that right? Commented Mar 23, 2011 at 7:40

originalPosition = (3 ; 2)