expected input to be a number but got the list

时间:2015-05-24 21:38:04

标签: netlogo

HI im starting a little game int net logo im trying to create some walls to appear randomly in the screen but i got this error, ill leave the code here thanks in advance

to setup
  ca
  let wall-down 20
  let wall-position 5
  let wall-up 10

  let wd list n-values 5 random 5
  (foreach wd [
    ask patches 
    [
      ifelse (pycor < ? - 16 and pxcor = wall-position )
      [ set pcolor gray ]
      [ set pcolor 97 ]
    ]
  ])

1 个答案:

答案 0 :(得分:1)

这里你真的不需要foreachn-values。写起来更简单:

to setup
  clear-all
  let wall-down 20
  let wall-position 5
  let wall-up 10
  repeat 5 [
    let y random 5
    ask patches [
      ifelse (pycor < y - 16 and pxcor = wall-position)
        [ set pcolor gray ]
        [ set pcolor 97 ]
    ]
  ]
end

无论如何你走n-values路线,bergant对语法是正确的。