This code library has been built to help people explore how altruistic punishment, bribes, status anxiety, Â influence and privacy play in causing / preventing the tragedy of the commons.Â
Model designPseudocode
Variables
Interface: slides, view, graphs and monitors
Extensions, questions, notes and references
Diary notes10th OctoberFabio sent through the COMSES 2011 Challenge which seems to fit this work very well. Increasingly it seems people are seeing ABM as a valuable communication tool. A plan would be to get something out and trial it at the John Mason school.Â
Learning objectives:
6th OctoberAfter lots of messing around with the code described earlier in the week I made the change a patch attribute within concentric circles micro-behaviour (MB). There were lots of lessons learned in the making of this MB, how to implement input boxes, let/set statements and general code. I now want to take this forward to implement MBs that control how agents link to each other as they move around. Earlier I implemented linking with these ideas:
It would be best to break this into several MBs:
4th OctoberAnother example of setting patch attributes according to a distribution: globals [  x ;; circumference  c ;; patch color  ] to setup  ca  crt 1  set x 18  set c 20 end to go  ask turtle 0 [   repeat x [    ask patches in-radius x [ set pcolor c ]    set x ( x - 1 )    set c ( c + 1 )   ]  ] ask turtle 0 [ die ] ask patches [ set plabel pcolor ] end The code can be made more succinct and flexible: globals [  x ;; circumference  c ;; patch color  ] to setup  ca  set x n ;; n is a slider  set c 20  paint-patches-in-a-circle  ask patches [ set plabel pcolor ] end to paint-patches-in-a-circle  crt 1 [   ;; position the centre of the circle   set xcor up ;; 'up' is an input box   set ycor across ;; 'across' is an input box   ;; set color of patches starting at outer-most circumference and moving inwards   repeat x [    ask patches in-radius x [ set pcolor c ]    set x ( x - 1 )    set c ( c + 1 )    ]   ;; remove the coloring agent   die   ] end This then is the basis for a micro-behaviour where 1 or more circles that set an attribute (doesn't have to be pcolor) at increments from the circumference to the center. The main point being that you can create an agent at setup and make it move around and change patch attributes. To be usable as a micro-behaviour we'd want to call it and pass in the relevant parameters i.e. circumference, color, xcor and ycor. After discussion with Ken I am not sure about implementing my understanding of OO in the BC. The code above in can be implemented as in the create circle of colour in patches MB. 30th SeptemberFirst we need to create a micro-world where a resource is available for human consumption. The resource could be distributed evenly, randomly or according to some pattern. The resource could deplete at a fixed or variable rate, deplete as consumed, or it could grow evenly or at a rate that fluctuates over time. There could also be different types of resource where agents gain utility from consumption in different ways.
resource quantity at start (RQs) growth-rate (gr) depletion-rate (dr) Patch attributes can be set according to some pattern by:
Let's play with these approaches in NL: globals [ x c ] to setup  ca  crt 1  set x 0.1  set c 10 end to go  ask turtle 0 [   repeat 10 [    repeat 36 [    fd x    rt 10    ask patch-here [ set pcolor c ]   ]      set x ( x + 0.1 )      set c ( c + 1 )   ]  ] ask turtle 0 [ die ] end 29th SeptemberAfter a lengthy delay I am back to thinking about the ideal chunking of MBs so that they can be both easy to understand and expressive. This will require some field work with social scientists who are new to modelling - it will be an interesting juggling act. I have made two models while thinking about how people relate to energy (a resource) and each other (see top of the page). The question now is how to re-author these MBs so that they can be part of a more general energy and people library. A library is a super-set of a specific model so requires more careful consideration. Taking a specific example - how to model the growth of a resource. I have:Â
There are many ways to do this and the BC is slightly confusing with respect to how it has to be done for the following reasons:
This can all be done in one MB or broken up as is. Wrt modelling energy, the MBs could do things like:
It is important to:
So this really comes down to developing an easy language for people to use to build the kinds of models they are interested. How to get them thinking along the lines? Well the general class of model I am thinking about is one relating to how individuals interact within different types of energy/resource distributions. This is a tragedy of the commons problem that emphasizes modelling realistic interactions between people e.g. status anxiety, altruism etc.  Early in this diary I raised the idea of using a story to help people build ever more interesting models. It occurs to me now that this sounds like the numerous optimisation game theory simulations. I guess this is making that math more tractable and also allowing people to model changes in strategy e.g. agents showing for-thought for instance i.e. there being agents that can stabilise systems that are at tipping points. In other words, agents are not simple self-optimisation units, more sophisticated decision-makers that inter-relate according to different societal roles. 19th August
18th AugustI've noticed two trends lately:
I am doing things like working out why patch energy levels drop below 0, re-writing code to be more efficient and understandable, changing variable value ranges so that one change doesn't swamp another e.g. some agents can put others too much in debt. Somehow mathematically it doesn't feel right - its like I am making up numbers to steer the simulation in a direction...which I am not totally sure what it should be. I really need some kind of data set to tune things towards. As I've been saying the last few days I need to turn more attention back to the original questions that are meant to underpin this model. I also need to think about how this model (and ones perhaps more directly related to the environment) can be used by researchers to communicate with policy-makers and the general public. Regarding the later I am thinking of a guide divided up into several chapters: chapter 1
chapter 2
chapter 3
;;Â hatch 1 [ set shape "circle" set size 0.5 set color report culture-shade (my-culture / the-max-culture ) rt random 360 fd random-float 1 set my-culture n ]Â set my-culture my-culture - 1
Finally for today - a reminder how to use to-report: to setup ;; first schedule the procedure you want to run e.g.  aprocedure end ;; then define the procedure
to aprocedure
;; introduce a command that refers to a procedure e.g. "answer" and pass variable(s) to this procedure as a ;; list if required
  show answer [ 5 ] end ;; then define this "answer" reporter remembering to give the input variables a name here e.g. " v" to-report answer [ v ] ;; then use report primitive do to something with the variables   report first v * first v end
;; this program will show the number 25 17th AugustTo do: change my-greed/punish/bribe to variables in range 0-8 make my-defect a variable range so that it is part of the influence behaviour change the influence behaviour so that the difference of the abs (bribe - punish) is added/taken from my-defect and my-greed change the manage funds so that a fund is only topped up to a maximum value of 100 add the idea that an agent can spend assets to move its defect/greed values back towards the set point it initialised with add culture and privacy interactions between patches and agents add attribute cloaking to agents ( another instantiation of privacy ) break up the behaviours into smaller chunks that are aggregated together - make a range of behaviours that implement different rules (so they can be activated as desired) think whether I need to implement life-cycles to get the desired heterogeneity and multiple stable equilibria? actually - how will I know when the model is finished...i need to return to my original question. then i need to start simplifying and return back to the original question more generally: create a page on Sites that has sections for each of the main type of behaviour. describe the story of how each type can be used (he order). describe the conceptual range of each type e.g. the possibilities in terms of the end game. i think this goes back to privacy - I want to show that in an open world over-exploitation of resources wouldn't happen ( if people agreed what defecting is ) but when the information is not available defecting comes the norm. after re-reading the altruistic punishment paper, it is the addition of bribes to the interaction that is different. Fehr and Gachter only used punishment/no punishment. in this sense the end-game is to show this by plotting data created using the Behaviour Space. in terms of the paper, then I should focus on saying that education is the key to tackling climate change, that the learning must focus on complexity, and that contemporary discourse over-simplifies humans when it talks about the future, we are denigrated to simplistic agents who will repeat the mistakes of the past. we after all live in a deeply right-wing and conservative world (UK/ USA etc). with respect to education, I could mention serious games but most of all mention constructionism. learning with graphics might also be worth emphasizing. Thinking about the end game for the simulation - I want to generate data on: the types of agents that exist at different stages of a simulation run and how these population mixes correlate to the state of the environment e.g. energy and culture i could also experiment to see how robust different states are to shock e.g. sudden reduction in energy availability 16th AugustThe latest model seems stable but the agent interaction behaviours ( links, bribe, punish ) quickly result in a homogenous population with respect to 'my-greed'. I need to come up with a way of analysing the model so that it can be more realistic and preferably evolve to a range of interesting stable states. I suspect I can do this by eye (so to speak) and then will need to use the BehaviourSpace. 15th AugustFirst I am working on making the link behaviour more flexible/expressive. I think this means using NL primitives like max-n-of, with-max, max-one-of etc i.e. the agents are making a decision  about which other agent to link to based on an attribute such as my-assets, my-greed or even my-culture. Code examples: ;; giving agents vision and the ability to interrogate other agent's attributes gives a good start point for constructing meaningful ;; simulations of social networking e.g. replace 'in-radius n' with a vision attribute and 'color' with something like my-greed ;; NB. prefix these statement with an if any? agents...
;; turtle 0 creates a directed link to all the other turtles in the view ask turtle 0 [ create-links-to n-of ( count turtles - 1 ) other turtles ]
;; similar to above but only in-radius 3Â ask turtle 0 [ create-links-to n-of count turtles in-radius 3 other turtles ]
;; link to 1 agent that has the highest color value ask turtle 0 [ create-links-to max-n-of 1 other turtles [ color ]]
;; ...lowest color value ask turtle 0 [ create-links-to min-n-of 1 other turtles [ color ]]
;; ... in a defined radius ask turtle 0 [ create-links-to max-n-of 1 other turtles in-radius 20 [ color ]] turtles-own [  number   vision]to setup  ca  cro 20 [   set shape "circle"   fd random 15   set number random 100   set vision random 9 + 1    ] end to go  ask turtles [   if any? other turtles in-radius vision [    let n count turtles in-radius vision * 0.5    create-links-to max-n-of n other turtles in-radius vision [ number ]    ]   ] end The question now is how to store the linked agents so that they can be used within the interact behaviour: turtles-own [  number  other-number  linked-agent  vision  interaction-agents] to setup  ca  cro 8 [   set shape "circle"   fd random 15   set number random 100   set vision random random 9 + 1   ] end to go  ask turtles [   if any? other turtles in-radius vision [    let n count turtles in-radius vision - 1    create-links-to max-n-of n other turtles in-radius vision [ number ]    ]   ifelse count my-out-links > 0   [ set interaction-agents [ other-end ] of my-out-links ]   [ set interaction-agents nobody ]   if interaction-agents != nobody [    show interaction-agents    foreach interaction-agents [     ask ? [ set size 2 ] ]   ]  ]  ask links [ set color red set thickness 0.2]   end The program above is a good general template for simulating how agents might decide which other agents to link to at any one moment i.e. combining vision, knowledge about another agents attribute(s) (- here 'number), and then acting on the attributes of the linked agent (- here just changing the size). The process of codingÂ(This is a teaching note).  To build a model you need to move often between several tools and perform a range of tasks repeatedly i.e.
14th AugustVery small syntax changes can completely change a model e.g. a bracket in the wrong place. To an inexperienced programmer these changes seem small but with more practice when you spot them you think ' how could I be so stupid '. What develops is a way of reading code, and parsing it into your own mental logic. http://m.modelling4all.org/m/?frozen=Bc4hyesfZsKl2tn7xUyd55&MforAllModel=1 This code had me confused for a while: turtles-own [ interaction ] to setup  ca  cro 20 [ fd random 12 set shape "circle"]  ask links [ set thickness 2 set color red ]  ask turtles [   if any? other turtles in-radius 5 with [ count my-links = 0 ] [    set interaction one-of other turtles in-radius 5 with [ count my-links = 0 ]    create-link-with interaction ]]     end I can change the code to the below to use  directed instead of undirected links: turtles-own [ interaction ] to setup  ca  cro 20 [ fd random 12 set shape "circle"]  ask turtles [   if any? other turtles in-radius 5 with [ count my-in-links = 0 ] [    set interaction one-of other turtles in-radius 5 with [ count my-in-links = 0 ]    create-link-to interaction ]]  ask links [ set thickness .2 set color red ]     end but why do I end up with agents that have 2 links? (Something to do with ask and ask-concurrent?) Anyway, I think I should use directed links within the link micro-behaviour and write the code so that it can be easily extended to model many different forms of social interaction each step. 13th August Pedagogic note: if things aren't working as you'd expect e.g. no influence seems to be happening - check the scheduling!!! By downloading the model into NL and running some queries at the command line while the model is running e.g. show count objects with [kind = "agents" and my-defect = 1] I can quickly check various aspects of the model configuration. For instance this command shows me that by setting a random number of defectors at the start, each simulation run will vary greatly e.g. if there are none by chance. However the model currently set so that non-defecting agents quickly influence defectors to change their ways - the result of which is that defection quickly disappears (and the model is not interesting or realistic). Actually I just tested this some more and the number of defectors as the simulation runs is more to do with the fraction of them at the start compared to non-defectors. Again this is not interesting - I need to change things so that a more interesting parameter sweep occurs and the model evolves as I outlined yesterday. Second sitting (2pm ) I just changed the interface so that agents relative asset ownership is illustrated by size (color was difficult to distinguish). Now I have the interesting situation where some agents have massively negative assets - should I kill them or is this indicative of debt...should they go insolvent instead? To fix next time:Â
12th AugustThe big lesson of today is very small - be careful of square brackets! I spent too long working out how to change one agents attributes to be the same as an agent that it is linked: set my-defect [ my-defect ] of [ other-end ] of one-of my-links turtles-own [ number other-number] to setup  ca  cro 2 [   fd random 15   set number random 100   create-link-with one-of other turtles ] end to go  ask turtle 0 [ set other-number [ number ] of [ other-end ] of one-of my-links ]  ask turtle 1 [ set other-number [ number ] of [ other-end ] of one-of my-links ] end I also had the annoying issue that I had named a set of variables in two ways: punish-fund and punishment-fund. Since modelling4all auto-creates variables the compiler through no errors. So the next step is to work out exactly what I want to happen as agents influence each other. This approach is not very interesting since it will result in a homogeneous population eventually. I want the population to evolve into one that has an interesting optimization landscape e.g. with a number of stable states, or perhaps several states that exhibit chaotic behaviour e.g. bifurcations etc. To do next: change the influence MB so that the transaction winner subtly influences the loser attributes rather than simply over-writing them i.e. simulate a nudge rather than a complete domination.  This could be done by changing my-defect so that it is a scale and defection occurs when the value is over a tipping point i.e. 1 - 10 with defection at 5.  Or there could be an influence variable that is the factor and this could be calculated based on a population-wide norm i.e. ... Refer to Dan Ariely: http://danariely.com/the-books/excerpted-from-chapter-4-%E2%80%93-the-cost-of-social-norms/ The main thing is to think about the conference, what I need to do for it e.g. how does this model relate to the themes of the event? In particular I need to think about how extensible these behaviours are. 11th AugustFirst some reflections on coming back to the model. Being able to come back to a model and fix/enhance it after a period away (when you've forgotten most of the detail or thinking behind it) is a good test of how expressive and clearly it has been designed. Because of the limitations of programming through a browser modelling4all does not make it easy to follow the logical flow of the program because of all the nested micro-behaviours and the difficulty in remembering how all the variables (attributes and parameters) are being used. I remember that just before I went away I started to use a great deal of agent attributes to get bribes/punishment working and coming back now I can't quite remember why I decided to use some of them. This amounts to saying that the program outline description above is very useful and should be encouraged in the video guides. I am starting to see a programming skill might be to kind of relax using variables and trust that they work as you use them e.g. I created sustainable share of energy of patch variable which is calculated by looking at the parameter the-energy-quota to find how close to zero a patch energy should go, then look at how much patch energy there is, and divide this by the number of agents that are on the patch. I do not necessarily need to remember all this each time I use this variable, I just need to trust that it is what it infers i.e. how much energy an agent can take from a patch. If they take more they have defected. The two frozen models:
I had before the break are useful, the first works, the second makes a flawed attempt at modeling bribe/punishment behaviour. I think I will start again with how I want this to work and return to the pseudocode description above. A pedagogical note: when you get to the step of comparing and setting agent attributes then the 'log specific attributes' behaviour is very useful to make sure the model/MBs are behaving as you expect. This was particularly true of the way Cindy modeled in that we were not sure after several weeks what was going on 10th AugustAfter lengthy break... the latest model doesn't run because there is a problem with the MB 'change attributes after bribe/punishment'. Will be fixed tomorrow with fresh eyes. Today I fixed the division by zero error - this was caused by me naming an agent attribute incorrectly (my-punish-preference instead of my-punishment-preference) which mean the wrongly named attribute was created on the fly (a feature of modelling4all) and set to zero. 12th July 2011Using NL to get the hang of linking wrt this model: links-own [ age-of-link ] to setup  ca  cro 10 [ fd random 10 set color random 255 ]   end to go  ask turtles [ ifelse color > number [ set size 3] [ set size 1 ] ]  move  find-turtle-and-link  links-age  ask links [ if age-of-link >= 10 [ die ] ]  tick end to move  ask turtles [ rt random ( 30 + random -60 ) fd 0.1 ] end   to find-turtle-and-link  ask turtles [   let n other turtles in-radius 3 with [ color > number and not any? my-links ]   if any? n [    create-link-with one-of n [     set age-of-link 0     set thickness 0.2     set color red ]]] end to links-age  ask links [ set age-of-link age-of-link + 1 ] end bribes and punishment:
11th July 2011The task today has been to get agents linking and setting link attributes to break the links. An example model shows this working but we've decided to raise an enhancement request because of the non-intuitive way that the BC currently schedules the naming of prototypes. Ken's religiosity model also shows some more advanced used of links working in the BC. There are 3 things to remember about the example model with regards to linking:
The example code works in the main model (which it just occurs to me needs a name). 8th July 2011A short NL program that shows how links attributes can be created and used, but I am not sure how to do this in modelling4all yet. we might need to write some more extension code to allow attributes to be created and set on the fly as for attribute-of-patch and my-attribute .links-own [ age-of-link ] to setup  ca  cro 10 [ fd random 10 ] end to go  move  find-turtle-and-link  links-age  ask links [ if age-of-link <= 0 [ die ]]  tick end to move  ask turtles [ rt random 45 fd 0.1 ] end   to find-turtle-and-link  ask n-of 1 turtles [   create-link-to one-of other turtles [ set age-of-link 5 ]  ] end to links-age  ask links [ set age-of-link age-of-link - 1 ] end 7th July 2011There is a pedagogical issue here that the model description above has become so complex it is difficult to hold in memory. This makes it difficult to imagine whether it is interesting, coherent, consistent etc. One approach to dividing the implementation up into smaller chunks is to create a story script (see pedagogical section above) and use it to build the micro-behaviours. Each story chunk should contain the following elements:
During the build lots of new ideas will pop out - these should be recorded and parked if they are overly complicated. 10:45: started to add reproduction - how can I hatch an agent and reset some of the attributes once i.e. my-assets Current model has reproduction (based on an assets threshold which is a little artificial). The coloring of agents is now achieved by using a list [( 255 * fraction) 0 0] which means agents are always a shed of pure red (no green/blue). Next steps: add a histogram to watch main parameters 5th July 2011focus on decision-making of agents e.g. how agents decide whether to punish/bribe AND how the agents will respond to environmental stimuli 4th July 2011plan for today:
24th June 2011another way to model privacy would be to implement attribute cloaking (rather than allowing agents to set patch-entry-cost). to model agent decisions based on attributes?Â
23rd June 2011So the focus needs to be in creating a pattern for coding behaviours that model agent decision-making. As is the case in the  current model - the difficulty here is deciding on sensible numbers i.e. how much my-assets would be needed to create culture, how much should culture effect agents. One approach to this  'arbitrary numbers' problem is to let the numbers evolve in the system. This can be done by (a) letting agents breed, and the offspring have attributes that are the sum of the two parents (b) let agents effect each other's attributes during transactions. At this stage I am veering towards option B i.e. change attributes like my-love-of-culture in favour of the agent that wins a transaction e.g. if an agent successfully bribes another, then this other's attributes will be changed to resemble those of the briber. So what might be a general schema for coding behaviours?: if condition e.g. have enough assets to do something like bribe and another if condition do something e.g. bribe/punish/set entry-cost normalise attributes between two agents in favour of the 'winner' e.g. the briber, the punisher by normalise i don't mean make the loser's attributes the same as the winner. this might quickly emerge into a homogeneous model. i want the agents to explore the bribe/control/punishment space comprehensively. 22nd June 2011The model so far has made me re-focus what I want to do so I have re-written the overall model description above. The general idea is to model assets (money) as an expression of power that agents can use to (a) control access to a resources (b) avoid altruistic punishment by bribing the agent dishing out the punishment (c) spend on building culture. The model I've been building to-date was not focused enough on an interesting question. This one gets back (I think) to understanding how an agent's attitude to openness can skew an economy. 21st June 2011The model I ended up with yesterday had quite a few problems because of the way parameters are scheduled. Basically the parameters were set to zero because their value was dependent on agents existing, and none were when the parameter is created. Also patch behaviours cannot be scheduled in the same way agent attributes can. These issues are fixed in this model. Now I need to get the numbers right, and think some more about how I want the model to grow from here. 18th June 2011Plan:
to setup  ca  cro 10  ask turtles [ fd random 10 set color random 255] end to go  let x first [color] of turtles with-max [color]  show x  ask turtles [   set color 61 +  ( ( ( color / x ) * 80 ) / 10 )  ] end
17th June 2011Agent prototype attributes:
micro-behaviours:
Patch prototype attributes:
micro-behaviours:
Measurements
16th June 2011
turtles-own [control cash] patches-own [energy-on-patch price ] to setup  ca  crt number  ask turtles [ set control random 9 set color control set cash 100]  ask patches [ set energy-on-patch random 8 set pcolor 60 + energy-on-patch ] end to go  grow-energy  move  consume  price-land  ask turtles [   set cash cash - cost-of-living   if [price] of patch-here > 0 [    ask patch-here [ set pcolor price ]]   ]  ask patches [   if price > 0 [ set price price - decay ]   if count turtles-here > 0 and price <= 0 [ set pcolor energy-on-patch]   ]  tick end to grow-energy  ;; patches continuously grow energy to a threshold   ask patches [   if energy-on-patch <= 8 [    set energy-on-patch energy-on-patch + 0.1    set pcolor 60 + energy-on-patch]  ] end to move  ;; agents find cheapest neighboring patch and move to it if they have enough cash  ;; extensions:  ;; find the patch with the best energy to price ration   ask turtles [    let x first sort [price] of neighbors    face one-of neighbors with [ price = x ]    if x <= cash [ fd 1 ]  ] end to consume  ;; agents take energy according to their control, only limited by the energy available on the patch  ask turtles [   let energy [energy-on-patch] of patch-here   let c control   ifelse energy >= control     [    set cash cash + energy    ask patch-here [ set energy-on-patch energy-on-patch - c ]    ]  ;; the finite earth view of the world i.e. can't take more energy than there is on a patch    [     set cash cash + energy     ask patch-here [ set energy-on-patch energy-on-patch - energy ]     ]   ] end to price-land  ;; turtles can put a price on land  ;; extensions:  ;; set price a multiplier of control  ask turtles [   let p [price] of patch-here   let c control   if cash >= p [    set cash cash - p    ask neighbors [     set price price + c ]     ]  ] end
or something like this. Point being this could serve as a process for stepping through when designing models, and improving them to be ever more complex yet simple. It has also occurred to me that openness/control is only one aspect that needs modelling with reference to the open to change project. The other is responsiveness of agents to environmental parameters...which is another type of openness. 15th June 2011
turtles-own [greed wealth] patches-own [energy-of-patch price ] to setup  ca  crt number  ask turtles [ set color red fd random 15 set greed random 9 set wealth 0]  ask patches [   set energy-of-patch random 9   set pcolor 60 + energy-of-patch ] end to go  move  eat  grow-energy  own-land  tick end to move  ;; turtles find cheapest patch   ask turtles [   let x sort [price] of neighbors   let y first x   face one-of neighbors with [price = y]   fd 1  ] end to eat  ;; main thing here is not to take more energy than there exists on a patch (hence the ifelse)  ask turtles [   let energy [energy-of-patch] of patch-here   let g greed   ifelse energy >= greed [    set wealth wealth + energy    ask patch-here [ set energy-of-patch energy-of-patch - g ]]    [set wealth wealth + energy     ask patch-here [ set energy-of-patch energy-of-patch - energy ]]   ] end to grow-energy  ;; patches keep growing energy to a threshold   ask patches [   if energy-of-patch <= 9 [    set energy-of-patch energy-of-patch + 0.1    set pcolor 60 + energy-of-patch]  ] end to own-land  ;; when rich enough turtles can put a price on land  ask turtles [   if wealth >= 200 [    ask neighbors [ set price price + 200 ]    set wealth wealth - 200 ]   ] end
10th June 2011With the basic model now working I can start listing basic agent (and patch) behaviours and attributes: agent:
9th June 2011The issues were caused with a bug in the new 'remove enhancement' micro-behaviour functionality. After re-making the behaviours I now have a model that works as expected. I also received a reply from the netlogo yahoo group from JL that gives me a cunning solution to report all the patches under a symmetrical shape like a circle. I still find it surprising that a more general reporter is not available since this is something that the eye can see easily but NL cannot report easily, especially if the agent was an irregular shape like a star: It is not difficult to get the agentset of all patches whose center is inside a circle. You would use the `in-radius` primitive. In the context of a turtle whose circular shape goes all the way to the edge of the shape editor grid, you might use a reporter like this: to-report patches-within  ; by turtle, agentset of patches covered by me   report patches in-radius size / 2 end crt 1 [ set size 4 set shape "circle" set color lput 150 extract-rgb color fd 10] ask turtle [show count patches in-radius size / 2]
...easily solved by (size / 2) but I could not get this code working in a NL model i.e. using to-report/report. I think I will take the other approach of simply enabling agents to take ownership of patches and so exert some control over access to these patches. 8th June 2011
7th June 2011
6th June 2011
|
Projects‎ > ‎