1

I want to draw a large circle and outside to it 50 small ones

breed [largecircle lc]
breed [smallcircke sc]

ask patches with [(pxcor > min-pxcor) and
    (pxcor < (max-pxcor))]
    [ set pcolor blue]

;cteate turtle / draw circle/ and make the circle to be in a drawing area (patches)
create-largecircle 1 [
    set shape "circle"
    set color green
    setxy 0 0
    set size  10
    stamp
    die
  ]
create-smallcircle 50 [
    set shape "circle"
    setxy random-xcor random-ycor;randomize
    move-to one-of patches with [pcolor = blue ]
  ]

it doesn`t work.Circles are still generated inside large circle area Any thoughts how can I approach the requirement?

YAKOVM
  • 9,805
  • 31
  • 116
  • 217

1 Answers1

1

Your approach doesn't work, because you are not modifying any pcolors of patches in the landscape. The stamp command only leaves an image of the largecircle turtle, but the pcolors underneath still remain blue. Thus, your smallcircles are still allowed to move anywhere even within the stamp area of your largecircle.

To solve this, you need a different approach. Turtle shapes in NetLogo are useful for generating visual output of your model. But it is not possible to identify patches which are covered by a certain turtle shape. Even though a turtles visual shape can cover several patches, its location is still limited to one specific patch. It's hard to recommend an approach without knowing, what you are exactly planning to do with your model. However, here is a solution that comes close to your provided code example:

breed [smallcircle sc]
globals [largecircle]

to setup
ca
ask patches with [(pxcor > min-pxcor) and (pxcor < (max-pxcor))][
   set pcolor blue
]

;store patches within radius of center patch as global
ask patch 0 0 [
  set largecircle patches in-radius (10 / 2)
]
;set color of largecircle patches green
ask largecircle [
  set pcolor green
]
;create small circles and move to random location outside largecircle
create-smallcircle 50 [
    set shape "circle"
    move-to one-of patches with [not member? self largecircle]
]
end

I removed the largecircle breed and instead created a global variable largecircle. The largecircle is then created by asking the center patch, identifying all patches within a certain radius and store these patches in the global variable largecircle. We can now use this patch-set to set the pcolor of largecircle-patches or to control the movement of the small circles.

nldoc
  • 1,179
  • 5
  • 6