2017-07-20 82 views

回答

3

有一個在你的問題有很多不確定性,但你應該能夠更改以下,以滿足您的需求。

turtles-own [ID] ;if unique, you can just use `who` 

to setup ;make some turtles with various xcors and IDs 
    ca 
    crt 100 [ 
    setxy random-xcor random-ycor 
    set ID random 1000 
    ] 
end 

to-report top ;get a turtle with biggest id 
    report max-one-of turtles [ID] 
end 

to-report winners ;get turtles to right of top 
    let topx [xcor] of top 
    report turtles with [xcor > topx] 
end 

to test 
    setup 
    print count winners 
end 
+0

@goodgest這聽起來像你需要問一個單獨的問題。但在你這樣做之前,請思考這個經驗法則:記者是你的朋友。 (也就是說,不要認爲你不能輕易使用這些記者或其變體,沒有什麼能阻止你的表單在你的「結束」程序中叫記者。) – Alan