Monday, 15 September 2014

netlogo - Fail to set turtle's average heading with error message "mean expected input to be a list but got the number XXX instead" -



netlogo - Fail to set turtle's average heading with error message "mean expected input to be a list but got the number XXX instead" -

i'm trying inquire turtles turn toward average leader's heading when find nearest leader, when run code, error message pop-up "mean expected input list got number xxx instead" , it's point code:

[turn-towards average-heading-towards-leaders max-cohere-turn]

below finish code:

to go inquire turtles [check] tick end check if leader? [let beings-seen patches in-cone leader-vision leader-vision-angle [pcolor = red] ifelse any? beings-seen [let target one-of beings-seen face target ] [flock]] end flock allow nearby-leaders turtles [leader? ] if any? nearby-leaders in-radius vision [turn-towards average-heading-towards-leaders max-cohere-turn] end to-report average-heading-towards-leaders allow nearby-leaders turtles [leader? ] allow x-component mean [sin heading] of one-of nearby-leaders allow y-component mean [cos heading] of one-of nearby-leaders ifelse x-component = 0 , y-component = 0 [ study heading ] [ study atan x-component y-component ] end

can point wrong code. help.

the problem these 2 lines:

allow x-component mean [sin heading] of one-of nearby-leaders allow y-component mean [cos heading] of one-of nearby-leaders

[sin heading] of one-of nearby-leaders reports sine of heading of 1 of nearby leaders, single number. mean expects list. you're trying pass number expects list.

to prepare it, can rid of means in lines.

netlogo

No comments:

Post a Comment