FramScript questions 

Hi, I've been using Framsticks and writing my own experiments using the Framscript language, I was wondering if it would be possible for some assistance with a few issues.

Firstly, in a Vector or Dictionary structure, it appears the items are stored by reference, am I correct in thinking this?
For example in the following:
var vecA = Vector.new();
vecA.add("a");
vecA.add("b");
// Create a copy
var vecB = vecA;
vecB.set(0, "c");
Simulator.print(vecA);
Simulator.print(vecB);

Both vecA and vecB output the same: [c,b]
There's no issue with this, I merely wanted to check I was correct in my understanding.

Secondly, is there any simple way to create a copy of a Dictionary
In the classdocs http://www.framsticks.com/files/classdoc/c_dictionary.html it incorrectly states a Dictionary can be enumerated using just integer indexes:
var d=Dictionary.new();
d.set("name","John");
d.set("age",44);
var i,element;
for(i=0;i<d.size;i++)
element=d.get(i);

This does not appear to work unless the keys are set as integers, which would be just like using a Vector.

With this issue I can't see a simple way to create a copy of a Dictionary unless you know all of the key names. I was wondering if this was intended or an issue which could possibly be rectified.

Finally, is there any possible way to modify the components in a Model
For example removing a muscle. Currently I'm having to parse the original genotype, construct my own data structure, then manipulate it and finally I use this data structure to construct a new F0 genotype and finally create a Geno from this. A simple example of where this would be used would be in an experiment where creatures may lose the ability of controlling one limb.

Ideally it would be useful to be able to modify the Geno or Model directly, because currently I'm sure Framsticks is building up it's own internal data structure and I'm having to do the same concurrently.

Thanks a lot for your support.

Forums: 
Szymon Ulatowski's picture

  1. Actually, this experiment only shows that copying a variable into another variable copies the reference without cloning the referenced object. Nevertheless, the answer to the question you asked is also positive - vector and dictionary items are stored by reference, too.
  2. Thank you for finding the forgotten function! Iterating dictionary items and keys will be added in the next update.
  3. Yes, the Model object will be made editable eventually. I think your request may even speed up this Framsticks evolution a bit :-)
    Note: if by "parsing" you meant analyzing the textual form of the genotype, then you can skip this part and build the (currently non-editable) Model object from the genotype, and then read the creature elements from it. This is little help and it is clear that we really need the script-modifiable Model for such tasks...

Thanks for all of those answers, very useful :)

I have currently been using Framscript to convert my own genotype definition into f0. Which is why I have the parsing in framscript (which I'm sure isn't going to be ideal). I am planning on moving over to the SDK for this specific thing very shortly though.

I do have a quick question about using the SDK, if I compile my own genotype converter, I'm assuming this would have to be used as a standalone exe, ie I use the exe to construct the genotype, pass it to frams.exe in f0 format, get the output back and continue.
Is this correct? Or is there any way to make use of it in framsticks via a runtime library.

Cheers once again for your help, this amazing application has really got my interest :)

Luke

Maciej Komosinski's picture

Regarding genetics, there are two separate issues: conversion to any of the existing "formats" (if you decide do develop your own genetic encoding), and operators (to modify genotypes in your format).

You can implement these in FramScript, but if they get complex, then C++ may be a better choice (and then you use SDK and the GenoOperators class). You can test your code thoroughly outside of Framsticks, and once it is stable and mature, it can be included in Framsticks (we compile it together with the rest of source code).

Ah, that makes a lot of sense. I'll currently stick to using FramScript for the conversion to f0.

Cheers for all the support,
Luke