Beetle Navigation
Model was written in NetLogo 6.0.3
•
Viewed 409 times
•
Downloaded 61 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Click to Run Model
breed [ boxes box ] breed [ beetles beetle ] beetles-own [ beetle-home distance-home moving-timer time-reorienting x-position y-position ] to setup clear-all ask patches [ set pcolor green + (random-float 0.8) - 0.4 ] setup-beetle setup-obstacles reset-ticks end to setup-beetle create-beetles 1 [ set shape "bug" set color black set size 3.5 ] ask beetles [ setxy -24 0 facexy 25 0 set moving-timer number-steps set time-reorienting reorient-timer set beetle-home patch-here ifelse show-pen? [ pen-down ] [ pen-up ] ] end to setup-obstacles ask n-of number-obstacles patches with [ distancexy -25 0 > 4 and abs pxcor < (max-pxcor - 5) and abs pycor < (max-pycor - 5) ] [ sprout-boxes 1 [ set shape "circle" set size size-obstacles set color 1.5 ] ] end to go if all? beetles [ xcor >= 24 ] [ stop ] ask beetles [ ifelse moving-timer >= 1 [ move-beetles ] [ reorient ] ] tick end to move-beetles ask beetles [ set heading random-float step-angle + 90 fd 1 set distance-home distance beetle-home set moving-timer moving-timer - 1 if count boxes in-cone (size-obstacles) 180 > 0 [ go-another-direction ] if abs pxcor >= 25 or abs pycor >= 24 [ set heading random 360 bk 1 ] ] end to go-another-direction ask beetles [ let target one-of boxes in-radius size-obstacles set x-position [ xcor ] of target set y-position [ ycor ] of target ifelse step-angle < 90 [ ifelse y-position > ycor [ lt random 45 bk 1 lt random 90 bk 1 ] [ rt random 45 bk 1 rt random 90 bk 1 ] ] [ if x-position < xcor and y-position < ycor [ case-one ] if x-position > xcor and y-position > ycor [ case-one ] if x-position > xcor and y-position < ycor [ case-two ] if x-position < xcor and y-position > ycor [ case-two ] ] ] end to case-one ask beetles [ bk 1 rt random 15 bk 1 ] end to case-two ask beetles [ bk 1 lt random 15 bk 1 ] end to reorient ask beetles [ set shape "rotating bug" set color 3 set heading heading + ( 1 / reorient-timer ) * 360 set time-reorienting time-reorienting - 1 if time-reorienting < 1 [ set heading 90 set shape "bug" set color black set moving-timer number-steps set time-reorienting reorient-timer ] ] end
There are 9 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Beetle Navigation.png | preview | Preview for 'Beetle Navigation' | over 6 years ago, by Jake Hofgard | Download |
This model does not have any ancestors.
This model does not have any descendants.