NetLogo.Trying to make turtle on a specific patch color die -
NetLogo.Trying to make turtle on a specific patch color die -
so i've made breeds player , zombie:
breed [zombies zombie] breed [players player]
i kill zombie if walks unto black patch (pit).
to go inquire zombies [ ;set heading (heading + 45 - (random 90)) allow closest-player min-one-of players[distance myself] set heading towards closest-player forwards 1 ;if xcor = pcolor black [death] have lot larn netlogo syntax ;if ycor = pcolor black [death] these lines give thought of i'm trying do. ] end death ;; turtle procedure set shape "skull" set color white set heading 0 end
as described in variables section of programming guide:
a turtle can read , set patch variables of patch standing on.
in case, means zombies can straight check pcolor
of patch they're on:
if pcolor = black [ death ]
this equivalent of more verbose form using patch-here
:
if [ pcolor ] of patch-here = black [ death ]
you don't need utilize coordinates identify patch. netlogo has plenty of reporters can help getting patch want. example: patch-ahead
, patch-at, patch-at-heading-and-distance
, patch-here
, patch-left-and-ahead
, patch-right-and-ahead
.
but in cases need find patch using coordinates, there patch
:
if [ pcolor ] of patch xcor ycor = black [ death ]
but of unnecessary in case. stick simple if pcolor = black [ death ]
.
netlogo
Comments
Post a Comment