I am very new to netlogo. I have searched every question here before I posted this.
I have the following code which sprouts a given number of horses:
ask n-of Number-horses patches with [grass? = "Yes"] [sprout-horses 1 [set color 25 ]]
The person can change the number of horses using the slider but I would like each horse to have its own area/range/radius.
They can only move within this radius/area and they cannot meet each other.
From what I've read it's got something to do with the distance function?
There are several ways that you can assign a territory zone to each horse, but all methods that I know have two steps, first step is in order to make sure initial home area of horses are separated from each other , So we need to create horses only in patches which has a certain distance from another patch which has a horse on it,I did not follow your method that asked patches to sprout horses and instead I created them without asking patches.
I was not sure how you defined grass? Variable for each patch but I have assigned a number of patches with grass? = true and others false. Second step is to set home-area property of each horse. If initially you moved them far away from each other they will have separate territories.
I have included a few examples here : First to use in-radius for both steps:
In this example horses only move in the patches in their radius 2. But you can change that base on your model requirements.
In the second method you can use distance for the first step (finding empty patches with enough distance to current patch) and radius for second one (assigning home-area to each horse).
If you use higher distance for finding empty patches you will have completely seprated zones. Finally , you can use distance for both steps:
I just did it another way:
As you can see I used while and a condition to ask patches one by one, I might be mistaken but when I ask all the
n-of Number-of-horses patches with [YourCondition][...]
I get the wrong results and distance between horses is not effective, maybe they are created all at the same time and therefore upon creating a horse there was no horse nearby!? I am new to these concepts and might be wrong.This is the code and view for the one which asks patches to create horses at once here :
You can find a similar problem here which has examples too :
Spacing agents in NetLogo based on territory size