NetLogo / GIS-Extension

the GIS (Geographic Information Systems) extension bundled with NetLogo
Other
27 stars 20 forks source link

NetLogo let target min-one-of neighbors math operation produced a non-number #47

Open jmstadt opened 1 year ago

jmstadt commented 1 year ago

Hello, I am new to NetLogo, so I apologize if this is the wrong forum. I am trying to reproduce the following: https://github.com/YangZhouCSS/Pedestrian_Model_Krasnow. I know when I load the .nlogo it warns me that it was produced in 5.2 and I am using 6.3 so I may have to make changes for it to work. But, I am not sure what changes to make.

The error I get is: math operation produced a non-number error while patch -25 -58 running + called by procedure GO called by Button 'go'

It comes from the following line in the code:

let target min-one-of neighbors [ elevation + ( count turtles-here * 9999999) ]

Which is in the to go section:

`to go if count turtles > 0 [set move-speed count turtles with [moved? = true] / count turtles] if count turtles = 0 [stop]

ask patches with [exit = 1] [ask turtles-here[die]]

ask turtles [ set moved? false let target min-one-of neighbors [ elevation + ( count turtles-here * 9999999) ]

if [elevation + (count turtles-here * 9999999)] of target < [elevation] of patch-here
[ face target
  move-to target
  set moved? true
  ask target [set path path + 1]]

]

if Show_path? [ask patches with [elevation < 9999999][let thecolor (9.9 - (path * 0.15)) if thecolor < 0.001 [set thecolor 0.001] set pcolor thecolor]] tick end `

I am looking at the .asc files and I see that the NAN value is -9999. I am thinking that the error arises because one of the neighbors is -9999. But, in the to setup section, I would have thought the "set-world-envelope" would prevent that.

I know this is not a bug so apologize again if this is the improper place to ask this question. I posted in StackOverflow here: https://stackoverflow.com/questions/74977284/netlogo-let-target-min-one-of-neighbors-math-operation-produced-a-non-number/74985127#74985127

I am trying to get this project to work as it is similar to something else I am trying to do.

jmstadt commented 1 year ago

Just fyi, I commented out and changed the following line of code and it worked. Not sure why, but I was able to move forward.

;let target min-one-of neighbors [ elevation + ( count turtles-here * 9999999) ] let target min-one-of neighbors [ elevation ]