Re: NSUInteger hash
Re: NSUInteger hash
- Subject: Re: NSUInteger hash
- From: "Kyle Sluder" <email@hidden>
- Date: Sun, 17 Aug 2008 15:08:36 -0400
On Sun, Aug 17, 2008 at 12:43 PM, Steve Wart <email@hidden> wrote:
> I go through the rooms in random order, pick a wall at random, and knock it
> down (also being careful to knock down the corresponding wall in any
> adjacent rooms). By knocking down a wall, two rooms become merged into one.
> When I have only one room left, it means that the maze is complete.
Sounds like the perfect use case for union-find. Since each cell can
only have four walls, you really only need three bits per cell. You
could use a 2D array of bytes to represent your entire maze, and
randomly toggle bits until you wind up with one set (room). Then,
once the maze has been generated, convert that into an object
representation for the rest of your app to consume.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden