Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:56:34+00:00 2026-05-31T18:56:34+00:00

I have a program that is searching a maze to find the best way

  • 0

I have a program that is searching a maze to find the best way out. As it searches it adds the next move to an array. My problem is that it keeps repeating the same three moves over and over. I need to find the best way to check that array of moves in order to force it to change move when a loop has been detected.

edit for clarity,
http://www.logicmazes.com/theseus.html maze three is the one I’m testing. what happens is that it gets stuck moving up and down in the column it starts in.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:56:35+00:00Added an answer on May 31, 2026 at 6:56 pm

    It sounds like the problem is that your “state” doesn’t actually contain enough state information. In every cycle, after Theseus has moved and the Minotaur has moved twice, the state consists of the following:

    • Theseus’s x-coordinate.
    • Theseus’s y-coordinate.
    • The Minotaur’s x-coordinate.
    • The Minotaur’s y-coordinate.

    You can represent these as some sort of MazeState object whose equals and hashCode methods make it easy to see if two instances represent the same state.

    Since the Minotaur’s motion follows a very rigid program, every move that Theseus makes (left/right/up/down/delay) will move from one well-defined state to another. You then need to forbid Theseus from making any moves that:

    • Would cause the Minotaur’s x- and y-coordinates to equal those of Theseus (since this means Theseus is dead).
    • Would cause the new state to be equal to a state that you’ve previously been in (since this means that no progress has been made).

    To do this, you can store the previous states in a HashSet<MazeState>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that spits out both standard error and standard out, and
I have a small java program that searches the contents of all *.txt files
I have a program that should get the maximum out of my cpu. It
I've been searching for a way to have users set my program as the
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of
I have a program that I'm writing where I am using another company's library
I have a program that should run every night. Another is started every boot.
I have a program that saves images, but when I debug it I get
I have a program that creates lists and needs any assigned values to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.