Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How to implement the wall follower algorithm in java?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to implement the wall follower algorithm in java?

    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.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to implement the wall follower algorithm in java?

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/55382-how-implement-wall-follower-algorithm-java.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to implement the wall follower algorithm in java?

    Yeah sorry. I have posted it on the other java forum as well. I was trying to get various opinions. Sorry about that.

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: How to implement the wall follower algorithm in java?


  5. The Following User Says Thank You to Darryl.Burke For This Useful Post:

    copeg (February 10th, 2012)

  6. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to implement the wall follower algorithm in java?

    Quote Originally Posted by michaelnana View Post
    Yeah sorry. I have posted it on the other java forum as well. I was trying to get various opinions. Sorry about that.
    If you read the links in Darryl and my posts, you would realize what cross posting does - it wastes the time of those trying to help, in affect biting the hand that feeds you. You have yet to be forthright in disclosing your crossposts, and yes this will hurt your chances of receiving help

Similar Threads

  1. how to implement timed out event in java?!
    By migongotar in forum Java Theory & Questions
    Replies: 3
    Last Post: December 15th, 2018, 07:41 AM
  2. Replies: 0
    Last Post: November 6th, 2011, 03:55 PM
  3. How do I implement a login system in java using arrays
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 21st, 2011, 08:03 AM
  4. What are HashCode and equals in Java and thay are implement in java?
    By diyaots in forum Java Theory & Questions
    Replies: 2
    Last Post: September 9th, 2011, 08:38 AM
  5. Simple java program to calculate wall covering of a room
    By parvez07 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 22nd, 2009, 03:31 PM