Hey guys,
I'm new here. Well I'm working on my homework in java which is about implementing a rat that will traverse through the maze and exit.
So for my second rat I want to implement a left hand or right hand wall follower rat. i.e the rat will always check to see if there is a wall on the right and move along it.
The problem is I don't see how I can implement it. The reason I say this is because the rat is just a simple dot. I can't really tell it to move forward. I can say move up which is incrementing the rows or move right which is incrementing the cols so I reall can't figure out the wall follow algorithm.
I know I would need direction but every implementation of direction I have made so far just gets my rat stuck.
I'm looking for someone to help me understand the algorithm and how to implement it, like some sort of pseudo code and explanation. That would be greatly appreciated.
This may help as well. This is how the maze looks like.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
F X X
X XX XXX X XXXXXXXXXXXXXXXXX X
X X XXX X X X
XX X XXX XXXXX XXXXXXXXXXXXX X
XX X XXX X
XX X XXXXXXXXXXXXXXXXXXXXXXX X
XX X XX X XXXX X
XX X XX XXXXXXXXXXXXXXX XXXX X
X X XX X X
X XX XXXXXXXXXXXXXXXX X XXXXXX
X XX X XXXXXX
X XXXXXXXXXXXXXXXXXX XXXXXX
XXXXXXXXXXXXXXXXXXXXXXX XXXXXX
XXXX XXX XXXXXX
XXXXXXXXXXXXX XXXXXX XXXX
X X
X XXXXX XXXXXXXXXXXXXXXXXXXX X
X XXXXX X X X XXXXXXXXX X
X X X X XXXX X XXXXXXXXX X
X XXXXX X X X X X X
X X X X X XXXX XXXXXXXXX X
X X XXXXX X X XXXX XXXXXXXXX X
X X X X
X XXXXX X XXXXXXXXXXXXXXXXXXXX
X X X X
X X XXXXX XXXX XXXX XXXXXXXX X
X X XXXX XXXX X X
XSXXXXXXXXX X X X XX X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Where the x are the walls.
So yeah, thanks in advance.