(Line 36) Expected a number here, rather than a list or block

67 Views Asked by At

Don't know what this really means or what's causing this. My code is heavily modeled from the community model "Fire" The Error:

(Line 36) Expected a number here, rather than a list or block.
globals [
  initial-plants  
  triggered-plants    
]

breed [signals signal]   

to setup
  clear-all
  set-default-shape turtles "square"
  ask patches with [(random-float 100) < density]
    [ set pcolor green ]
  ask patches with [pxcor = min-pxcor]
    [ transmit ]
  set initial-plants count patches with [pcolor = green]
  set triggered-plants 0
  ask patches with [ pcolor = red ] [
    ; See if there is any possible neighbor patch
    ; to whom I can spread my lack of concentration
    let target one-of neighbors4 with [ pcolor = green ]

    ; if the target exists, have them change their color
    if target != nobody [
      ask target [ 
        set pcolor red
      ]
    ]
  ]
  reset-ticks
end

to go
  if not any? turtles  
    [ stop ]
  ask signal
    [ask neighbors4 with [pcolor = green]
      [ transmit ] ]
  tick
end

to transmit  
  start signal 1
    [ set color blue ]
  set pcolor black
  set triggered-plants triggered-plants + 1
end
1

There are 1 best solutions below

0
lmf0845 On

You used "signal" so the singular, but need to use the plural "signals". Or specify which signal, e.g. by the who-number (ask signal 1 [...). This is where your described error comes from.

Additionally, you got an error due to the undefined start you used, but I think this is something else you are working on?

Here is a revised version of your code:

globals [
  initial-plants  
  triggered-plants    
]

breed [signals signal]   

to setup
  clear-all
  set-default-shape turtles "square"
  ask patches with [(random-float 100) < density]
    [ set pcolor green ]
  ask patches with [pxcor = min-pxcor]
    [ transmit ]
  set initial-plants count patches with [pcolor = green]
  set triggered-plants 0
  ask patches with [ pcolor = red ] [
    ; See if there is any possible neighbor patch
    ; to whom I can spread my lack of concentration
    let target one-of neighbors4 with [ pcolor = green ]

    ; if the target exists, have them change their color
    if target != nobody [
      ask target [ 
        set pcolor red
      ]
    ]
  ]
  reset-ticks
end

to go
  if not any? turtles  
    [ stop ]
  ask signals
    [ask neighbors4 with [pcolor = green]
      [ transmit ] ]
  tick
end

;to transmit  
;  start signal 1
;    [ set color blue ]
;  set pcolor black
;  set triggered-plants triggered-plants + 1
;