![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
Re: Closed geometry: a train track problemby abcde (Scribe) |
on Jan 03, 2006 at 18:10 UTC ( #520682=note: print w/replies, xml ) | Need Help?? |
I just typed up a nice algorithm here (which was essentially brute force) when I thought of a much better one. Damn. This one should be better, and you can apply it in real life as well.
This seems boring, but it's much, much faster than trying a brute-force method, and it still produces interesting tracks. One of the interesting things (that I just thought of) about this design is the pathfinding - if you're laying down a track, but there's another piece of track in the way, don't remove the bit of track, but use one of the circle pieces to divert it around that bit of track. This makes the rails run together, as rails tend to do! If you're really looking for a challenge, try making the algorithm recursive by using it again while doing step 2.2. And well done for thinking of such an interesting puzzle!
~abseed
In Section
Seekers of Perl Wisdom
|
|