Maze solving: Difference between revisions

Content deleted Content added
Line 1,488:
WAttrib(mz.window,"canvas=normal") # show it
until Event() == &lpress # wait for left mouse press
qMice := set() # Active mice
goodMice := set() # Mice that found solutions
startPos := findStart(mz.maze)
 
insert(qMice,QMouse(mz.maze,startPos)) # Start first quantum mouse
# block until all quantum mice have finished
waitForCompletion()
Line 1,558 ⟶ 1,557:
every r := 1 to *region do region[r] := list(*m[1])
every !!region := mutex()
qMice := set() # Active mice
}
insert(qMice,self)
maze := m
loc := l
Line 1,568 ⟶ 1,569:
if atEnd() then insert(goodMice, self) # This mouse found a finish
else { # Spawn more mice to look for finish
insert(qMice, QMouse(maze, goNorth(), path))
insert(qMice, QMouse(maze, goSouth(), path))
insert(qMice, QMouse(maze, goEast(), path))
insert(qMice, QMouse(maze, goWest(), path))
}
delete(qMice, self)