soooo I did a thing, finally got it working last night https://github.com/nate/labyrinth
my first serious-ish clojure project
it needs tests, badly
Neat, you could try a generative test checking that you can get from one point in the maze to any other point
oh a solver is definitely on my list
I want to name it minotaur (not theseus because no one remembers him)
I'll give look over the code after work for you
oh that would be awesome, thanks!
please be merciless, I really want to improve
I probably should add docs or at least reasoning for why things are put together how they are
there's always more to do, I suppose
A simple test would be checking that all squares have at least one "open" side
hmmm
if one open side faced the open side of another cell, that would pass that test
solving the maze seems incredibly amenable to parallelism
start with a threadpool working off a queue, in the main thread add the different directions off the entrance to the queue. each thread walks the direction until it reaches another decision point where it enqueues the two+ directions that are possible, repeat
and then be listening on a channel for when the exit is found
sort of flooding the maze by using threads, letting each thread handle flooding of one direction
if it's not a perfect maze then you could let the threads continue to flood the maze and then compare the paths to get the shortest one
terminating the threads might be tricky
but I guess if you have a quit channel and a queue channel and the thread pool listens on each with alts, preferring the quit channel, then we can just close the quit channel to force all the threads to exit
or go blocks or what have you
From playing around with go blocks and multi threaded tasks in the past my advice is to get a serial process working first. Concurrency even in Clojure gets tricky and hard to debug very fast 🙂
for sure
I rewrote this library at one point, made it work 98% better: https://github.com/igrigorik/agent
but eventually I just ripped it out of my projects and used forking so everything could be done serially yet in parallel
also because ruby
always because ruby