1

I'm working on extending NetLogo Robotic Factory with a mechanism where there can be only one robot per machine and where the machine takes several ticks to perform the task.

To model this, I'm creating a link between the robot and the machine. And there can only be one link per machine.

It is the first time I'm using NetLogo. So I'm not used to switching contexts. I'm trying to find out how I can give orders to both the robot and the machine when they are linked.

to move
  ask robots [
    if waiting = 0 [
      if can-move? 1 [forward 1 face destination]
      set energy energy - 1
    ]
    if waiting > 0 [
      set waiting waiting - 1
    ]
  ]
end


to set-robots-destination 
  ask robots [
    (ifelse
    ; --------------- 
    ; Step1: forges
    ; ---------------
      [ breed ] of destination = forges [ 
        ifelse any? forges-here [ 
          if [count links] of one-of forges-here = 0 [
            create-link-with one-of forges-here
            set color of one-of forges-here red
            set waiting 5
            if waiting = 0 [
              set costs costs + 1 
              set destination one-of forges
              set [color] of one-of materials-here blue
              ask my-links [ die ]
            ]
          ]
        ]
        [ move ] 
      ]
...

As you can see, repeating one-of forge there create several issues. First of all the syntax to change its color is incorrect. Then, it is unclear if the color will actually turn blue by the end or if the robot will already have left.

I would prefer to find a way to switch context with the linked forge and give it orders directly. Is this possible?

Xiiryo
  • 3,021
  • 5
  • 31
  • 48

0 Answers0