Click to See Complete Forum and Search --> : A kingdom for a pattern!


Tomaz Stih
June 3rd, 1999, 11:49 AM
I am building an alife application using MFC. I have created a world and put inside little creatures. I have two objects concerning this situation. One is CWorld with methods that affect the entire population such as DestroyAllLife(), Genesis() and a list of all CCreature objects. The other is CCreature. An instance of CWorld is also a member of CDocument which acts as a controller. Now the problem I am trying to solve is how to couple classes CWorld and CCreature.

For example: The world of my creatures is flat. Actually some of them think it is not flat but they are WRONG! It is a CRect object as flat as it can be. When a creature decides to go on a vacation it travels around the world. Eventually it comes to the edge of the world. But how will my poor creature know it has come to the edge of the world? If it asks the world he lives in about the edge of the world that is not compliant with the low coupling of objects.
If it has a map (a knowledge about the world) it has an internal knowledge about another object.
But the problems get even worse. My creature has feelings about other creatures. It can see and admire other creatures. It can hurd. It can even fell inlove with another creature and they produce new cute little creatures with chromosones being mixture of their genes.
But how does my creature meet other creatures?
How does it see them? How does a male creature see the beauty of a female creature?
Again it can't ask world about it and it can't have it's own handbook with list of all interesting creatures with their phone numbers.
Help! How would you organize these objects?
I am so desperate that I am thinking about creating a CGod object which my little creatures could ask about anything they wish to know...

---------------------------------------------
Tomaz Stih, B.Sc.CS tomaz@nameco.com
Ob sotoccju 10 Nameco Group
SI-1000 Ljubljana http://www.nameco.com
Europe

Gary Grant
June 3rd, 1999, 03:28 PM
Check the C++ section of this site. It has a subsection on design paterns.

June 4th, 1999, 01:34 AM
A few million years ago--after the '60s but before the '90s--the American magazine "Scientific American" published an article on pattern algorithms for a "cocktail party". Although the author was rather "tongue-in-cheek", the algorithms were valid and included topics such as spatial proximity, attraction (to other party-goers, the bar, and/or the buffet table) and basic goals/objectives (getting a date, getting drunk, eating). If you have access to a good library, you might be able to find a reprint of the article.

Cheers!
Humble Programmer
,,,^..^,,,