4

What my code does is to set an internal grey patch zone and an external black patch zone, where turtles can multiply (one on each patch). Once a turtle reach the boundary between the gray and the black zones I assigned the variable energy to delay the reproduction of the turtle by certain ticks ( each tick energy grows one unit). When energy reaches certain number I wanted the turtles to hatch new turtles in one of the empty black patches, but after the first generation of new turtles in the black zone i get the runtime error " MOVE-TO expected input to be an agent but got NOBODY instead."

This is my code

breed [greens a-green]
breed [reds a-red]
greens-own[energy]

to setup
  clear-all
  ask patch 0 0 [ ask patches in-radius 15 [set pcolor 3]]
  ask n-of 20 patches with [pcolor = 3][sprout-greens 1 [set color green set energy 0]]
  ask n-of 20 patches with [pcolor = 3][sprout-reds 1 [set color red]]
  reset-ticks
end

to go
  division
  delay-expansion
  expansion
  tick
end

to division
ask greens[
    let empty-space neighbors with [pcolor = 3 and not any? turtles-here] ;crea un set llamado "empty-space" que son los patches negros q rodean a la celula verde y q no estan ocupados
    if any? empty-space [hatch 1 set color green move-to one-of empty-space] ; si existe algun patch negro alrededor, nace una celula verde y se ubica en ese patch
  ]

ask reds[
    let empty-space neighbors with [pcolor = 3 and not any? turtles-here] ;crea un set llamado "empty-space" que son los patches negros q rodean a la celula roja y q no estan ocupados
    if any? empty-space [hatch 1 set color red move-to one-of empty-space] ; si existe algun patch negro alrededor, nace una celula roja y se ubica en ese patch
  ]
end

to delay-expansion
  ask greens[
    let black-space neighbors with [pcolor = black and not any? turtles-here]
    if any? black-space [set energy (energy + 1 )]
  ]
end

to expansion
  ask greens[
    let black-space neighbors with [pcolor = black and not any? turtles-here]
    if energy > 5  [hatch 1 set color blue move-to one-of black-space]
  ]
end
  • 3
    In your last procedure (expansion), you have a move-to that's not protected by an `if any? black-space` check. If the green doesn't have any vacant black spaces, you will get the error you described because the agentset black-space is empty. – JenB Oct 23 '18 at 11:41
  • Thanks, its now working – Oscar Gallardo Oct 24 '18 at 17:33

0 Answers0