Life Simulation Game - Design a Lifeform

Home   Rules   Download   Running the Game   Design a Lifeform   Results   Strategy  

A lifeform is implemented using a COM automation server. At present, programming knowledge is required to create one - if you would like an option to create lifeforms without requiring programming knowledge, email me to say so.

Sample code for the "plant" lifeform is available for download here as a Microsoft Visual C++ project.

Each lifeform requires a class description such as "plant.plant" which can be used to register the COM class. This must be unique on the target PC so don't re-use these names.

The COM automation server must have the following properties:

[id(1)] long Energy;
[id(2)] BSTR IndividualName;
[id(3)] BSTR SpeciesName;
[id(4)] BSTR ClassDescription;
[id(5)] long XPosition;
[id(6)] long YPosition;

and the following methods:
[id(7)] void Initialise(IDispatch* poWorldDispatch);
[id(8)] BSTR NextAction();

Note that "long" is a four byte integer for non-C++ implementors.

When your lifeform is initialised, you will be passed a pointer to the world object. You should store a reference to this, and use it subsequently to find out information about the world. The World object has the following COM properties:

[id(1)] long MaxX;
[id(2)] long MaxY;

and the following methods:
[id(3)] BSTR GetSpeciesName(long X, long Y);
[id(4)] BSTR GetIndividualName(long X, long Y);
[id(5)] short IsOccupied(long X, long Y);
[id(6)] BSTR LastAction(long X, long Y);
[id(7)] long GetGreennessOfGrass(long X, long Y);

When passing parameters, the coordinates are zero-based, so they range from 0 to 9 in the default world.

Defining your lifeform's behaviour

You lifeform's behaviour is determined by your response to the method call "NextAction". Your implementation should return a string of one of the following forms:
"SitStill"
"Eat(1,0)", "Eat(-1,0)", "Eat(0,1)" or "Eat(0,-1)"
"Defend"
"Move(1,0)", "Move(-1,0)", "Move(0,1)" or "Move(0,-1)"
"Reproduce(1,0)", "Reproduce(-1,0)", "Reproduce(0,1)" or "Reproduce(0,-1)"

Note that the 1s and 0s passed as parameters are X and Y offsets respectively from the lifeform's own cell, so (-1,0) is the cell to the left, and (0, 1) is the cell above etc.

Not all parameter values are checked by the world, so please be careful not to crash it!
Hosted by www.Geocities.ws

1