jeudi 31 mai 2018

How can I get child id of hatched turtle inside the ask turtle context?

I just started using netlogo and I'm trying to transition away from OOP, so I apologize if my coding paradigm is the source of my issue.

Problem

Inside an ask turtle procedure I have hatched a turtle. I want to create a link to the hatched turtle with the turtle that hatched it. I do not need to remember family ties.

Attempts to solve the problem

ask turtles [
    setxy ( mean [pxcor] of my-territory ) ( mean [pycor] of my-territory )
    show my-territory
    let parent-node [hatch 1]
    [ set color red
      if parent-node != nobody
      [ create-link-with parent-node [ set color green ]
        move-to old-node ;; position the new node near its partner
        fd 8
      ]]]

But the hatch gives me the error the it expects a literal value. 1 is a literal correct? What would be the best way of thinking about how to solve this?

Aucun commentaire:

Enregistrer un commentaire