Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot solve mazes with wrap x or wrap xy, wrap y works fine #5

Open
MtnViewJohn opened this issue Feb 24, 2018 · 3 comments
Open

Cannot solve mazes with wrap x or wrap xy, wrap y works fine #5

MtnViewJohn opened this issue Feb 24, 2018 · 3 comments

Comments

@MtnViewJohn
Copy link

MtnViewJohn commented Feb 24, 2018

Theseus can solve mazes with no wrapping or with wrap y but it hangs when trying to solve mazes with wrap x or wrap xy. The astar solver cannot solve with wrap y.

john@paravmubuntu16_04:~$ theseus -w 10 -H 10 --wrap x -f png -o maze
maze written to maze.png
john@paravmubuntu16_04:~$ theseus -w 10 -H 10 --wrap x -f png -o maze -V
^C/var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/solvers/base.rb:29:in `solved?': Interrupt
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/solvers/base.rb:43:in `solve'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/formatters/png.rb:79:in `initialize'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/formatters/png/orthogonal.rb:16:in `initialize'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/maze.rb:653:in `new'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/maze.rb:653:in `to'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/cli.rb:157:in `block in run_static'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/cli.rb:157:in `open'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/cli.rb:157:in `run_static'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/cli.rb:70:in `run'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/lib/theseus/cli.rb:25:in `run'
	from /var/lib/gems/2.3.0/gems/theseus-1.1.0/bin/theseus:5:in `<top (required)>'
	from /usr/local/bin/theseus:23:in `load'
	from /usr/local/bin/theseus:23:in `<main>'

john@paravmubuntu16_04:~$ theseus -w 10 -H 10 --wrap y -f png -o maze -V
maze written to maze.png
john@paravmubuntu16_04:~$ 

@jamis
Copy link
Owner

jamis commented Feb 25, 2018

This is because of how the default entrance and exit are determined by theseus. When wrapping in x (or xy), theseus's default algorithm for finding those points doesn't work, so the solver gets stuck trying to find a path between two points that aren't actually connected to the maze.

While theseus should definitely handle this case more gracefully, you can work around it in the meantime by telling it exactly where you want solution to start and stop, e.g.:

$ theseus -w 10 -H 10 --wrap x -f png -o maze -V -E 0,0 -X 9,9
maze written to maze.png

The -E option says which cell should be treated as the entrance (starting point), and the -X says which cell should be treated as the exit (ending point).

@MtnViewJohn
Copy link
Author

Maybe theseus should just refuse to create a default entrance and exit if wrapping is enabled. There is still something going on with the astar algorithm. This command sometimes hangs and sometimes runs to completion:

theseus -w 40 -H 10 --solve astar --wrap x -E 0,0 -X 20,9 -f png -o maze2

The backtracker algorithm always seems to work if an entrance and exit are provided.

@jamis
Copy link
Owner

jamis commented Feb 25, 2018

Yeah. To be honest, I don't really have a lot of time to maintain this program. It needs to be rewritten (the existing architecture makes some dubious choices) and tested (the existing tests don't really cover much). It's not much better than a proof-of-concept at the moment, though it can do some fun things if you're willing to work around the quirks. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants