Kick start requested for scripting an experiment 

I'm trying to script my first experiment, and would appreciate some initial guidance to get me going. I've looked at available expdefs but don't seem to be able to find what I need.

I'm building on the reproduction.expdef example and as a simple start I'm trying to add a second population of creatures, which do just the same as the first creature group (ie. eat food and multiply) except that they will have a different genotype. Once I get it going I'd later like to play with the properties (eg. e_meta) of the two populations to see them compete for food.

It seems that all the members of the ExpProperties class are single. Does ExpProperties allow these members to be replicated for additional populations?

I'm thinking that perhaps I should use the add function of ExpProperties to create new instances (is that the right programming word?) of the default members, eg. duplicate e_meta to make e_meta_2 that can then be called upon by the second population. Similarly, would I use the add function to create the second genotype, say initialgen_2 ?

If I'm on the right track, how would this look in code, and how would I then call it up to create and manipulate the second population?

Thanks for any help that can be offered. If there's an existing ExpProperties script that I've overlooked that will show me how to do these sorts of things, just steer me in that direction!

Cheers

Ian

Forums: 
Maciej Komosinski's picture

Yes, you can add e_meta_2, initialgen_2, etc. This is simple - you just add new "property:" sections at the end of the expdef script file.

The standard.expdef uses two populations (one is called Creatures, the other is Food). Note that various handlers (procedures that are called on some events) use these names: for example, the general function onStep() is called once every simulation step, while function onCreaturesStep(cr) is called for creatures in the "Creatures" population, in each simulation step.

So you can either have handlers that specify "by name" which group they concern (onFoodKill) or have general handlers (e.g., onKill) that handle all creatures, and include some logic inside the handler (if (Populations.group == 0) {...}).

Populations.addGroup("Rabbits"); will add another population (as in standard.expdef).

Thanks Maciej - I'll give that a go.

Cheers

Ian

Maciej - I've got it working. Thanks. A follow-up question - is there a way to make different populations of creatures different colours (or is creature colour fixed by the world's visual style)?

I've used AAAAAAA modifiers to make one lot of creatures light green but I'd prefer to make them, say red.

Thanks,

Ian

Maciej Komosinski's picture

Great! :-) Regarding OpenGL visualization, this is entirely dependent on scripts that reside in the 3dobj subdirectory (*.style files).

Have a look at the function default_joint_build() in standard.style. Depending on the assimilation ability of a stick, it loads greenstick[1-5].ac models which use green[1-5].png textures.

By the way, in simulation it is Parts that have the assimilation property, not Joints, so the assimilation of a Joint is - for visualization purposes - computed as the average of the two Parts.

You can also paint the whole creature with a single color - read docs for VisualModel.getArg, sample usage in function mark_model_build(). This requires either the Vstyle field specified in the f0 genotype, or the creature.model.Vstyle="mystyle(parameter=value)"; set when a creature is born. Then you can write the mystyle_model_build() function and get the value of the parameter inside this function.

Many thanks again Maciej (you can see that I'm hooked!) :-)

Ian

Got this bit working too, by modifying default_joint_build to set stick = Population.index before calling loadAndAddAsTransformNode(stick), so that different populations have different stick colours (I'll make some new texture files too).

Cheers

Ian

Maciej Komosinski's picture

stick = Population.index - smart! :-)