-2
$\begingroup$

I have a robot that has a start and goal position within a maze. Each point in the maze-grid is simply a Position object containing x and y. I need an algorithm that specifies the robot only moving to its relative right only using goEast, west, east and south from the perspective of the maze. There is an implementation already (with uml and mathod names) that does not support degrees or heading. Just current position, next position and then directions in absolute terms. And the logic that goes for the robor for going only to it's relative right.

$\endgroup$
2
  • 1
    $\begingroup$ Sorry, but still there is no problem here, what you have posted is underspecified at best. We do not see uml or your problems from post or comments. If you know positions via x,y coordinates, use them for directions. If you do not know starting direction, do not have any frane of reference, the problem is only solvable via exploration (nearest obstacle vs starting position to tetrive direction), if this is not an option, the problem is unsolvable. If say starting position is 2,3, and the next position is 3,3, it was east. This coordinates tell you what is the heading. $\endgroup$
    – Evil
    Jun 20 '18 at 22:36
  • $\begingroup$ I do apologize for the vague problem specification, and I realize that I should have explained more. This is a uni assignment and I was afraid to be branded a cheater/to actually cheat, or to let the assignment to be found on stackoverflow. I have learned that either I fully define the problem as much as I can or I don't. It was simply too abstract in this case. In the given UML we were supposed just edit one and implement two classes, robots. But only absolute coordinates were provided. I was hesitant to ask, but as suggested here, I was also supposed to create robot's frame of reference. $\endgroup$
    – Senethys
    Jun 22 '18 at 2:41
0
$\begingroup$

I'm not sure what the difficulty is, here. If the robot is facing north, its right is east; if the robot is facing east, its right is south; etc.

$\endgroup$
3
  • $\begingroup$ Need to specify that it doesn't have any directions as such. $\endgroup$
    – Senethys
    Jun 20 '18 at 18:27
  • $\begingroup$ So create frame of reference. If it is facing south, keep directions as it moves. $\endgroup$
    – Evil
    Jun 20 '18 at 18:30
  • 1
    $\begingroup$ @Senethys Please specify the problem fully by editing the question. $\endgroup$ Jun 20 '18 at 18:41
0
$\begingroup$

As suggested in another comment, a viable solution would be to keep track of the heading of your object.

Your goEast function would look something like this:

while(heading != south)
    turn right 90 degrees

Same thing for the rest of the directions

$\endgroup$
1
  • $\begingroup$ There is an implementation already (with uml and mathod names) that does not support degrees or heading. Just current position, next position and then directions in absolute terms. $\endgroup$
    – Senethys
    Jun 20 '18 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.