hey first post on stack overflow im asking about an issue on net logo as im doing a project in it. im making a flocking simulation but when i tried to impalement other behaviors using ifelse statements, but when i put the ifelse statement into it, they don't follow any behaviors, rather they just move. heres the code:
breed [Birds Bird] breed [Hawks Hawk]
to Setup clear-all reset-ticks create-Birds Number_of_Birds[ setxy random-xcor random-ycor] create-Hawks Number_of_Hawks[ setxy random-xcor random-ycor] end
to Start ask Birds[ set color white ifelse (Hawks in-radius Reaction_Distance = 0) [ set heading Migration_Direction let closest-Birds max-n-of Target_Group_Size (other Birds) [distance myself] let Group_Heading mean [heading] of closest-Birds let centroidx mean [xcor] of closest-Birds let centroidy mean [ycor] of closest-Birds set heading (Migration_Direction +( attraction * (Group_Heading))) fd 1 set heading ( attraction * (towardsxy centroidx centroidy) ) fd 1 ] [ let Closest_Hawks max-n-of 1 (Hawks) [distance myself] set heading (mean [heading] of Closest_Hawks + 180) fd 1 ] ] end
Aucun commentaire:
Enregistrer un commentaire