这是从[email=http://godson.blueidea.com/archives/2007/5778.shtml]http://godson.blueidea.com/archives/2007/5778.shtml[/email]上面看到的。
他给出了算法:
After starting at position 2,2 on the grid, the algorithm randomly chooses an adjacent target location (up, down, left or right) that is exactly two cells away.
After making its choice, it connects its current position with that location.
When it successfully makes a choice, it remembers the new location and chooses again.
When no locations are available - it has hit a dead end - it grabs the last successful position and tries again.
When there are no available positions left to try, the maze is complete.
虽然看明白了点,可我还是无法下手去做。
想到论坛这里问问高手:树好生成,但如何让树上任何两点有且只有一条通路??