Hi Steve,

Am So,17.08.2008 um 18:43 schrieb Steve Wart:

Hi Aaron,

That's always a good question to ask.

I'm porting a Smalltalk/OpenGL maze application I wrote a few years ago to
Cocoa.

The maze is initialized by creating a 2D matrix of Room objects which are separated by Wall objects. Every room has an ordered collection of walls which I've put into an NSMutableArray. Every wall has a start point and an end point and exists in exactly one room. So the common wall separating a
pair of rooms is actually represented by two walls.
I think, that this is the root of the problem. Two rooms are seperated by one wall. This is the (virtual) reality. Modelling this in a different way (rooms are seperated by two "surfaces") will cause problems in many ways.

What about remodelling this struture? If you need "double attributes" for a wall like color, hasWallPaper …, which are different on each surface, yo should model it this way: One wall entity with two surface entities.

Actually you divide one thing (wall) into two things (surfaces) and get problems, to glue it together again.

Cheers,
Amin



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.

I depend on isEqualTo: to compare the walls. They are both created from the
same set of points but they are different objects, so I can't use an
identity comparison. The Smalltalk code is reasonably clean but it's
bloating unpleasantly in Objective C so I will probably need to take a
higher-level look at what I'm trying to accomplish. The original maze
algorithm was cribbed from C so it shouldn't be too hard to make it work :-)

Steve

On Sun, Aug 17, 2008 at 12:10 AM, Aaron Lees <[EMAIL PROTECTED]> wrote:

What are you trying to do? It's usually a bad idea to compare floating point values for equality since you will run into subtle bugs to do with rounding. If you want to use your objects as dictionary keys it's often better to use a pointer equality rule instead of semantic equality. You can
do this with NSMapTable without any overrides in your class.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]

Amin Negm-Awad
[EMAIL PROTECTED]




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to