1

I'm looking to a way to create a matrix filled with random values. Tried to create a matrix:make-constant, which, obviously, returns a constant (say, a matrix full of 6s). This answer doesn't seem to be working properly.

In my model, hunters should give random values to every patch in the world. They would then use this value to judge the opportunity to wait for game:

hunters-own [hunter-matrix]

to setup
  clear-all
  create-hunters number-hunters [ 
    setxy random-xcor random-ycor
    set hunter-matrix matrix:make-constant 33 33 random 10  ]
end

Is there a way to make the matrix filled with random numbers instead?

gvanhavre
  • 113
  • 3

1 Answers1

2

The answer you linked to is still correct, but it's using the old NetLogo 5 task syntax instead of the new -> syntax: https://ccl.northwestern.edu/netlogo/docs/programming.html#anonymous-procedures

The procedure still works as is:

to-report fill-matrix [n m generator]
  report matrix:from-row-list n-values n [n-values m [runresult generator]]
end

However, you now call it using the -> syntax:

fill-matrix 33 33 [-> random 10]
Bryan Head
  • 12,360
  • 5
  • 32
  • 50