0

Good day,

I am working with Levelspace since I want to create a model of Agents with brains. I have two files:

  • the master containing the environnement within which agents without brain can evolve with simple rules
  • the child containing the brain every agent will have after binding the two files.

I want to pass informations from the child models to the master so I am using this kind of code in the master:

print [vecteur_binaire] ls:of ls:models

with vecteur_binaire a function of the child model. But I noticed that the code above do work only for globals and that it doesn't work for functions. For example, with the code above, it will return : " Extension exception: Model 0 (brain of (herbivore 0)) encountered an error: ITEM expected input to be a string or list but got the number 0 instead. error while herbivore 1 running LS:OF called by procedure CHOOSE_AND_MOVE_HERBIVORE called by procedure MOVE called by procedure GO called by Button 'go'"

this error highlighting the "ls:of" of the code. I really do not understand what is happening and why I have this error message. Moreover, becuause of this, I can't run my child model and so make brains work well.

Do you know houw to solve it?

Thank you very much in advance for your reponse!

Juliette

More complete code:

In the master:

to choose_and_move_herbivore [in]
     (ls:assign in visual_input [ vision ]  of self ) 
      print [vecteur_binaire] ls:of in
end 

with "in" the id number of the child model.

In the child model:

to-report vecteur_binaire
          go
          report o_t
end 

with "go" another function calling other functions in the programm to make brains work, and o_t the value that interests me.

Juliette
  • 1
  • 1
  • It looks like you have a `item` primitive in one of your models that is trying to access an entry in a list. NetLogo initialises a variable with the number 0 if it is not explicitly initialised and the list has not been constructed, which is what your error message means. Without seeing your code with the `item` line, it is difficult to work out more about the problem. – JenB Jul 27 '20 at 08:43
  • thank you for your response! I understand what you are saying about the creation of the empty list, but i don't know why the programm would be creating a list when I ask to run a function. This error is only happening when I add the line above in my programm. – Juliette Jul 27 '20 at 09:55
  • The code is really long, so I let you see the functions associated : In the master: ```to choose_and_move_herbivore [in] (ls:assign in visual_input [ vision ] of self ) print [vecteur_binaire] ls:of in``` with "in" the id number of the child model. In the child model: ```to-report vecteur_binaire go report o_t end ``` with "go" another function calling other functions in the programm to make brains work, and o_t the value that interests me. See above for a clearer complete code. – Juliette Jul 27 '20 at 10:02

0 Answers0