2014-10-16 4 views
1
리더의 제목과 동일 myheading 설정하는 방법

난 할 노력하고있어입니다 :는 Netlogo

의사 코드

to flock 
check flockmates 
if find any leader inside the flockmates 
    change myheading to leader's heading 
else 
    follow flocking rule [separate, allign, cohesion] 
end 

아래는 내가 사용하는 코드입니다. 나는이 코드를 실행하면

turtles-own 
[ flockmates 
    nearest-neighbor 
    leader? 
    leader 
] 

to setup 
__clear-all-and-reset-ticks 

ask n-of population patches with [ pcolor = blue] 
[sprout 1 
    [set color white 
    set size 0.6 
    set leader? false] 
    ] 
choose-leaders 
end 

to choose-leaders 
ask n-of ((percent_of_leader/100) * population) turtles 
[set leader? true 
set color black 
set size 0.6 
set leader self 
] 
end 

to go 
ask turtles [flock] 
end 

to flock 
find-flockmates 
let nearby-leaders turtles with [leader? ] 
ifelse any? nearby-leaders 
[ set heading [heading] of nearby-leaders] 

[ find-nearest-neighbor 
    ifelse distance nearest-neighbor < minimum-separation 
    [separate] 
    [ if any? flockmates 
     [align 
     cohere ]]] 
end 

to find-flockmates ;; turtle procedure 
set flockmates other turtles in-cone vision vision-angle 
end 

to find-nearest-neighbor ;; turtle procedure 
set nearest-neighbor min-one-of flockmates [distance myself] 
end 

그러나,이 오류 메시지가 팝업 비 번호 [147]로 거북이에게 변수 제목을 설정할 수 없습니다.이 코드는 [가까운 리더의 제목 [제목]을 설정합니다. 내가 여기서 뭘 잘못 했니? 누군가가 도울 수 있다면 정말 감사드립니다. 코드에서 가까운-지도자들이 거북이 세트이기 때문에

답변

3

, 당신은 one-of 사용해야합니다

set heading [heading] of one-of nearby-leaders