PDA

View Full Version : Karel The Robot Question



zackj3
October 23rd, 2010, 03:33 AM
I'm very new to programming / C++, and I have stumbled on this problem for a few hours now and was curious if someone can help.

Assume Karel is on a street corner, and he needs to check the 4 adjacent street corners around him (north, south, east, west). It is guaranteed that one and ONLY one of these adjacent corners contain a random number of beepers.

My problem is just to get Karel to check each corner and return back to the original street he starts on.

Also, there is the possibility that his front is blocked by a wall

if (frontIsClear)
Move();
if (nextToABeeper)
count the beepers (i have a function already for this)
else
TurnLeft();
TurnLeft();
Move();

this isn't right though. any suggestions?

Some Penguin
October 23rd, 2010, 08:07 AM
*shrug* How did Hans and Gretel plan on finding their way back through the forest?