View Single Post
 
Reply
Posted 2004-09-18, 01:12 PM in reply to Demosthenes's post "Need a little help"
If you give the mouse a "facing" direction (say, north = 0, west = 1, etc) then you can do something like the following:

Code:
"Feel" the wall to the left of the mouse, depending on his direction
IF (WallIsThere == false)
{
   Rotate Counter-Clockwise
   Move Forward
}
ELSE
{
    Check in front of the mouse
    IF (WallInFront == false)
    {
         Move Forward
    }
    ELSE
    {
         Rotate Couter-Clockwise
    }

}
Anytime you call the "Move Forward" function, you toggle the current floor marker (. or +), then move your ghosted mouse to the next tile. This will "clear" the marker if you hit a dead end. The mouse will try all possible places (luckily there are no loops..).

Of course, you'll probably end up with diagonals where the mouse tested a dead-end. In your example, here's the output:

Code:
# # # # # # # # # #
# . # M + . # . . # 
# . # # + # # # . #
# . . . + + . . . #
# # # # . # + # # #
# . . . . # + # C #
# # # # # # + # + #
# . # . . . + # + #
# . . . # . + + + #
# # # # # # # # # #
This is easy to fix. Just scan the entire maze for "." tiles, and check the tiles surrounding it in the four compass directions. If you get 2 "+"'s, add a "+" to that period tile.

I'm going to run this in my head a few times to see if I can spot any errors in my logic..

Last edited by BlueCube; 2004-09-18 at 01:15 PM.
Old
Profile PM WWW Search
BlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzBlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
BlueCube