breed [sharks shark]
breed [school fish]
sharks-own [closest-shark eat-fish]school-own [closest-fish danger-shark]to setup
;; __clear-all-and-reset-ticks should be replaced with clear-all at
;; the beginning of your setup procedure and reset-ticks at the end
;; of the procedure.)
__clear-all-and-reset-ticks
create-sharks 10
setxy random-xcor random-ycor
set shape "circle"
set color cyan
set size .3
]
setxy random-xcor random-ycor
set shape "circle"
set color white
set size 1
]
; pd
; you can wrtite your own comments
let headtails random 10
fd .002
ifelse (headtails < 5)
[set heading heading + 5]
[set heading heading - 5]
]
; pd
let headtails random 10
fd .002
ifelse (headtails < 5)
[set heading heading + 5]
[set heading heading - 5]
end
ask school [
set closest-fish min-one-of other school [distance myself]
face closest-fish
bk .1
]
to chase
set eat-fish min-one-of other school [distance myself]
;if eat-fish != nobody [
face eat-fish
fd .1
]
;]
set danger-shark min-one-of other sharks[distance myself]
if distance danger-shark < 10
[face danger-shark bk .1]
sharks-own [closest-shark eat-fish]school-own [closest-fish danger-shark]to setup
;; __clear-all-and-reset-ticks should be replaced with clear-all at
;; the beginning of your setup procedure and reset-ticks at the end
;; of the procedure.)
__clear-all-and-reset-ticks
create-sharks 10
setxy random-xcor random-ycor
set shape "circle"
set color cyan
set size .3
]
setxy random-xcor random-ycor
set shape "circle"
set color white
set size 1
]
; pd
; you can wrtite your own comments
let headtails random 10
fd .002
ifelse (headtails < 5)
[set heading heading + 5]
[set heading heading - 5]
]
; pd
let headtails random 10
fd .002
ifelse (headtails < 5)
[set heading heading + 5]
[set heading heading - 5]
end
ask school [
set closest-fish min-one-of other school [distance myself]
face closest-fish
bk .1
]
to chase
set eat-fish min-one-of other school [distance myself]
;if eat-fish != nobody [
face eat-fish
fd .1
]
;]
set danger-shark min-one-of other sharks[distance myself]
if distance danger-shark < 10
[face danger-shark bk .1]
;; (for this model to work with NetLogo's new plotting features,
create-school 500
ask school [
ask sharks [
end
to wiggle
ask school [
ask sharks[
]
to repel
end
ask sharks[
end
to flee
ask school [
]
end