[{"data":1,"prerenderedAt":13265},["ShallowReactive",2],{"/programming":3,"/programming-surround":13254},{"id":4,"title":5,"body":6,"description":13222,"extension":13223,"meta":13224,"navigation":13242,"path":13251,"seo":13252,"stem":3395,"__hash__":13253},"content/programming.md","Programming Guide",{"type":7,"value":8,"toc":13122},"minimark",[9,21,25,28,261,269,277,284,302,309,312,315,354,430,450,453,460,463,471,498,519,549,552,842,853,856,901,904,918,924,936,959,981,1008,1043,1067,1152,1155,1158,1167,1182,1197,1374,1393,1401,1410,1413,1422,1429,1446,1458,1484,1495,1514,1517,1526,1583,1596,1608,1630,1633,1655,1668,1700,1703,1826,1833,1842,1845,1865,1892,1895,1907,2012,2062,2069,2082,2094,2141,2150,2157,2164,2169,2172,2175,2182,2201,2248,2259,2270,2294,2327,2338,2341,2360,2363,2373,2398,2408,2446,2451,2466,2548,2554,2557,2560,2581,2628,2631,2657,2667,2728,2731,2736,2758,2796,2814,2825,2833,2840,2843,2937,2940,2957,2996,3003,3010,3013,3016,3019,3046,3058,3076,3094,3114,3134,3139,3151,3177,3182,3185,3188,3231,3234,3251,3258,3261,3280,3290,3301,3323,3330,3342,3349,3356,3381,3393,3400,3407,3417,3420,3432,3462,3469,3472,3583,3586,3589,3677,3684,3692,3702,3739,3742,3747,3750,3819,3822,3843,3848,3874,3930,3936,3950,3972,3989,4003,4013,4132,4135,4183,4460,4463,4536,4542,4545,4575,4578,4581,4614,4617,4623,4632,4649,4667,4676,4679,4776,4785,4801,4831,4841,4850,4872,4892,4909,4928,4938,5043,5075,5085,5094,5101,5110,5113,5133,5142,5145,5154,5219,5228,5238,5246,5249,5258,5261,5270,5273,5282,5330,5353,5362,5373,5376,5423,5426,5429,5567,5661,5670,5673,5683,5823,5826,5861,5870,5956,5959,5966,5975,5978,5989,5997,6049,6056,6059,6062,6065,6068,6071,6074,6084,6087,6092,6095,6098,6101,6104,6107,6110,6115,6150,6153,6160,6163,6170,6173,6176,6179,6182,6191,6203,6239,6303,6308,6313,6350,6359,6389,6398,6406,6415,6431,6539,6542,6659,6668,6671,6680,6688,6697,6700,6709,6712,6875,6883,6886,7059,7069,7078,7085,7091,7098,7101,7104,7128,7138,7151,7160,7169,7178,7245,7254,7257,7269,7272,7279,7282,7285,7288,7291,7294,7297,7300,7303,7312,7315,7318,7321,7342,7351,7358,7368,7378,7381,7405,7414,7417,7432,7435,7438,7441,7444,7453,7456,7459,7462,7469,7472,7479,7482,7485,7488,7491,7494,7497,7504,7507,7518,7527,7534,7537,7551,7558,7569,7593,7646,7723,7726,7729,7748,7760,7846,7849,7861,7868,7946,7953,7960,7966,7981,8015,8018,8056,8090,8125,8166,8175,8178,8205,8219,8222,8327,8336,8367,8387,8390,8399,8405,8412,8418,8421,8433,8439,8473,8480,8525,8532,8558,8632,8643,8659,8739,8746,8751,8775,8782,8785,8788,8794,8799,8839,8845,8850,8867,8870,8896,8902,8912,8949,8956,8967,8983,9014,9017,9042,9047,9057,9123,9133,9154,9180,9196,9217,9220,9243,9270,9318,9323,9342,9351,9487,9493,9503,9592,9615,9647,9659,9668,9757,9786,9803,9818,9822,9825,9903,9949,9954,9957,9974,9990,10007,10016,10039,10069,10085,10088,10129,10139,10162,10176,10181,10197,10234,10237,10254,10259,10279,10285,10288,10298,10305,10308,10311,10317,10320,10625,10650,10721,10724,10727,10753,10760,10767,10770,10773,10776,10802,10815,10818,10861,10864,11068,11071,11076,11079,11117,11120,11152,11155,11262,11265,11290,11293,11313,11318,11321,11374,11377,11380,11428,11440,11447,11450,11453,11465,11509,11512,11515,11534,11541,11544,11578,11626,11635,11638,11641,11650,11662,11671,11674,11705,11781,11787,11794,11797,11805,11814,11823,11828,11833,11846,11856,11870,11879,11887,11900,11913,11916,11949,11957,12012,12029,12051,12056,12065,12068,12084,12087,12094,12103,12106,12109,12126,12129,12132,12138,12149,12154,12163,12183,12189,12201,12210,12213,12222,12225,12228,12231,12240,12243,12252,12262,12269,12279,12288,12296,12302,12313,12319,12325,12336,12351,12358,12438,12441,12450,12453,12456,12461,12467,12479,12482,12502,12509,12534,12537,12542,12545,12554,12565,12590,12597,12604,12609,12626,12646,12653,12676,12679,12717,12737,12740,12782,12785,12788,12791,12823,12826,12833,12838,12841,12844,12873,12876,12882,12889,12894,12901,12908,12911,12921,12937,12977,12980,12994,13067,13070,13080,13089,13096,13110,13119],[10,11,15],"h1",{"id":12,"className":13},"programming-guide",[14],"section-heading",[16,17,5],"a",{"className":18,"href":20},[19],"section-anchor","#programming-guide",[22,23,24],"p",{},"This section describes the NetLogo programming language in detail.",[22,26,27],{},"The Code Example models mentioned throughout can be found in the Code Examples\nsection of the Models Library.",[29,30,33,43],"div",{"className":31},[32],"toc",[34,35,38],"h4",{"id":36,"className":37},"table-of-contents",[14],[16,39,42],{"className":40,"href":41},[19],"#table-of-contents","Table of Contents",[44,45,46,109,159,185,191,211,217,223,243,249,255],"ul",{},[47,48,49,53],"li",{},[16,50,52],{"href":51},"#agents-and-agentsets","Agents and Agentsets",[44,54,55,61,67,73,79,85,91,97,103],{},[47,56,57],{},[16,58,60],{"href":59},"#agents","Agents",[47,62,63],{},[16,64,66],{"href":65},"#agentsets","Agentsets",[47,68,69],{},[16,70,72],{"href":71},"#breeds","Breeds",[47,74,75],{},[16,76,78],{"href":77},"#variables","Variables",[47,80,81],{},[16,82,84],{"href":83},"#links","Links",[47,86,87],{},[16,88,90],{"href":89},"#tie","Tie",[47,92,93],{},[16,94,96],{"href":95},"#drawing","Drawing",[47,98,99],{},[16,100,102],{"href":101},"#turtle-shapes","Turtle shapes",[47,104,105],{},[16,106,108],{"href":107},"#link-shapes","Link shapes",[47,110,111,115],{},[16,112,114],{"href":113},"#programming","Programming",[44,116,117,123,129,135,141,147,153],{},[47,118,119],{},[16,120,122],{"href":121},"#procedures","Procedures",[47,124,125],{},[16,126,128],{"href":127},"#ask","ask",[47,130,131],{},[16,132,134],{"href":133},"#ask-concurrent","ask-concurrent",[47,136,137],{},[16,138,140],{"href":139},"#syntax","Syntax",[47,142,143],{},[16,144,146],{"href":145},"#multiple-source-files","Multiple source files",[47,148,149],{},[16,150,152],{"href":151},"#buttons","Buttons",[47,154,155],{},[16,156,158],{"href":157},"#anonymous-procedures","Anonymous procedures",[47,160,161,165],{},[16,162,164],{"href":163},"#world","World",[44,166,167,173,179],{},[47,168,169],{},[16,170,172],{"href":171},"#tick-counter","Tick counter",[47,174,175],{},[16,176,178],{"href":177},"#view-updates","View updates",[47,180,181],{},[16,182,184],{"href":183},"#topology","Topology",[47,186,187],{},[16,188,190],{"href":189},"#observer-perspective","Observer Perspective",[47,192,193,197],{},[16,194,196],{"href":195},"#inputoutput","Input/Output",[44,198,199,205],{},[47,200,201],{},[16,202,204],{"href":203},"#output","Output",[47,206,207],{},[16,208,210],{"href":209},"#file-io","File I/O",[47,212,213],{},[16,214,216],{"href":215},"#lists","Lists",[47,218,219],{},[16,220,222],{"href":221},"#strings","Strings",[47,224,225,229],{},[16,226,228],{"href":227},"#mathematics","Mathematics",[44,230,231,237],{},[47,232,233],{},[16,234,236],{"href":235},"#math","Math",[47,238,239],{},[16,240,242],{"href":241},"#random-numbers","Random numbers",[47,244,245],{},[16,246,248],{"href":247},"#plotting","Plotting",[47,250,251],{},[16,252,254],{"href":253},"#color","Color",[47,256,257],{},[16,258,260],{"href":259},"#movies","Movies",[262,263,266],"h2",{"id":264,"className":265},"agents-and-agentsets",[14],[16,267,52],{"className":268,"href":51},[19],[270,271,274],"h3",{"id":272,"className":273},"agents",[14],[16,275,60],{"className":276,"href":59},[19],[22,278,279,280,283],{},"The NetLogo world is made up of ",[281,282,272],"strong",{},". Agents are beings that can follow\ninstructions.",[22,285,286,287,290,291,290,294,297,298,301],{},"In NetLogo, there are four types of agents: ",[281,288,289],{},"turtles",", ",[281,292,293],{},"patches",[281,295,296],{},"links",",\nand the ",[281,299,300],{},"observer",".",[22,303,304,305,308],{},"Turtles are agents that move around in the ",[281,306,307],{},"world",". The world is two\ndimensional and is divided up into a grid of patches. Each patch is a square\npiece of “ground” over which turtles can move. Links are agents that connect two\nturtles. The observer doesn’t have a location — you can imagine it as looking\nout over the world of turtles and patches.",[22,310,311],{},"The observer doesn’t observe passively — it gives instructions to the other\nagents.",[22,313,314],{},"When NetLogo starts up, there are no turtles. The observer can make new turtles.\nPatches can make new turtles too. (Patches can’t move, but otherwise they’re\njust as “alive” as turtles.)",[22,316,317,318,331,332,339,340,346,347,353],{},"Patches have coordinates. The patch at coordinates (0, 0) is called the origin\nand the coordinates of the other patches are the horizontal and vertical\ndistances from this one. We call the patch’s coordinates ",[319,320,323],"primitive",{"displayText":321,"permalink":322},"pxcor","pcor",[16,324,321],{"href":325,"rel":326,"className":328,"dataDisplayText":321,"target":330,"title":321},"/dictionary#pcor",[327],"noopener",[329],"netlogo-wiki-link","_self"," and\n",[319,333,335],{"displayText":334,"permalink":322},"pycor",[16,336,334],{"href":325,"rel":337,"className":338,"dataDisplayText":334,"target":330,"title":334},[327],[329],". Just like in the standard mathematical coordinate plane,\n",[319,341,342],{"displayText":321,"permalink":322},[16,343,321],{"href":325,"rel":344,"className":345,"dataDisplayText":321,"target":330,"title":321},[327],[329]," increases as you move to the right and ",[319,348,349],{"displayText":334,"permalink":322},[16,350,334],{"href":325,"rel":351,"className":352,"dataDisplayText":334,"target":330,"title":334},[327],[329]," increases\nas you move up.",[22,355,356,357,290,366,290,375,331,382,389,390,396,397,290,403,409,410,416,417,331,423,429],{},"The total number of patches is determined by the settings\n",[319,358,361],{"displayText":359,"permalink":360},"min-pxcor","min-pcor",[16,362,359],{"href":363,"rel":364,"className":365,"dataDisplayText":359,"target":330,"title":359},"/dictionary#min-pcor",[327],[329],[319,367,370],{"displayText":368,"permalink":369},"max-pxcor","max-pcor",[16,371,368],{"href":372,"rel":373,"className":374,"dataDisplayText":368,"target":330,"title":368},"/dictionary#max-pcor",[327],[329],[319,376,378],{"displayText":377,"permalink":360},"min-pycor",[16,379,377],{"href":363,"rel":380,"className":381,"dataDisplayText":377,"target":330,"title":377},[327],[329],[319,383,385],{"displayText":384,"permalink":369},"max-pycor",[16,386,384],{"href":372,"rel":387,"className":388,"dataDisplayText":384,"target":330,"title":384},[327],[329],". When NetLogo starts up, ",[319,391,392],{"displayText":359,"permalink":360},[16,393,359],{"href":363,"rel":394,"className":395,"dataDisplayText":359,"target":330,"title":359},[327],[329],",\n",[319,398,399],{"displayText":368,"permalink":369},[16,400,368],{"href":372,"rel":401,"className":402,"dataDisplayText":368,"target":330,"title":368},[327],[329],[319,404,405],{"displayText":377,"permalink":360},[16,406,377],{"href":363,"rel":407,"className":408,"dataDisplayText":377,"target":330,"title":377},[327],[329]," and ",[319,411,412],{"displayText":384,"permalink":369},[16,413,384],{"href":372,"rel":414,"className":415,"dataDisplayText":384,"target":330,"title":384},[327],[329]," are\n-16, 16, -16, and 16 respectively. This means that ",[319,418,419],{"displayText":321,"permalink":322},[16,420,321],{"href":325,"rel":421,"className":422,"dataDisplayText":321,"target":330,"title":321},[327],[329],[319,424,425],{"displayText":334,"permalink":322},[16,426,334],{"href":325,"rel":427,"className":428,"dataDisplayText":334,"target":330,"title":334},[327],[329]," both range from -16 to 16, so there are 33 times 33, or 1089\npatches total. (You can change the number of patches with the Settings button.)",[22,431,432,433,409,441,449],{},"Turtles have coordinates too: ",[319,434,436],{"displayText":435,"permalink":435},"xcor",[16,437,435],{"href":438,"rel":439,"className":440,"dataDisplayText":435,"target":330,"title":435},"/dictionary#xcor",[327],[329],[319,442,444],{"displayText":443,"permalink":443},"ycor",[16,445,443],{"href":446,"rel":447,"className":448,"dataDisplayText":443,"target":330,"title":443},"/dictionary#ycor",[327],[329],". A patch’s coordinates are\nalways integers, but a turtle’s coordinates can have decimals. This means that a\nturtle can be positioned at any point within its patch; it doesn’t have to be in\nthe center of the patch.",[22,451,452],{},"Links do not have coordinates. Every link has two ends, and each end is a\nturtle. If either turtle dies, the link dies too. A link is represented visually\nas a line connecting the two turtles.",[270,454,457],{"id":455,"className":456},"agentsets",[14],[16,458,66],{"className":459,"href":65},[19],[22,461,462],{},"An agentset is exactly what its name implies, a set of agents. An agentset can\ncontain either turtles, patches or links, but not more than one type at once.",[22,464,465,466,470],{},"An agentset is not in any particular order. In fact, it’s always in a random\norder. And every time you use it, the agentset is in a ",[467,468,469],"em",{},"different"," random order.\nThis helps you keep your model from treating any particular turtles, patches or\nlinks differently from any others (unless you want them to be). Since the order\nis random every time, no one agent always gets to go first.",[22,472,473,474,481,482,489,490,497],{},"You’ve seen the ",[319,475,476],{"displayText":289,"permalink":289},[16,477,289],{"href":478,"rel":479,"className":480,"dataDisplayText":289,"target":330,"title":289},"/dictionary#turtles",[327],[329]," primitive, which reports the agentset of all\nturtles, the ",[319,483,484],{"displayText":293,"permalink":293},[16,485,293],{"href":486,"rel":487,"className":488,"dataDisplayText":293,"target":330,"title":293},"/dictionary#patches",[327],[329]," primitive, which reports the agentset of all patches\nand the ",[319,491,492],{"displayText":296,"permalink":296},[16,493,296],{"href":494,"rel":495,"className":496,"dataDisplayText":296,"target":330,"title":296},"/dictionary#links",[327],[329]," primitive which reports the agentset of all links.",[22,499,500,501,504,505,507,508,510,511,518],{},"But what’s powerful about the agentset concept is that you can construct\nagentsets that contain only ",[467,502,503],{},"some"," turtles, ",[467,506,503],{}," patches or ",[467,509,503],{}," links. For\nexample, all the red turtles, or the patches with pxcor evenly divisible by\nfive, or the turtles in the first quadrant that are on a green patch or the\nlinks connected to turtle 0. These agentsets can then be used by ",[319,512,513],{"displayText":128,"permalink":128},[16,514,128],{"href":515,"rel":516,"className":517,"dataDisplayText":128,"target":330,"title":128},"/dictionary#ask",[327],[329]," or by\nvarious reporters that take agentsets as inputs.",[22,520,521,522,530,531,539,540,548],{},"One way is to use ",[319,523,525],{"displayText":524,"permalink":524},"turtles-here",[16,526,524],{"href":527,"rel":528,"className":529,"dataDisplayText":524,"target":330,"title":524},"/dictionary#turtles-here",[327],[329]," or ",[319,532,534],{"displayText":533,"permalink":533},"turtles-at",[16,535,533],{"href":536,"rel":537,"className":538,"dataDisplayText":533,"target":330,"title":533},"/dictionary#turtles-at",[327],[329],", to make an agentset\ncontaining only the turtles on my patch, or only the turtles on some other patch\nat some x and y offsets. There’s also ",[319,541,543],{"displayText":542,"permalink":542},"turtles-on",[16,544,542],{"href":545,"rel":546,"className":547,"dataDisplayText":542,"target":330,"title":542},"/dictionary#turtles-on",[327],[329]," so you can get the set of\nturtles standing on a given patch or set of patches, or the set of turtles\nstanding on the same patch as a given turtle or set of turtles.",[22,550,551],{},"Here are some more examples of how to make agentsets:",[553,554,555],"pre",{},[556,557,558,565,568,573,574,577,579,583,585,573,588,591,593,597,599,573,602,606,607,573,611,573,615,620,621,623,627,629,573,632,606,635,573,638,573,641,620,644,646,650,652,573,655,606,658,573,661,573,665,620,670,672,676,678,573,681,573,685,689,691,695,697,573,700,704,705,573,709,712,713,573,716,712,719,573,723,712,726,573,729,732,733,735,739,741,745,747,751,753,573,756,759,760,573,763,573,766,769,770,774,775,573,778,573,781,784,785,787,788,774,791,573,795,573,798,802,803,805,809,811,573,814,817,819,823,825,826,830,831,573,835,573,839],"code",{},[559,560,564],"span",{"className":561},[562,563],"token","comment",";; all other turtles:",[566,567],"br",{},[559,569,572],{"className":570},[562,571],"reporter","other"," ",[559,575,289],{"className":576},[562,571],[566,578],{},[559,580,582],{"className":581},[562,563],";; all other turtles on this patch:",[566,584],{},[559,586,572],{"className":587},[562,571],[559,589,524],{"className":590},[562,571],[566,592],{},[559,594,596],{"className":595},[562,563],";; all red turtles:",[566,598],{},[559,600,289],{"className":601},[562,571],[559,603,605],{"className":604},[562,571],"with"," [",[559,608,610],{"className":609},[562,571],"color",[559,612,614],{"className":613},[562,571],"=",[559,616,619],{"className":617},[562,618],"constant","red","]",[566,622],{},[559,624,626],{"className":625},[562,563],";; all red turtles on my patch",[566,628],{},[559,630,524],{"className":631},[562,571],[559,633,605],{"className":634},[562,571],[559,636,610],{"className":637},[562,571],[559,639,614],{"className":640},[562,571],[559,642,619],{"className":643},[562,618],[566,645],{},[559,647,649],{"className":648},[562,563],";; patches on right side of view",[566,651],{},[559,653,293],{"className":654},[562,571],[559,656,605],{"className":657},[562,571],[559,659,321],{"className":660},[562,571],[559,662,664],{"className":663},[562,571],">",[559,666,669],{"className":667},[562,668],"number","0",[566,671],{},[559,673,675],{"className":674},[562,563],";; all turtles less than 3 patches away",[566,677],{},[559,679,289],{"className":680},[562,571],[559,682,684],{"className":683},[562,571],"in-radius",[559,686,688],{"className":687},[562,668],"3",[566,690],{},[559,692,694],{"className":693},[562,563],";; the four patches to the east, north, west, and south",[566,696],{},[559,698,293],{"className":699},[562,571],[559,701,703],{"className":702},[562,571],"at-points"," [[",[559,706,708],{"className":707},[562,668],"1",[559,710,669],{"className":711},[562,668],"] [",[559,714,669],{"className":715},[562,668],[559,717,708],{"className":718},[562,668],[559,720,722],{"className":721},[562,668],"-1",[559,724,669],{"className":725},[562,668],[559,727,669],{"className":728},[562,668],[559,730,722],{"className":731},[562,668],"]]",[566,734],{},[559,736,738],{"className":737},[562,563],";; shorthand for those four patches",[566,740],{},[559,742,744],{"className":743},[562,571],"neighbors4",[566,746],{},[559,748,750],{"className":749},[562,563],";; turtles in the first quadrant that are on a green patch",[566,752],{},[559,754,289],{"className":755},[562,571],[559,757,605],{"className":758},[562,571]," [(",[559,761,435],{"className":762},[562,571],[559,764,664],{"className":765},[562,571],[559,767,669],{"className":768},[562,668],") ",[559,771,773],{"className":772},[562,571],"and"," (",[559,776,443],{"className":777},[562,571],[559,779,664],{"className":780},[562,571],[559,782,669],{"className":783},[562,668],")",[566,786],{},"              ",[559,789,773],{"className":790},[562,571],[559,792,794],{"className":793},[562,571],"pcolor",[559,796,614],{"className":797},[562,571],[559,799,801],{"className":800},[562,618],"green",")]",[566,804],{},[559,806,808],{"className":807},[562,563],";; turtles standing on my neighboring four patches",[566,810],{},[559,812,542],{"className":813},[562,571],[559,815,744],{"className":816},[562,571],[566,818],{},[559,820,822],{"className":821},[562,563],";; all the links connected to turtle 0",[566,824],{},"[",[559,827,829],{"className":828},[562,571],"my-links","] ",[559,832,834],{"className":833},[562,571],"of",[559,836,838],{"className":837},[562,571],"turtle",[559,840,669],{"className":841},[562,668],[22,843,844,845,852],{},"Note the use of ",[319,846,847],{"displayText":572,"permalink":572},[16,848,572],{"href":849,"rel":850,"className":851,"dataDisplayText":572,"target":330,"title":572},"/dictionary#other",[327],[329]," to exclude this agent. This is common.",[22,854,855],{},"Once you have created an agentset, here are some simple things you can do:",[44,857,858,868,879,890],{},[47,859,860,861,867],{},"Use ",[319,862,863],{"displayText":128,"permalink":128},[16,864,128],{"href":515,"rel":865,"className":866,"dataDisplayText":128,"target":330,"title":128},[327],[329]," to make the agents in the agentset do something",[47,869,860,870,878],{},[319,871,873],{"displayText":872,"permalink":872},"any?",[16,874,872],{"href":875,"rel":876,"className":877,"dataDisplayText":872,"target":330,"title":872},"/dictionary#any",[327],[329]," to see if the agentset is empty",[47,880,860,881,889],{},[319,882,884],{"displayText":883,"permalink":883},"all?",[16,885,883],{"href":886,"rel":887,"className":888,"dataDisplayText":883,"target":330,"title":883},"/dictionary#all",[327],[329]," to see if every agent in an agentset satisfies a condition.",[47,891,860,892,900],{},[319,893,895],{"displayText":894,"permalink":894},"count",[16,896,894],{"href":897,"rel":898,"className":899,"dataDisplayText":894,"target":330,"title":894},"/dictionary#count",[327],[329]," to find out exactly how many agents are in the set",[22,902,903],{},"And here are some more complex things you can do:",[44,905,906],{},[47,907,908,909,917],{},"Pick a random agent from the set using ",[319,910,912],{"displayText":911,"permalink":911},"one-of",[16,913,911],{"href":914,"rel":915,"className":916,"dataDisplayText":911,"target":330,"title":911},"/dictionary#one-of",[327],[329],". For example, we can make a\nrandomly chosen turtle turn green:",[22,919,920,921],{},"ask one-of turtles ",[559,922,923],{}," set color green",[22,925,926,927,935],{},"Or tell a randomly chosen patch to ",[319,928,930],{"displayText":929,"permalink":929},"sprout",[16,931,929],{"href":932,"rel":933,"className":934,"dataDisplayText":929,"target":330,"title":929},"/dictionary#sprout",[327],[329]," a new turtle:",[553,937,938],{},[556,939,940,941,573,945,573,948,951,952,573,955,958],{},"    ",[559,942,128],{"className":943},[562,944],"command",[559,946,911],{"className":947},[562,571],[559,949,293],{"className":950},[562,571]," [ ",[559,953,929],{"className":954},[562,944],[559,956,708],{"className":957},[562,668]," ]",[44,960,961],{},[47,962,963,964,530,972,980],{},"Use the ",[319,965,967],{"displayText":966,"permalink":966},"max-one-of",[16,968,966],{"href":969,"rel":970,"className":971,"dataDisplayText":966,"target":330,"title":966},"/dictionary#max-one-of",[327],[329],[319,973,975],{"displayText":974,"permalink":974},"min-one-of",[16,976,974],{"href":977,"rel":978,"className":979,"dataDisplayText":974,"target":330,"title":974},"/dictionary#min-one-of",[327],[329]," reporters to find out which agent is\nthe most or least along some scale. For example, to remove the richest turtle,\nyou could say",[553,982,983],{},[556,984,940,985,573,988,573,991,606,994,573,998,1003,1004,958],{},[559,986,128],{"className":987},[562,944],[559,989,966],{"className":990},[562,571],[559,992,289],{"className":993},[562,571],[559,995,997],{"className":996},[562,571],"sum",[559,999,1002],{"className":1000},[562,1001],"variable","assets","] [ ",[559,1005,1007],{"className":1006},[562,944],"die",[44,1009,1010,1030],{},[47,1011,1012,1013,1021,1022,1029],{},"Make a histogram of the agentset using the ",[319,1014,1016],{"displayText":1015,"permalink":1015},"histogram",[16,1017,1015],{"href":1018,"rel":1019,"className":1020,"dataDisplayText":1015,"target":330,"title":1015},"/dictionary#histogram",[327],[329]," command (in\ncombination with ",[319,1023,1024],{"displayText":834,"permalink":834},[16,1025,834],{"href":1026,"rel":1027,"className":1028,"dataDisplayText":834,"target":330,"title":834},"/dictionary#of",[327],[329],").",[47,1031,860,1032,1038,1039,1042],{},[319,1033,1034],{"displayText":834,"permalink":834},[16,1035,834],{"href":1026,"rel":1036,"className":1037,"dataDisplayText":834,"target":330,"title":834},[327],[329]," to make a list of values, one for each agent in the agentset. Then\nuse one of NetLogo’s list primitives to do something with the list. (See the\n“Lists” section ",[16,1040,1041],{"href":215},"below",".) For example, to find out how rich turtles\nare on the average, you could say",[553,1044,1045],{},[556,1046,940,1047,573,1051,606,1055,573,1058,830,1061,573,1064],{},[559,1048,1050],{"className":1049},[562,944],"show",[559,1052,1054],{"className":1053},[562,571],"mean",[559,1056,997],{"className":1057},[562,571],[559,1059,1002],{"className":1060},[562,1001],[559,1062,834],{"className":1063},[562,571],[559,1065,289],{"className":1066},[562,571],[44,1068,1069,1096,1123,1141],{},[47,1070,860,1071,290,1079,409,1087,1095],{},[319,1072,1074],{"displayText":1073,"permalink":1073},"turtle-set",[16,1075,1073],{"href":1076,"rel":1077,"className":1078,"dataDisplayText":1073,"target":330,"title":1073},"/dictionary#turtle-set",[327],[329],[319,1080,1082],{"displayText":1081,"permalink":1081},"patch-set",[16,1083,1081],{"href":1084,"rel":1085,"className":1086,"dataDisplayText":1081,"target":330,"title":1081},"/dictionary#patch-set",[327],[329],[319,1088,1090],{"displayText":1089,"permalink":1089},"link-set",[16,1091,1089],{"href":1092,"rel":1093,"className":1094,"dataDisplayText":1089,"target":330,"title":1089},"/dictionary#link-set",[327],[329]," reporters to make new\nagentsets by gathering together agents from a variety of possible sources.",[47,1097,860,1098,290,1106,409,1114,1122],{},[319,1099,1101],{"displayText":1100,"permalink":1100},"no-turtles",[16,1102,1100],{"href":1103,"rel":1104,"className":1105,"dataDisplayText":1100,"target":330,"title":1100},"/dictionary#no-turtles",[327],[329],[319,1107,1109],{"displayText":1108,"permalink":1108},"no-patches",[16,1110,1108],{"href":1111,"rel":1112,"className":1113,"dataDisplayText":1108,"target":330,"title":1108},"/dictionary#no-patches",[327],[329],[319,1115,1117],{"displayText":1116,"permalink":1116},"no-links",[16,1118,1116],{"href":1119,"rel":1120,"className":1121,"dataDisplayText":1116,"target":330,"title":1116},"/dictionary#no-links",[327],[329]," reporters to make empty\nagentsets.",[47,1124,1125,1126,530,1134,301],{},"Check whether two agentsets are equal using ",[319,1127,1129],{"displayText":614,"permalink":1128},"symbols",[16,1130,614],{"href":1131,"rel":1132,"className":1133,"dataDisplayText":614,"target":330,"title":614},"/dictionary#symbols",[327],[329],[319,1135,1137],{"displayText":1136,"permalink":1128},"!=",[16,1138,1136],{"href":1131,"rel":1139,"className":1140,"dataDisplayText":1136,"target":330,"title":1136},[327],[329],[47,1142,860,1143,1151],{},[319,1144,1146],{"displayText":1145,"permalink":1145},"member?",[16,1147,1145],{"href":1148,"rel":1149,"className":1150,"dataDisplayText":1145,"target":330,"title":1145},"/dictionary#member",[327],[329]," to see whether a particular agent is a member of an agentset.",[22,1153,1154],{},"This only scratches the surface. See the Models Library for many more examples,\nand consult the NetLogo Dictionary for more information about all of the\nagentset primitives.",[22,1156,1157],{},"More examples of using agentsets are provided in the individual entries for\nthese primitives in the NetLogo Dictionary.",[34,1159,1162],{"id":1160,"className":1161},"special-agentsets",[14],[16,1163,1166],{"className":1164,"href":1165},[19],"#special-agentsets","Special agentsets",[22,1168,1169,1170,409,1172,1174,1175,1178,1179,1181],{},"The agentsets ",[556,1171,289],{},[556,1173,296],{}," have special behavior because they always\nhold the sets of ",[467,1176,1177],{},"all"," turtles and ",[467,1180,1177],{}," links. Therefore, these agentsets can\ngrow.",[22,1183,1184,1185,1196],{},"The following interaction shows the special behavior. Assume the Code tab has\n",[556,1186,1187,606,1192,620],{},[559,1188,1191],{"className":1189},[562,1190],"keyword","globals",[559,1193,1195],{"className":1194},[562,1001],"g",". Then:",[553,1198,1199],{},[556,1200,1201,573,1205,1209,1211,573,1214,573,1218,1222,1224,573,1227,573,1231,573,1234,1237,1239,573,1242,573,1246,573,1249,1252,1254,1257,1259,573,1262,573,1265,1268,1270,573,1273,573,1276,573,1279,1282,1284,1288,1290,573,1293,573,1296,573,1299,573,1302,1305,1307,573,1310,573,1313,573,1316,1319,1321,1324,1326,573,1329,573,1332,1335,1337,573,1340,573,1343,573,1346,1349,1351,1354,1356,573,1359,573,1362,573,1365,1368,1370],{},[559,1202,1204],{"className":1203},[562,1001],"observer>",[559,1206,1208],{"className":1207},[562,944],"clear-all",[566,1210],{},[559,1212,1204],{"className":1213},[562,1001],[559,1215,1217],{"className":1216},[562,944],"create-turtles",[559,1219,1221],{"className":1220},[562,668],"5",[566,1223],{},[559,1225,1204],{"className":1226},[562,1001],[559,1228,1230],{"className":1229},[562,944],"set",[559,1232,1195],{"className":1233},[562,1001],[559,1235,289],{"className":1236},[562,571],[566,1238],{},[559,1240,1204],{"className":1241},[562,1001],[559,1243,1245],{"className":1244},[562,944],"print",[559,1247,894],{"className":1248},[562,571],[559,1250,1195],{"className":1251},[562,1001],[566,1253],{},[559,1255,1221],{"className":1256},[562,668],[566,1258],{},[559,1260,1204],{"className":1261},[562,1001],[559,1263,1217],{"className":1264},[562,944],[559,1266,1221],{"className":1267},[562,668],[566,1269],{},[559,1271,1204],{"className":1272},[562,1001],[559,1274,1245],{"className":1275},[562,944],[559,1277,894],{"className":1278},[562,571],[559,1280,1195],{"className":1281},[562,1001],[566,1283],{},[559,1285,1287],{"className":1286},[562,668],"10",[566,1289],{},[559,1291,1204],{"className":1292},[562,1001],[559,1294,1230],{"className":1295},[562,944],[559,1297,1195],{"className":1298},[562,1001],[559,1300,1073],{"className":1301},[562,571],[559,1303,289],{"className":1304},[562,571],[566,1306],{},[559,1308,1204],{"className":1309},[562,1001],[559,1311,1245],{"className":1312},[562,944],[559,1314,894],{"className":1315},[562,571],[559,1317,1195],{"className":1318},[562,1001],[566,1320],{},[559,1322,1287],{"className":1323},[562,668],[566,1325],{},[559,1327,1204],{"className":1328},[562,1001],[559,1330,1217],{"className":1331},[562,944],[559,1333,1221],{"className":1334},[562,668],[566,1336],{},[559,1338,1204],{"className":1339},[562,1001],[559,1341,1245],{"className":1342},[562,944],[559,1344,894],{"className":1345},[562,571],[559,1347,1195],{"className":1348},[562,1001],[566,1350],{},[559,1352,1287],{"className":1353},[562,668],[566,1355],{},[559,1357,1204],{"className":1358},[562,1001],[559,1360,1245],{"className":1361},[562,944],[559,1363,894],{"className":1364},[562,571],[559,1366,289],{"className":1367},[562,571],[566,1369],{},[559,1371,1373],{"className":1372},[562,668],"15",[22,1375,1376,1377,1379,1380,1388,1389,1392],{},"The ",[556,1378,289],{}," agentset grows when new turtles are born, but other agentsets\ndon’t grow. If I write ",[556,1381,1382,573,1385],{},[559,1383,1073],{"className":1384},[562,571],[559,1386,289],{"className":1387},[562,571],", I get a new, normal agentset\ncontaining just the turtles that ",[467,1390,1391],{},"currently"," exist. New turtles don’t join when\nthey’re born.",[22,1394,1395,1396,409,1398,1400],{},"Breed agentsets are special in the same way as ",[556,1397,289],{},[556,1399,296],{},". Breeds are\nintroduced and explained below.",[34,1402,1405],{"id":1403,"className":1404},"agentsets-and-lists",[14],[16,1406,1409],{"className":1407,"href":1408},[19],"#agentsets-and-lists","Agentsets and lists",[22,1411,1412],{},"Earlier, we said that agentsets are always in random order, a different random\norder every time. If you need your agents to do something in a fixed order, you\nneed to make a list of the agents instead. See the Lists section below.",[1414,1415,1416],"blockquote",{},[22,1417,1418,1421],{},[281,1419,1420],{},"Code Example:"," Ask Ordering Example",[270,1423,1426],{"id":1424,"className":1425},"breeds",[14],[16,1427,72],{"className":1428,"href":71},[19],[22,1430,1431,1432,409,1435,1438,1439,409,1442,1445],{},"NetLogo allows you to define different “breeds” of turtles and breeds of links.\nOnce you have defined breeds, you can go on and make the different breeds behave\ndifferently. For example, you could have breeds called ",[556,1433,1434],{},"sheep",[556,1436,1437],{},"wolves",", and\nhave the wolves try to eat the sheep or you could have link breeds called\n",[556,1440,1441],{},"streets",[556,1443,1444],{},"sidewalks"," where foot traffic is routed on sidewalks and car\ntraffic is routed on streets.",[22,1447,1448,1449,1457],{},"You define turtle breeds using the ",[319,1450,1452],{"displayText":1451,"permalink":1451},"breed",[16,1453,1451],{"href":1454,"rel":1455,"className":1456,"dataDisplayText":1451,"target":330,"title":1451},"/dictionary#breed",[327],[329]," keyword, at the top of the Code\ntab, before any procedures:",[553,1459,1460],{},[556,1461,1462,606,1465,573,1468,620,1472,606,1477,573,1480,620],{},[559,1463,1451],{"className":1464},[562,1190],[559,1466,1437],{"className":1467},[562,1001],[559,1469,1471],{"className":1470},[562,1001],"wolf",[559,1473,1475,1451],{"className":1474},[562,1190],[566,1476],{},[559,1478,1434],{"className":1479},[562,1001],[559,1481,1483],{"className":1482},[562,1001],"a-sheep",[22,1485,1486,1487,1494],{},"You can refer to a member of the breed using the singular form, just like the\n",[319,1488,1489],{"displayText":838,"permalink":838},[16,1490,838],{"href":1491,"rel":1492,"className":1493,"dataDisplayText":838,"target":330,"title":838},"/dictionary#turtle",[327],[329]," reporter. When printed, members of the breed will be labeled with the\nsingular name.",[22,1496,1497,1498,1506,1507,301],{},"Some commands and reporters have the plural name of the breed in them, such as\n",[319,1499,1501],{"displayText":1500,"permalink":1217},"create-\u003Cbreeds>",[16,1502,1500],{"href":1503,"rel":1504,"className":1505,"dataDisplayText":1500,"target":330,"title":1500},"/dictionary#create-turtles",[327],[329],". Others have the singular name of the breed\nin them, such as ",[319,1508,1510],{"displayText":1509,"permalink":838},"\u003Cbreed>",[16,1511,1509],{"href":1491,"rel":1512,"className":1513,"dataDisplayText":1509,"target":330,"title":1509},[327],[329],[22,1515,1516],{},"The order in which breeds are declared is also the order in which they are\nlayered in the view. So breeds defined later will appear on top of breeds\ndefined earlier; in this example, sheep will be drawn over wolves.",[22,1518,1519,1520,1522,1523,1525],{},"When you define a breed such as ",[556,1521,1434],{},", an agentset for that breed is\nautomatically created, so that all of the agentset capabilities described above\nare immediately available with the ",[556,1524,1434],{}," agentset.",[22,1527,1528,1529,290,1536,396,1545,290,1552,290,1559,396,1566,1573,1574,301],{},"The following new primitives are also automatically available once you define a\nbreed: ",[319,1530,1532],{"displayText":1531,"permalink":1217},"create-sheep",[16,1533,1531],{"href":1503,"rel":1534,"className":1535,"dataDisplayText":1531,"target":330,"title":1531},[327],[329],[319,1537,1540],{"displayText":1538,"permalink":1539},"hatch-sheep","hatch",[16,1541,1538],{"href":1542,"rel":1543,"className":1544,"dataDisplayText":1538,"target":330,"title":1538},"/dictionary#hatch",[327],[329],[319,1546,1548],{"displayText":1547,"permalink":929},"sprout-sheep",[16,1549,1547],{"href":932,"rel":1550,"className":1551,"dataDisplayText":1547,"target":330,"title":1547},[327],[329],[319,1553,1555],{"displayText":1554,"permalink":524},"sheep-here",[16,1556,1554],{"href":527,"rel":1557,"className":1558,"dataDisplayText":1554,"target":330,"title":1554},[327],[329],[319,1560,1562],{"displayText":1561,"permalink":533},"sheep-at",[16,1563,1561],{"href":536,"rel":1564,"className":1565,"dataDisplayText":1561,"target":330,"title":1561},[327],[329],[319,1567,1569],{"displayText":1568,"permalink":542},"sheep-on",[16,1570,1568],{"href":545,"rel":1571,"className":1572,"dataDisplayText":1568,"target":330,"title":1568},[327],[329],", and ",[319,1575,1578],{"displayText":1576,"permalink":1577},"is-a-sheep?","is-of-type",[16,1579,1576],{"href":1580,"rel":1581,"className":1582,"dataDisplayText":1576,"target":330,"title":1576},"/dictionary#is-of-type",[327],[329],[22,1584,1585,1586,1595],{},"Also, you can use ",[319,1587,1590],{"displayText":1588,"permalink":1589},"sheep-own","turtles-own",[16,1591,1588],{"href":1592,"rel":1593,"className":1594,"dataDisplayText":1588,"target":330,"title":1588},"/dictionary#turtles-own",[327],[329]," to define new turtle variables that\nonly turtles of the given breed have. (It’s allowed for more than one breed to\nown the same variable.)",[22,1597,1598,1599,1607],{},"A turtle’s breed agentset is stored in the ",[319,1600,1602],{"displayText":1451,"permalink":1601},"breedvar",[16,1603,1451],{"href":1604,"rel":1605,"className":1606,"dataDisplayText":1451,"target":330,"title":1451},"/dictionary#breedvar",[327],[329]," turtle variable.\nSo you can test a turtle’s breed, like this:",[553,1609,1610],{},[556,1611,1612,1616,573,1620,573,1623,951,1626,958],{},[559,1613,1615],{"className":1614},[562,944],"if",[559,1617,1619],{"className":1618},[562,1190]," breed",[559,1621,614],{"className":1622},[562,571],[559,1624,1437],{"className":1625},[562,1001],[559,1627,1629],{"className":1628},[562,1001],"...",[22,1631,1632],{},"Note also that turtles can change breeds. A wolf doesn’t have to remain a wolf\nits whole life. Let’s change a random wolf into a sheep:",[553,1634,1635],{},[556,1636,1637,573,1640,573,1643,951,1646,1649,573,1652,958],{},[559,1638,128],{"className":1639},[562,944],[559,1641,911],{"className":1642},[562,571],[559,1644,1437],{"className":1645},[562,1001],[559,1647,1230],{"className":1648},[562,944],[559,1650,1619],{"className":1651},[562,1190],[559,1653,1434],{"className":1654},[562,1001],[22,1656,1376,1657,1665,1666,301],{},[319,1658,1660],{"displayText":1659,"permalink":1659},"set-default-shape",[16,1661,1659],{"href":1662,"rel":1663,"className":1664,"dataDisplayText":1659,"target":330,"title":1659},"/dictionary#set-default-shape",[327],[329]," primitive is useful for associating certain turtle\nshapes with certain breeds. See the section on shapes ",[16,1667,1041],{"href":101},[22,1669,1670,1671,1680,1681,1690,1691,1699],{},"Who numbers are assigned irrespective of breeds. If you already have a ",[556,1672,1673,573,1677],{},[559,1674,1676],{"className":1675},[562,1001],"frog",[559,1678,669],{"className":1679},[562,668],",\nthen the first mouse will be ",[556,1682,1683,573,1687],{},[559,1684,1686],{"className":1685},[562,1001],"mouse",[559,1688,708],{"className":1689},[562,668],", not ",[556,1692,1693,573,1696],{},[559,1694,1686],{"className":1695},[562,1001],[559,1697,669],{"className":1698},[562,668],", since the who number 0 is\nalready taken.",[22,1701,1702],{},"Here is a quick example of using breeds:",[553,1704,1705],{},[556,1706,1707,606,1710,573,1714,620,1717,606,1722,573,1726,620,1729,606,1735,620,1739,573,1745,1749,1751,1752,1755,1751,1757,573,1761,1765,1767,1768,573,1771,573,1774,1778,1780,1781,573,1784,573,1787,573,1791,958,1794,1751,1796,573,1800,1803,1767,1805,573,1808,573,1811,958,1814,1751,1816,1820],{},[559,1708,1451],{"className":1709},[562,1190],[559,1711,1713],{"className":1712},[562,1001],"mice",[559,1715,1686],{"className":1716},[562,1001],[559,1718,1720,1451],{"className":1719},[562,1190],[566,1721],{},[559,1723,1725],{"className":1724},[562,1001],"frogs",[559,1727,1676],{"className":1728},[562,1001],[559,1730,1732,1734],{"className":1731},[562,1190],[566,1733],{},"mice-own",[559,1736,1738],{"className":1737},[562,1001],"cheese",[559,1740,1742,1744],{"className":1741},[562,1190],[566,1743],{},"to",[559,1746,1748],{"className":1747},[562,1001],"setup",[566,1750],{},"  ",[559,1753,1208],{"className":1754},[562,944],[566,1756],{},[559,1758,1760],{"className":1759},[562,1001],"create-mice",[559,1762,1764],{"className":1763},[562,668],"50",[566,1766],{},"    [ ",[559,1769,1230],{"className":1770},[562,944],[559,1772,610],{"className":1773},[562,571],[559,1775,1777],{"className":1776},[562,618],"white",[566,1779],{},"      ",[559,1782,1230],{"className":1783},[562,944],[559,1785,1738],{"className":1786},[562,1001],[559,1788,1790],{"className":1789},[562,571],"random",[559,1792,1287],{"className":1793},[562,668],[566,1795],{},[559,1797,1799],{"className":1798},[562,1001],"create-frogs",[559,1801,1764],{"className":1802},[562,668],[566,1804],{},[559,1806,1230],{"className":1807},[562,944],[559,1809,610],{"className":1810},[562,571],[559,1812,801],{"className":1813},[562,618],[566,1815],{},[559,1817,1819],{"className":1818},[562,944],"reset-ticks",[559,1821,1823,1825],{"className":1822},[562,1190],[566,1824],{},"end",[1414,1827,1828],{},[22,1829,1830,1832],{},[281,1831,1420],{}," Breeds and Shapes Example",[34,1834,1837],{"id":1835,"className":1836},"link-breeds",[14],[16,1838,1841],{"className":1839,"href":1840},[19],"#link-breeds","Link breeds",[22,1843,1844],{},"Link breeds are very similar to turtle breeds, however, there are a few\ndifferences.",[22,1846,1847,1848,331,1856,1864],{},"When you declare a link breed you must declare whether it is a breed of directed\nor undirected links by using the ",[319,1849,1851],{"displayText":1850,"permalink":1850},"directed-link-breed",[16,1852,1850],{"href":1853,"rel":1854,"className":1855,"dataDisplayText":1850,"target":330,"title":1850},"/dictionary#directed-link-breed",[327],[329],[319,1857,1859],{"displayText":1858,"permalink":1858},"undirected-link-breed",[16,1860,1858],{"href":1861,"rel":1862,"className":1863,"dataDisplayText":1858,"target":330,"title":1858},"/dictionary#undirected-link-breed",[327],[329]," keywords.",[553,1866,1867],{},[556,1868,1869,606,1872,573,1875,620,1879,606,1884,573,1888,620],{},[559,1870,1850],{"className":1871},[562,1190],[559,1873,1441],{"className":1874},[562,1001],[559,1876,1878],{"className":1877},[562,1001],"street",[559,1880,1882,1858],{"className":1881},[562,1190],[566,1883],{},[559,1885,1887],{"className":1886},[562,1001],"friendships",[559,1889,1891],{"className":1890},[562,1001],"friendship",[22,1893,1894],{},"Once you have created a breeded link you cannot create unbreeded links and vice\nversa. (You can, however, have directed and undirected links in the same world,\njust not in the same breed)",[22,1896,1897,1898,301],{},"Unlike with turtle breeds the singular breed name is required for link breeds,\nas many of the link commands and reports use the singular name, such as\n",[319,1899,1902],{"displayText":1900,"permalink":1901},"\u003Clink-breed>-neighbor?","link-neighbor",[16,1903,1900],{"href":1904,"rel":1905,"className":1906,"dataDisplayText":1900,"target":330,"title":1900},"/dictionary#link-neighbor",[327],[329],[22,1908,1909,1910,1919,573,1926,1933,573,1940,1949,573,1958,1967,573,1976,1985,1994,573,2003],{},"The following primitives are also automatically available once you define a\ndirected link breed: ",[319,1911,1914],{"displayText":1912,"permalink":1913},"create-street-from","create-link",[16,1915,1912],{"href":1916,"rel":1917,"className":1918,"dataDisplayText":1912,"target":330,"title":1912},"/dictionary#create-link",[327],[329],[319,1920,1922],{"displayText":1921,"permalink":1913},"create-streets-from",[16,1923,1921],{"href":1916,"rel":1924,"className":1925,"dataDisplayText":1921,"target":330,"title":1921},[327],[329],[319,1927,1929],{"displayText":1928,"permalink":1913},"create-street-to",[16,1930,1928],{"href":1916,"rel":1931,"className":1932,"dataDisplayText":1928,"target":330,"title":1928},[327],[329],[319,1934,1936],{"displayText":1935,"permalink":1913},"create-streets-to",[16,1937,1935],{"href":1916,"rel":1938,"className":1939,"dataDisplayText":1935,"target":330,"title":1935},[327],[329],[319,1941,1944],{"displayText":1942,"permalink":1943},"in-street-neighbor?","in-link-neighbor",[16,1945,1942],{"href":1946,"rel":1947,"className":1948,"dataDisplayText":1942,"target":330,"title":1942},"/dictionary#in-link-neighbor",[327],[329],[319,1950,1953],{"displayText":1951,"permalink":1952},"in-street-neighbors","in-link-neighbors",[16,1954,1951],{"href":1955,"rel":1956,"className":1957,"dataDisplayText":1951,"target":330,"title":1951},"/dictionary#in-link-neighbors",[327],[329],[319,1959,1962],{"displayText":1960,"permalink":1961},"in-street-from","in-link-from",[16,1963,1960],{"href":1964,"rel":1965,"className":1966,"dataDisplayText":1960,"target":330,"title":1960},"/dictionary#in-link-from",[327],[329],[319,1968,1971],{"displayText":1969,"permalink":1970},"my-in-streets","my-in-links",[16,1972,1969],{"href":1973,"rel":1974,"className":1975,"dataDisplayText":1969,"target":330,"title":1969},"/dictionary#my-in-links",[327],[329],[319,1977,1980],{"displayText":1978,"permalink":1979},"my-out-streets","my-out-links",[16,1981,1978],{"href":1982,"rel":1983,"className":1984,"dataDisplayText":1978,"target":330,"title":1978},"/dictionary#my-out-links",[327],[329],[319,1986,1989],{"displayText":1987,"permalink":1988},"out-street-neighbor?","out-link-neighbor",[16,1990,1987],{"href":1991,"rel":1992,"className":1993,"dataDisplayText":1987,"target":330,"title":1987},"/dictionary#out-link-neighbor",[327],[329],[319,1995,1998],{"displayText":1996,"permalink":1997},"out-street-neighbors","out-link-neighbors",[16,1999,1996],{"href":2000,"rel":2001,"className":2002,"dataDisplayText":1996,"target":330,"title":1996},"/dictionary#out-link-neighbors",[327],[329],[319,2004,2007],{"displayText":2005,"permalink":2006},"out-street-to","out-link-to",[16,2008,2005],{"href":2009,"rel":2010,"className":2011,"dataDisplayText":2005,"target":330,"title":2005},"/dictionary#out-link-to",[327],[329],[22,2013,2014,2015,2022,573,2029,2036,573,2045,2054],{},"And the following are automatically available when you define an undirected link\nbreed: ",[319,2016,2018],{"displayText":2017,"permalink":1913},"create-friendship-with",[16,2019,2017],{"href":1916,"rel":2020,"className":2021,"dataDisplayText":2017,"target":330,"title":2017},[327],[329],[319,2023,2025],{"displayText":2024,"permalink":1913},"create-friendships-with",[16,2026,2024],{"href":1916,"rel":2027,"className":2028,"dataDisplayText":2024,"target":330,"title":2024},[327],[329],[319,2030,2032],{"displayText":2031,"permalink":1901},"friendship-neighbor?",[16,2033,2031],{"href":1904,"rel":2034,"className":2035,"dataDisplayText":2031,"target":330,"title":2031},[327],[329],[319,2037,2040],{"displayText":2038,"permalink":2039},"friendship-neighbors","link-neighbors",[16,2041,2038],{"href":2042,"rel":2043,"className":2044,"dataDisplayText":2038,"target":330,"title":2038},"/dictionary#link-neighbors",[327],[329],[319,2046,2049],{"displayText":2047,"permalink":2048},"friendship-with","link-with",[16,2050,2047],{"href":2051,"rel":2052,"className":2053,"dataDisplayText":2047,"target":330,"title":2047},"/dictionary#link-with",[327],[329],[319,2055,2057],{"displayText":2056,"permalink":829},"my-friendships",[16,2058,2056],{"href":2059,"rel":2060,"className":2061,"dataDisplayText":2056,"target":330,"title":2056},"/dictionary#my-links",[327],[329],[22,2063,2064,2065,2068],{},"Multiple link breeds may declare the same ",[556,2066,2067],{},"-own"," variable, but a variable may\nnot be shared between a turtle breed and a link breed.",[22,2070,2071,2072,2081],{},"Just as with turtle breeds the order in which link breeds are declared defines\nthe order in which the links are drawn, so the friendships will always be on top\nof streets (if for some reason these breeds were in the same model). You can\nalso use ",[319,2073,2076],{"displayText":2074,"permalink":2075},"\u003Clink-breeds>-own","links-own",[16,2077,2074],{"href":2078,"rel":2079,"className":2080,"dataDisplayText":2074,"target":330,"title":2074},"/dictionary#links-own",[327],[329]," to declare variables of each link breed\nseparately.",[22,2083,2084,2085,2093],{},"You can change the breed of a link with ",[556,2086,2087,2090],{},[559,2088,1230],{"className":2089},[562,944],[559,2091,1619],{"className":2092},[562,1190],". (However, you cannot change\na breeded link to an unbreeded one, to prevent having breeded and unbreeded\nlinks in the same world.)",[553,2095,2096],{},[556,2097,2098,573,2101,573,2104,951,2107,2110,573,2113,958,2116,2118,573,2121,573,2124,951,2127,2130,573,2133,2136,2137],{},[559,2099,128],{"className":2100},[562,944],[559,2102,911],{"className":2103},[562,571],[559,2105,1887],{"className":2106},[562,1001],[559,2108,1230],{"className":2109},[562,944],[559,2111,1619],{"className":2112},[562,1190],[559,2114,1441],{"className":2115},[562,1001],[566,2117],{},[559,2119,128],{"className":2120},[562,944],[559,2122,911],{"className":2123},[562,571],[559,2125,1887],{"className":2126},[562,1001],[559,2128,1230],{"className":2129},[562,944],[559,2131,1619],{"className":2132},[562,1190],[559,2134,296],{"className":2135},[562,571]," ] ",[559,2138,2140],{"className":2139},[562,563],";; produces a runtime error",[22,2142,2143,2149],{},[319,2144,2145],{"displayText":1659,"permalink":1659},[16,2146,1659],{"href":1662,"rel":2147,"className":2148,"dataDisplayText":1659,"target":330,"title":1659},[327],[329]," may also be used with link breeds to associate it with a\nparticular link shape.",[1414,2151,2152],{},[22,2153,2154,2156],{},[281,2155,1420],{}," Link Breeds Example",[270,2158,2161],{"id":2159,"className":2160},"variables",[14],[16,2162,78],{"className":2163,"href":77},[19],[22,2165,2166],{},[281,2167,2168],{},"Agent variables",[22,2170,2171],{},"Agent variables are places to store values (such as numbers) in an agent. An\nagent variable can be a global variable, a turtle variable, a patch variable, or\na link variable.",[22,2173,2174],{},"If a variable is a global variable, there is only one value for the variable,\nand every agent can access it. You can think of global variables as belonging to\nthe observer.",[22,2176,2177,2178,2181],{},"Turtle, patch, and link variables are different. Each turtle has its ",[467,2179,2180],{},"own"," value\nfor every turtle variable. The same goes for patches and links.",[22,2183,2184,2185,2192,2193,2200],{},"Some variables are built into NetLogo. For example, all turtles and links have a\n",[319,2186,2187],{"displayText":610,"permalink":610},[16,2188,610],{"href":2189,"rel":2190,"className":2191,"dataDisplayText":610,"target":330,"title":610},"/dictionary#color",[327],[329]," variable, and all patches have a ",[319,2194,2195],{"displayText":794,"permalink":794},[16,2196,794],{"href":2197,"rel":2198,"className":2199,"dataDisplayText":794,"target":330,"title":794},"/dictionary#pcolor",[327],[329]," variable. (The patch\nvariable begins with “p” so it doesn’t get confused with the turtle variable,\nsince turtles have direct access to patch variables.) If you set the variable,\nthe turtle or patch changes color. (See next section for details.)",[22,2202,2203,2204,290,2210,1573,2216,2224,2225,409,2231,2237,2238,2247],{},"Other built-in turtle variables including ",[319,2205,2206],{"displayText":435,"permalink":435},[16,2207,435],{"href":438,"rel":2208,"className":2209,"dataDisplayText":435,"target":330,"title":435},[327],[329],[319,2211,2212],{"displayText":443,"permalink":443},[16,2213,443],{"href":446,"rel":2214,"className":2215,"dataDisplayText":443,"target":330,"title":443},[327],[329],[319,2217,2219],{"displayText":2218,"permalink":2218},"heading",[16,2220,2218],{"href":2221,"rel":2222,"className":2223,"dataDisplayText":2218,"target":330,"title":2218},"/dictionary#heading",[327],[329],".\nOther built-in patch variables include ",[319,2226,2227],{"displayText":321,"permalink":322},[16,2228,321],{"href":325,"rel":2229,"className":2230,"dataDisplayText":321,"target":330,"title":321},[327],[329],[319,2232,2233],{"displayText":334,"permalink":322},[16,2234,334],{"href":325,"rel":2235,"className":2236,"dataDisplayText":334,"target":330,"title":334},[327],[329],". (There\nis ",[319,2239,2242],{"displayText":2240,"permalink":2241},"a complete list here of built in variables","builtinvariables",[16,2243,2240],{"href":2244,"rel":2245,"className":2246,"dataDisplayText":2240,"target":330,"title":2240},"/dictionary#builtinvariables",[327],[329],".)",[22,2249,2250,2251,2258],{},"You can also define your own variables. You can make a global variable by adding\na switch, slider, chooser, or input box to your model, or by using the\n",[319,2252,2253],{"displayText":1191,"permalink":1191},[16,2254,1191],{"href":2255,"rel":2256,"className":2257,"dataDisplayText":1191,"target":330,"title":1191},"/dictionary#globals",[327],[329]," keyword at the beginning of your code, like this:",[553,2260,2261],{},[556,2262,2263,606,2266,620],{},[559,2264,1191],{"className":2265},[562,1190],[559,2267,2269],{"className":2268},[562,1001],"score",[22,2271,2272,2273,290,2279,409,2287,2293],{},"You can also define new turtle, patch and link variables using the\n",[319,2274,2275],{"displayText":1589,"permalink":1589},[16,2276,1589],{"href":1592,"rel":2277,"className":2278,"dataDisplayText":1589,"target":330,"title":1589},[327],[329],[319,2280,2282],{"displayText":2281,"permalink":2281},"patches-own",[16,2283,2281],{"href":2284,"rel":2285,"className":2286,"dataDisplayText":2281,"target":330,"title":2281},"/dictionary#patches-own",[327],[329],[319,2288,2289],{"displayText":2075,"permalink":2075},[16,2290,2075],{"href":2078,"rel":2291,"className":2292,"dataDisplayText":2075,"target":330,"title":2075},[327],[329]," keywords, like this:",[553,2295,2296],{},[556,2297,2298,606,2301,573,2305,620,2309,606,2314,620,2318,606,2323,620],{},[559,2299,1589],{"className":2300},[562,1190],[559,2302,2304],{"className":2303},[562,1001],"energy",[559,2306,2308],{"className":2307},[562,1001],"speed",[559,2310,2312,2281],{"className":2311},[562,1190],[566,2313],{},[559,2315,2317],{"className":2316},[562,1001],"friction",[559,2319,2321,2075],{"className":2320},[562,1190],[566,2322],{},[559,2324,2326],{"className":2325},[562,1001],"strength",[22,2328,2329,2330,2337],{},"These variables can then be used freely in your model. Use the ",[319,2331,2332],{"displayText":1230,"permalink":1230},[16,2333,1230],{"href":2334,"rel":2335,"className":2336,"dataDisplayText":1230,"target":330,"title":1230},"/dictionary#set",[327],[329]," command\nto set them. (Any variable you don’t set has a starting value of zero.)",[22,2339,2340],{},"Global variables can be read and set at any time by any agent. As well, a turtle\ncan read and set patch variables of the patch it is standing on. For example,\nthis code:",[553,2342,2343],{},[556,2344,2345,573,2348,951,2351,573,2354,573,2357,958],{},[559,2346,128],{"className":2347},[562,944],[559,2349,289],{"className":2350},[562,571],[559,2352,1230],{"className":2353},[562,944],[559,2355,794],{"className":2356},[562,571],[559,2358,619],{"className":2359},[562,618],[22,2361,2362],{},"causes every turtle to make the patch it is standing on red. (Because patch\nvariables are shared by turtles in this way, you can’t have a turtle variable\nand a patch variable with the same name.)",[22,2364,2365,2366,2372],{},"In other situations where you want an agent to read a different agent’s\nvariable, you can use ",[319,2367,2368],{"displayText":834,"permalink":834},[16,2369,834],{"href":1026,"rel":2370,"className":2371,"dataDisplayText":834,"target":330,"title":834},[327],[329],". Example:",[553,2374,2375],{},[556,2376,2377,606,2380,830,2383,573,2386,573,2389,2392,2394],{},[559,2378,1050],{"className":2379},[562,944],[559,2381,610],{"className":2382},[562,571],[559,2384,834],{"className":2385},[562,571],[559,2387,838],{"className":2388},[562,571],[559,2390,1221],{"className":2391},[562,668],[566,2393],{},[559,2395,2397],{"className":2396},[562,563],";; prints current color of turtle with who number 5",[22,2399,2400,2401,2407],{},"You can also use ",[319,2402,2403],{"displayText":834,"permalink":834},[16,2404,834],{"href":1026,"rel":2405,"className":2406,"dataDisplayText":834,"target":330,"title":834},[327],[329]," with a more complicated expression than just a variable\nname, for example:",[553,2409,2410],{},[556,2411,2412,606,2415,573,2418,573,2422,830,2425,573,2428,573,2431,2434,2436,2440,2442],{},[559,2413,1050],{"className":2414},[562,944],[559,2416,435],{"className":2417},[562,571],[559,2419,2421],{"className":2420},[562,571],"+",[559,2423,443],{"className":2424},[562,571],[559,2426,834],{"className":2427},[562,571],[559,2429,838],{"className":2430},[562,571],[559,2432,1221],{"className":2433},[562,668],[566,2435],{},[559,2437,2439],{"className":2438},[562,563],";; prints the sum of the x and y coordinates of",[566,2441],{},[559,2443,2445],{"className":2444},[562,563],";; turtle with who number 5",[22,2447,2448],{},[281,2449,2450],{},"Local variables",[22,2452,2453,2454,2462,2463,2465],{},"A local variable is defined and used only in the context of a particular\nprocedure or part of a procedure. To create a local variable, use the ",[319,2455,2457],{"displayText":2456,"permalink":2456},"let",[16,2458,2456],{"href":2459,"rel":2460,"className":2461,"dataDisplayText":2456,"target":330,"title":2456},"/dictionary#let",[327],[329],"\ncommand. If you use ",[556,2464,2456],{}," at the top of a procedure, the variable will exist\nthroughout the procedure. If you use it inside a set of square brackets, for\nexample inside an “ask”, then it will exist only inside those brackets.",[553,2467,2468],{},[556,2469,2470,573,2473,606,2477,573,2481,620,2485,1751,2487,573,2490,606,2494,830,2497,573,2500,2503,1751,2505,573,2508,951,2511,573,2514,606,2517,830,2520,573,2523,958,2526,1751,2528,573,2531,951,2534,573,2537,573,2540,958,2543],{},[559,2471,1744],{"className":2472},[562,1190],[559,2474,2476],{"className":2475},[562,1001],"swap-colors",[559,2478,2480],{"className":2479},[562,1001],"turtle1",[559,2482,2484],{"className":2483},[562,1001],"turtle2",[566,2486],{},[559,2488,2456],{"className":2489},[562,944],[559,2491,2493],{"className":2492},[562,1001],"temp",[559,2495,610],{"className":2496},[562,571],[559,2498,834],{"className":2499},[562,571],[559,2501,2480],{"className":2502},[562,1001],[566,2504],{},[559,2506,128],{"className":2507},[562,944],[559,2509,2480],{"className":2510},[562,1001],[559,2512,1230],{"className":2513},[562,944],[559,2515,610],{"className":2516},[562,571],[559,2518,610],{"className":2519},[562,571],[559,2521,834],{"className":2522},[562,571],[559,2524,2484],{"className":2525},[562,1001],[566,2527],{},[559,2529,128],{"className":2530},[562,944],[559,2532,2484],{"className":2533},[562,1001],[559,2535,1230],{"className":2536},[562,944],[559,2538,610],{"className":2539},[562,571],[559,2541,2493],{"className":2542},[562,1001],[559,2544,2546,1825],{"className":2545},[562,1190],[566,2547],{},[270,2549,2551],{"id":296,"className":2550},[14],[16,2552,84],{"className":2553,"href":83},[19],[22,2555,2556],{},"A link is an agent that connects two turtles. These turtles are sometimes also\ncalled nodes.",[22,2558,2559],{},"The link is always drawn as a line between the two turtles. Links do not have a\nlocation as turtles do, they are not considered to be on any patch and you\ncannot find the distance from a link to another point.",[22,2561,2562,2563,2566,2567,2570,2571,2574,2575,2577,2578,2580],{},"There are two link designations: undirected and directed. A directed link is\n",[467,2564,2565],{},"out"," of, or ",[467,2568,2569],{},"from",", one node and ",[467,2572,2573],{},"into",", or ",[467,2576,1744],{},", another node. The\nrelationship of a parent to a child could be modeled as a directed link. An\nundirected link appears the same to both nodes, each node has a link ",[467,2579,605],{},"\nanother node. The relationship between spouses, or siblings, could be modeled as\nan undirected link.",[22,2582,2583,2584,331,2591,2598,2599,290,2606,396,2613,1573,2620,2627],{},"There is a global agentset of all links, just as with turtles and patches. You\ncan create undirected links using the ",[319,2585,2587],{"displayText":2586,"permalink":1913},"create-link-with",[16,2588,2586],{"href":1916,"rel":2589,"className":2590,"dataDisplayText":2586,"target":330,"title":2586},[327],[329],[319,2592,2594],{"displayText":2593,"permalink":1913},"create-links-with",[16,2595,2593],{"href":1916,"rel":2596,"className":2597,"dataDisplayText":2593,"target":330,"title":2593},[327],[329]," commands; and directed links using the\n",[319,2600,2602],{"displayText":2601,"permalink":1913},"create-link-to",[16,2603,2601],{"href":1916,"rel":2604,"className":2605,"dataDisplayText":2601,"target":330,"title":2601},[327],[329],[319,2607,2609],{"displayText":2608,"permalink":1913},"create-links-to",[16,2610,2608],{"href":1916,"rel":2611,"className":2612,"dataDisplayText":2608,"target":330,"title":2608},[327],[329],[319,2614,2616],{"displayText":2615,"permalink":1913},"create-link-from",[16,2617,2615],{"href":1916,"rel":2618,"className":2619,"dataDisplayText":2615,"target":330,"title":2615},[327],[329],[319,2621,2623],{"displayText":2622,"permalink":1913},"create-links-from",[16,2624,2622],{"href":1916,"rel":2625,"className":2626,"dataDisplayText":2622,"target":330,"title":2622},[327],[329],"\ncommands. Once the first link has been created directed or undirected, all\nunbreeded links must match (links also support breeds, much like turtles, which\nwill be discussed shortly); it’s impossible to have two unbreeded links where\none is directed and the other is undirected. A runtime error occurs if you try\nto do it. (If all unbreeded links die, then you can create links of that breed\nthat are different in designation from the previous links.)",[22,2629,2630],{},"In general, link primitive names indicate what kind of links they deal with:",[44,2632,2633,2642,2651],{},[47,2634,2635,2636,2638,2639,2641],{},"Primitives that have “out” in their name utilize outgoing and undirected\nlinks. You can think of these as “the links I can use to get ",[467,2637,2569],{}," the\ncurrent node ",[467,2640,1744],{}," other nodes.” In general, these are probably the primitives\nyou want to use.",[47,2643,2644,2645,2647,2648,2650],{},"Primitives that have “in” in their name utilize incoming and undirected links.\nYou can think of these as “the links I can use to get ",[467,2646,1744],{}," the current node\n",[467,2649,2569],{}," other nodes.”",[47,2652,2653,2654,2656],{},"Primtives that do not specify “in” or “out”, or have “with” in their name\nutilize ",[467,2655,1177],{}," links, both undirected and directed, incoming and outgoing.",[22,2658,2659,2660,409,2663,2666],{},"A link’s ",[556,2661,2662],{},"end1",[556,2664,2665],{},"end2"," variables contain the two turtles the link connects.\nIf the link is directed, it goes from end1 to end2. If the link is undirected,\nend1 is always the older of the two turtles, that is, the turtle with the\nsmaller who number.",[22,2668,2669,2670,409,2676,2682,2683,409,2690,2697,2698,396,2705,290,2712,2719,2720,2727],{},"Link breeds, like turtle breeds, allow you to define different types of links in\nyour model. Link breeds must either be directed or undirected, unlike unbreeded\nlinks this is defined at compile time rather than run time. You declare link\nbreeds using the keywords ",[319,2671,2672],{"displayText":1858,"permalink":1858},[16,2673,1858],{"href":1861,"rel":2674,"className":2675,"dataDisplayText":1858,"target":330,"title":1858},[327],[329],[319,2677,2678],{"displayText":1850,"permalink":1850},[16,2679,1850],{"href":1853,"rel":2680,"className":2681,"dataDisplayText":1850,"target":330,"title":1850},[327],[329],".\nBreeded links can be created using the commands\n",[319,2684,2686],{"displayText":2685,"permalink":1913},"create-\u003Cbreed>-with",[16,2687,2685],{"href":1916,"rel":2688,"className":2689,"dataDisplayText":2685,"target":330,"title":2685},[327],[329],[319,2691,2693],{"displayText":2692,"permalink":1913},"create-\u003Cbreeds>-with",[16,2694,2692],{"href":1916,"rel":2695,"className":2696,"dataDisplayText":2692,"target":330,"title":2692},[327],[329]," for\nundirected breeds and the commands ",[319,2699,2701],{"displayText":2700,"permalink":1913},"create-\u003Cbreed>-to",[16,2702,2700],{"href":1916,"rel":2703,"className":2704,"dataDisplayText":2700,"target":330,"title":2700},[327],[329],[319,2706,2708],{"displayText":2707,"permalink":1913},"create-\u003Cbreeds>-to",[16,2709,2707],{"href":1916,"rel":2710,"className":2711,"dataDisplayText":2707,"target":330,"title":2707},[327],[329],[319,2713,2715],{"displayText":2714,"permalink":1913},"create-\u003Cbreed>-from",[16,2716,2714],{"href":1916,"rel":2717,"className":2718,"dataDisplayText":2714,"target":330,"title":2714},[327],[329],", and\n",[319,2721,2723],{"displayText":2722,"permalink":1913},"create-\u003Cbreeds>-from",[16,2724,2722],{"href":1916,"rel":2725,"className":2726,"dataDisplayText":2722,"target":330,"title":2722},[327],[329]," for directed links.",[22,2729,2730],{},"There cannot be more than one undirected link of the same breed (or more than\none unbreeded undirected link) between a pair of agents, nor more than one\ndirected link of the same breed in the same direction between a pair of agents.\nYou can have two directed links of the same breed (or two unbreeded directed\nlinks) between a pair if they are in opposite directions.",[22,2732,2733],{},[281,2734,2735],{},"Layouts",[22,2737,2738,2739,2747,2748],{},"As part of our network support we have also added several different primitives\nthat will help you to visualize the networks. The simplest is ",[319,2740,2742],{"displayText":2741,"permalink":2741},"layout-circle",[16,2743,2741],{"href":2744,"rel":2745,"className":2746,"dataDisplayText":2741,"target":330,"title":2741},"/dictionary#layout-circle",[327],[329],"\nwhich evenly spaces the agents around the center of the world given a radius.\n",[2749,2750],"img",{"alt":2751,"className":2752,"src":2754,"width":2755,"height":2755,"style":2756},"programming/circle-layout.png",[2753],"netlogo-image","/_content/images/programming/circle-layout.png",245,{"aspectRatio":2757},"245/245",[22,2759,2760,2768,2769,2775,2776,2782,2783,2789,2790],{},[319,2761,2763],{"displayText":2762,"permalink":2762},"layout-radial",[16,2764,2762],{"href":2765,"rel":2766,"className":2767,"dataDisplayText":2762,"target":330,"title":2762},"/dictionary#layout-radial",[327],[329]," is a good layout if you have something like a tree structure,\nthough even if there are some cycles in the tree it will still work, though as\nthere are more and more cycles it will probably not look as good.\n",[319,2770,2771],{"displayText":2762,"permalink":2762},[16,2772,2762],{"href":2765,"rel":2773,"className":2774,"dataDisplayText":2762,"target":330,"title":2762},[327],[329]," takes a root agent to be the central node places it at (0,0)\nand arranges the nodes connected to it in a concentric pattern. Nodes one degree\naway from the root will be arranged in a circular pattern around the central\nnode and the next level around those nodes and so on. ",[319,2777,2778],{"displayText":2762,"permalink":2762},[16,2779,2762],{"href":2765,"rel":2780,"className":2781,"dataDisplayText":2762,"target":330,"title":2762},[327],[329]," will\nattempt to account for asymmetrical graphs and give more space to branches that\nare wider. ",[319,2784,2785],{"displayText":2762,"permalink":2762},[16,2786,2762],{"href":2765,"rel":2787,"className":2788,"dataDisplayText":2762,"target":330,"title":2762},[327],[329]," also takes a breed as an input so you use one breed\nof links to layout the network and not another. ",[2749,2791],{"alt":2792,"className":2793,"src":2794,"width":2755,"height":2755,"style":2795},"programming/radial-layout.png",[2753],"/_content/images/programming/radial-layout.png",{"aspectRatio":2757},[22,2797,2798,2799,2807,2808],{},"Given a set of anchor nodes ",[319,2800,2802],{"displayText":2801,"permalink":2801},"layout-tutte",[16,2803,2801],{"href":2804,"rel":2805,"className":2806,"dataDisplayText":2801,"target":330,"title":2801},"/dictionary#layout-tutte",[327],[329]," places all the other nodes at the\ncenter of mass of the nodes it is linked to. The anchor set is automatically\narranged in a circle layout with a user defined radius and the other nodes will\nconverge into place (this of course means that you may have to run it several\ntimes before the layout is stable.) ",[2749,2809],{"alt":2810,"className":2811,"src":2812,"width":2755,"height":2755,"style":2813},"programming/tutte-layout.png",[2753],"/_content/images/programming/tutte-layout.png",{"aspectRatio":2757},[22,2815,2816,2824],{},[319,2817,2819],{"displayText":2818,"permalink":2818},"layout-spring",[16,2820,2818],{"href":2821,"rel":2822,"className":2823,"dataDisplayText":2818,"target":330,"title":2818},"/dictionary#layout-spring",[327],[329]," is useful for many kinds of networks. The drawback is that is\nrelatively slow since it takes many iterations to converge. In this layout the\nlinks act as springs that pull the nodes they connect toward each other and the\nnodes repel each other. The strength of the forces is controlled by inputs to\nthe primitives. These inputs will always have a value between 0 and 1; keep in\nmind that very small changes can still affect the appearance of the network. The\nsprings also have a length (in patch units), however, because of all the forces\ninvolved the nodes will not end up exactly that distance from each other.",[1414,2826,2827],{},[22,2828,2829,2832],{},[281,2830,2831],{},"Code Examples:"," Network Example, Network Import Example, Giant Component,\nSmall Worlds, Preferential Attachment",[270,2834,2837],{"id":2835,"className":2836},"tie",[14],[16,2838,90],{"className":2839,"href":89},[19],[22,2841,2842],{},"Tie connects two turtles so that the movement of one turtles affects the\nlocation and heading of another. Tie is a property of links so there must be a\nlink between two turtles to create a tie relationship.",[22,2844,2845,2846,2854,2855,409,2862,2869,2870,2876,2877,2883,2884,2890,2891,396,2900,290,2908,2916,2917,2923,2924,2930,2931,301],{},"When a link’s ",[319,2847,2849],{"displayText":2848,"permalink":2848},"tie-mode",[16,2850,2848],{"href":2851,"rel":2852,"className":2853,"dataDisplayText":2848,"target":330,"title":2848},"/dictionary#tie-mode",[327],[329]," is set to “fixed” or “free” ",[319,2856,2857],{"displayText":2662,"permalink":2662},[16,2858,2662],{"href":2859,"rel":2860,"className":2861,"dataDisplayText":2662,"target":330,"title":2662},"/dictionary#end1",[327],[329],[319,2863,2864],{"displayText":2665,"permalink":2665},[16,2865,2665],{"href":2866,"rel":2867,"className":2868,"dataDisplayText":2665,"target":330,"title":2665},"/dictionary#end2",[327],[329]," are\ntied together. If the link is directed ",[319,2871,2872],{"displayText":2662,"permalink":2662},[16,2873,2662],{"href":2859,"rel":2874,"className":2875,"dataDisplayText":2662,"target":330,"title":2662},[327],[329]," is the “root agent” and ",[319,2878,2879],{"displayText":2665,"permalink":2665},[16,2880,2665],{"href":2866,"rel":2881,"className":2882,"dataDisplayText":2665,"target":330,"title":2665},[327],[329],"\nis the “leaf agent”. That is when ",[319,2885,2886],{"displayText":2662,"permalink":2662},[16,2887,2662],{"href":2859,"rel":2888,"className":2889,"dataDisplayText":2662,"target":330,"title":2662},[327],[329]," moves (using ",[319,2892,2895],{"displayText":2893,"permalink":2894},"fd","forward",[16,2896,2893],{"href":2897,"rel":2898,"className":2899,"dataDisplayText":2893,"target":330,"title":2893},"/dictionary#forward",[327],[329],[319,2901,2903],{"displayText":2902,"permalink":2902},"jump",[16,2904,2902],{"href":2905,"rel":2906,"className":2907,"dataDisplayText":2902,"target":330,"title":2902},"/dictionary#jump",[327],[329],[319,2909,2911],{"displayText":2910,"permalink":2910},"setxy",[16,2912,2910],{"href":2913,"rel":2914,"className":2915,"dataDisplayText":2910,"target":330,"title":2910},"/dictionary#setxy",[327],[329],", etc.) ",[319,2918,2919],{"displayText":2665,"permalink":2665},[16,2920,2665],{"href":2866,"rel":2921,"className":2922,"dataDisplayText":2665,"target":330,"title":2665},[327],[329]," also moves the same distance and direction.\nHowever when ",[319,2925,2926],{"displayText":2665,"permalink":2665},[16,2927,2665],{"href":2866,"rel":2928,"className":2929,"dataDisplayText":2665,"target":330,"title":2665},[327],[329]," moves it does not affect ",[319,2932,2933],{"displayText":2662,"permalink":2662},[16,2934,2662],{"href":2859,"rel":2935,"className":2936,"dataDisplayText":2662,"target":330,"title":2662},[327],[329],[22,2938,2939],{},"If the link is undirected it is a reciprocal tie relationship, meaning, if\neither turtle moves the other turtle will also move. So depending on which\nturtle is moving either turtle can be considered the root or the leaf. The root\nturtle is always the turtle that initiates the movement.",[22,2941,2942,2943,2949,2950,2956],{},"When the root turtle turns right or left, the leaf turtle rotates around the\nroot turtle the same amount as if a stiff were attaching the turtles. When\n",[319,2944,2945],{"displayText":2848,"permalink":2848},[16,2946,2848],{"href":2851,"rel":2947,"className":2948,"dataDisplayText":2848,"target":330,"title":2848},[327],[329]," is set to “fixed” the heading of the leaf turtle changes by the\nsame amount. If the ",[319,2951,2952],{"displayText":2848,"permalink":2848},[16,2953,2848],{"href":2851,"rel":2954,"className":2955,"dataDisplayText":2848,"target":330,"title":2848},[327],[329]," is set to “free” the heading of the leaf turtle\nis unchanged.",[22,2958,1376,2959,2965,2966,2973,2974,2982,2983,301],{},[319,2960,2961],{"displayText":2848,"permalink":2848},[16,2962,2848],{"href":2851,"rel":2963,"className":2964,"dataDisplayText":2848,"target":330,"title":2848},[327],[329]," of a link can be set to “fixed” using the ",[319,2967,2968],{"displayText":2835,"permalink":2835},[16,2969,2835],{"href":2970,"rel":2971,"className":2972,"dataDisplayText":2835,"target":330,"title":2835},"/dictionary#tie",[327],[329]," command and\nset to “none” (meaning the turtles are no longer tied) using ",[319,2975,2977],{"displayText":2976,"permalink":2976},"untie",[16,2978,2976],{"href":2979,"rel":2980,"className":2981,"dataDisplayText":2976,"target":330,"title":2976},"/dictionary#untie",[327],[329]," to set\nthe mode to “free” you need to: ",[556,2984,2985,573,2988,573,2991],{},[559,2986,1230],{"className":2987},[562,944],[559,2989,2848],{"className":2990},[562,571],[559,2992,2995],{"className":2993},[562,2994],"string","\"free\"",[1414,2997,2998],{},[22,2999,3000,3002],{},[281,3001,1420],{}," Tie System Example",[270,3004,3007],{"id":3005,"className":3006},"drawing",[14],[16,3008,96],{"className":3009,"href":95},[19],[22,3011,3012],{},"The drawing is a layer where turtles can make visible marks.",[22,3014,3015],{},"In the view, the drawing appears on top of the patches but underneath the\nturtles. Initially, the drawing is empty and transparent.",[22,3017,3018],{},"You can see the drawing, but the turtles (and patches) can’t. They can’t sense\nthe drawing or react to it. The drawing is just for people to look at.",[22,3020,3021,3022,409,3031,3038,3039,301],{},"Turtles can draw and erase lines in the drawing using the\n",[319,3023,3026],{"displayText":3024,"permalink":3025},"pen-down","pen-switch-status",[16,3027,3024],{"href":3028,"rel":3029,"className":3030,"dataDisplayText":3024,"target":330,"title":3024},"/dictionary#pen-switch-status",[327],[329],[319,3032,3034],{"displayText":3033,"permalink":3025},"pen-erase",[16,3035,3033],{"href":3028,"rel":3036,"className":3037,"dataDisplayText":3033,"target":330,"title":3033},[327],[329]," commands.\nWhen a turtle’s pen is down (or erasing), the turtle draws (or erases) a line\nbehind it whenever it moves. The lines are the same color as the turtle. To stop\ndrawing (or erasing), use ",[319,3040,3042],{"displayText":3041,"permalink":3025},"pen-up",[16,3043,3041],{"href":3028,"rel":3044,"className":3045,"dataDisplayText":3041,"target":330,"title":3041},[327],[329],[22,3047,3048,3049,3057],{},"Lines drawn by turtles are normally one pixel thick. If you want a different\nthickness, set the ",[319,3050,3052],{"displayText":3051,"permalink":3051},"pen-size",[16,3053,3051],{"href":3054,"rel":3055,"className":3056,"dataDisplayText":3051,"target":330,"title":3051},"/dictionary#pen-size",[327],[329]," turtle variable to a different number before\ndrawing (or erasing). In new turtles, the variable is set to 1.",[22,3059,3060,3061,530,3067,3075],{},"Lines made when a turtle moves in a way that doesn’t fix a direction, such as\nwith ",[319,3062,3063],{"displayText":2910,"permalink":2910},[16,3064,2910],{"href":2913,"rel":3065,"className":3066,"dataDisplayText":2910,"target":330,"title":2910},[327],[329],[319,3068,3070],{"displayText":3069,"permalink":3069},"move-to",[16,3071,3069],{"href":3072,"rel":3073,"className":3074,"dataDisplayText":3069,"target":330,"title":3069},"/dictionary#move-to",[327],[329],", the shortest path line that obeys the topology\nwill be drawn.",[22,3077,3078,3079,3085,3086],{},"Here’s some turtles which have made a drawing over a grid of randomly shaded\npatches. Notice how the turtles cover the lines and the lines cover the patch\ncolors. The ",[319,3080,3081],{"displayText":3051,"permalink":3051},[16,3082,3051],{"href":3054,"rel":3083,"className":3084,"dataDisplayText":3051,"target":330,"title":3051},[327],[329]," used here was 2: ",[2749,3087],{"alt":3088,"className":3089,"src":3090,"width":3091,"height":3091,"style":3092},"color chart",[2753],"/_content/images/programming/drawing.png",252,{"aspectRatio":3093},"252/252",[22,3095,1376,3096,3104,3105,3113],{},[319,3097,3099],{"displayText":3098,"permalink":3098},"stamp",[16,3100,3098],{"href":3101,"rel":3102,"className":3103,"dataDisplayText":3098,"target":330,"title":3098},"/dictionary#stamp",[327],[329]," command lets a turtle leave an image of itself behind in the\ndrawing and ",[319,3106,3108],{"displayText":3107,"permalink":3107},"stamp-erase",[16,3109,3107],{"href":3110,"rel":3111,"className":3112,"dataDisplayText":3107,"target":330,"title":3107},"/dictionary#stamp-erase",[327],[329]," lets it remove the pixels below it in the drawing.",[22,3115,3116,3117,3125,3126,3133],{},"To erase the whole drawing, use the observer commmand ",[319,3118,3120],{"displayText":3119,"permalink":3119},"clear-drawing",[16,3121,3119],{"href":3122,"rel":3123,"className":3124,"dataDisplayText":3119,"target":330,"title":3119},"/dictionary#clear-drawing",[327],[329],". (You\ncan also use ",[319,3127,3128],{"displayText":1208,"permalink":1208},[16,3129,1208],{"href":3130,"rel":3131,"className":3132,"dataDisplayText":1208,"target":330,"title":1208},"/dictionary#clear-all",[327],[329],", which clears everything else too.)",[22,3135,3136],{},[281,3137,3138],{},"Importing an image",[22,3140,3141,3142,3150],{},"The observer command ",[319,3143,3145],{"displayText":3144,"permalink":3144},"import-drawing",[16,3146,3144],{"href":3147,"rel":3148,"className":3149,"dataDisplayText":3144,"target":330,"title":3144},"/dictionary#import-drawing",[327],[329]," command allows you to import an image\nfile from disk into the drawing.",[22,3152,3153,3159,3160,530,3168,3176],{},[319,3154,3155],{"displayText":3144,"permalink":3144},[16,3156,3144],{"href":3147,"rel":3157,"className":3158,"dataDisplayText":3144,"target":330,"title":3144},[327],[329]," is useful only for providing a backdrop for people to look\nat. If you want turtles and patches to react to the image, you should use\n",[319,3161,3163],{"displayText":3162,"permalink":3162},"import-pcolors",[16,3164,3162],{"href":3165,"rel":3166,"className":3167,"dataDisplayText":3162,"target":330,"title":3162},"/dictionary#import-pcolors",[327],[329],[319,3169,3171],{"displayText":3170,"permalink":3170},"import-pcolors-rgb",[16,3172,3170],{"href":3173,"rel":3174,"className":3175,"dataDisplayText":3170,"target":330,"title":3170},"/dictionary#import-pcolors-rgb",[327],[329]," instead.",[22,3178,3179],{},[281,3180,3181],{},"Comparison to other Logos",[22,3183,3184],{},"Drawing works somewhat differently in NetLogo than some other Logos.",[22,3186,3187],{},"Notable differences include:",[44,3189,3190,3193,3200],{},[47,3191,3192],{},"New turtles’ pens are up, not down.",[47,3194,3195,3196,3199],{},"Instead of using a ",[556,3197,3198],{},"fence"," command to confine the turtle inside boundaries, in\nNetLogo you edit the world and turn wrapping off.",[47,3201,3202,3203,290,3206,2574,3209,3212,3213,301],{},"There is no ",[556,3204,3205],{},"screen-color",[556,3207,3208],{},"bgcolor",[556,3210,3211],{},"setbg",". You can make a solid\nbackground by coloring the patches, e.g. ",[556,3214,3215,573,3218,951,3221,573,3224,573,3227,958],{},[559,3216,128],{"className":3217},[562,944],[559,3219,293],{"className":3220},[562,571],[559,3222,1230],{"className":3223},[562,944],[559,3225,794],{"className":3226},[562,571],[559,3228,3230],{"className":3229},[562,618],"blue",[22,3232,3233],{},"Drawing features not supported by NetLogo:",[44,3235,3236,3242],{},[47,3237,3202,3238,3241],{},[556,3239,3240],{},"window"," command. This is used in some other Logos to let the\nturtle roam over an infinite plane.",[47,3243,3202,3244,530,3247,3250],{},[556,3245,3246],{},"flood",[556,3248,3249],{},"fill"," command to fill an enclosed area with color.",[270,3252,3255],{"id":3253,"className":3254},"turtle-shapes",[14],[16,3256,102],{"className":3257,"href":101},[19],[22,3259,3260],{},"In NetLogo, turtle shapes are vector shapes. They are built up from basic\ngeometric shapes; squares, circles, and lines, rather than a grid of pixels.\nVector shapes are fully scalable and rotatable. NetLogo caches bitmap images of\nvector shapes size 1, 1.5, and 2 in order to speed up execution.",[22,3262,3263,3264,3272,3273,3279],{},"A turtle’s shape is stored in its ",[319,3265,3267],{"displayText":3266,"permalink":3266},"shape",[16,3268,3266],{"href":3269,"rel":3270,"className":3271,"dataDisplayText":3266,"target":330,"title":3266},"/dictionary#shape",[327],[329]," variable and can be set using the\n",[319,3274,3275],{"displayText":1230,"permalink":1230},[16,3276,1230],{"href":2334,"rel":3277,"className":3278,"dataDisplayText":1230,"target":330,"title":1230},[327],[329]," command.",[22,3281,3282,3283,3289],{},"New turtles have a shape of “default”. The ",[319,3284,3285],{"displayText":1659,"permalink":1659},[16,3286,1659],{"href":1662,"rel":3287,"className":3288,"dataDisplayText":1659,"target":330,"title":1659},[327],[329]," primitive is\nuseful for changing the default turtle shape to a different shape, or having a\ndifferent default turtle shape for each breed of turtle.",[22,3291,1376,3292,3300],{},[319,3293,3295],{"displayText":3294,"permalink":3294},"shapes",[16,3296,3294],{"href":3297,"rel":3298,"className":3299,"dataDisplayText":3294,"target":330,"title":3294},"/dictionary#shapes",[327],[329]," primitive reports a list of currently available turtle shapes in\nthe model. This is useful if, for example, you want to assign a random shape to\na turtle:",[553,3302,3303],{},[556,3304,3305,573,3308,951,3311,573,3314,573,3317,573,3320,958],{},[559,3306,128],{"className":3307},[562,944],[559,3309,289],{"className":3310},[562,571],[559,3312,1230],{"className":3313},[562,944],[559,3315,3266],{"className":3316},[562,571],[559,3318,911],{"className":3319},[562,571],[559,3321,3294],{"className":3322},[562,571],[22,3324,3325,3326,3329],{},"Use the Turtle Shapes Editor to create your own turtle shapes, or to add shapes\nto your model from our shapes library, or to transfer shapes between models. For\nmore information, see the Shapes Editor ",[16,3327,3328],{"href":3294},"section"," of this manual.",[22,3331,3332,3333,3341],{},"The thickness of the lines used to draw the vector shapes can be controlled by\nthe ",[319,3334,3336],{"displayText":3335,"permalink":3335},"__set-line-thickness",[16,3337,3335],{"href":3338,"rel":3339,"className":3340,"dataDisplayText":3335,"target":330,"title":3335},"/dictionary#__set-line-thickness",[327],[329]," primitive.",[1414,3343,3344],{},[22,3345,3346,3348],{},[281,3347,2831],{}," Breeds and Shapes Example, Shape Animation Example",[270,3350,3353],{"id":3351,"className":3352},"link-shapes",[14],[16,3354,108],{"className":3355,"href":107},[19],[22,3357,3358,3359,3365,3366,3372,3373,3380],{},"Link Shapes are similar to turtle shapes, only you use the Link Shape Editor to\ncreate and edit them. Link shapes consist of between 0 and 3 lines which can\nhave different patterns and a direction indicator that is composed of the same\nelements as turtle shapes. Links also have a ",[319,3360,3361],{"displayText":3266,"permalink":3266},[16,3362,3266],{"href":3269,"rel":3363,"className":3364,"dataDisplayText":3266,"target":330,"title":3266},[327],[329]," variable that can be set\nto any link shape that is in the model. By default links have the “default”\nshape, though you can change that using ",[319,3367,3368],{"displayText":1659,"permalink":1659},[16,3369,1659],{"href":1662,"rel":3370,"className":3371,"dataDisplayText":1659,"target":330,"title":1659},[327],[329],". The\n",[319,3374,3375],{"displayText":3351,"permalink":3351},[16,3376,3351],{"href":3377,"rel":3378,"className":3379,"dataDisplayText":3351,"target":330,"title":3351},"/dictionary#link-shapes",[327],[329]," reporter reports all the link shapes included in the current\nmodel.",[22,3382,3383,3384,3392],{},"The thickness of the lines in the link shape is controlled by the ",[319,3385,3387],{"displayText":3386,"permalink":3386},"thickness",[16,3388,3386],{"href":3389,"rel":3390,"className":3391,"dataDisplayText":3386,"target":330,"title":3386},"/dictionary#thickness",[327],[329],"\nlink variable.",[262,3394,3397],{"id":3395,"className":3396},"programming",[14],[16,3398,114],{"className":3399,"href":113},[19],[270,3401,3404],{"id":3402,"className":3403},"procedures",[14],[16,3405,122],{"className":3406,"href":121},[19],[22,3408,3409,3410,409,3413,3416],{},"In NetLogo, ",[281,3411,3412],{},"commands",[281,3414,3415],{},"reporters"," tell agents what to do. A command is\nan action for an agent to carry out, resulting in some effect. A reporter is\ninstructions for computing a value, which the agent then “reports” to whoever\nasked it.",[22,3418,3419],{},"Typically, a command name begins with a verb, such as “create”, “die”, “jump”,\n“inspect”, or “clear”. Most reporter names are nouns or noun phrases.",[22,3421,3422,3423,3426,3427,3431],{},"Commands and reporters built into NetLogo are called ",[281,3424,3425],{},"primitives",".\n",[16,3428,3430],{"href":3429},"dictionary","The NetLogo Dictionary"," has a complete list of built-in\ncommands and reporters.",[22,3433,3434,3435,3437,3438,530,3445,3453,3454,3461],{},"Commands and reporters you define yourself are called ",[281,3436,3402],{},". Each\nprocedure has a name, preceded by the keyword ",[319,3439,3440],{"displayText":1744,"permalink":1744},[16,3441,1744],{"href":3442,"rel":3443,"className":3444,"dataDisplayText":1744,"target":330,"title":1744},"/dictionary#to",[327],[329],[319,3446,3448],{"displayText":3447,"permalink":3447},"to-report",[16,3449,3447],{"href":3450,"rel":3451,"className":3452,"dataDisplayText":3447,"target":330,"title":3447},"/dictionary#to-report",[327],[329],", depending\non whether it is a command procedure or a reporter procedure. The keyword\n",[319,3455,3456],{"displayText":1825,"permalink":1825},[16,3457,1825],{"href":3458,"rel":3459,"className":3460,"dataDisplayText":1825,"target":330,"title":1825},"/dictionary#end",[327],[329]," marks the end of the commands in the procedure. Once you define a\nprocedure, you can use it elsewhere in your program.",[22,3463,3464,3465,3468],{},"Many commands and reporters take ",[281,3466,3467],{},"inputs"," — values that the command or\nreporter uses in carrying out its actions or computing its result.",[22,3470,3471],{},"Here are two command procedures:",[553,3473,3474],{},[556,3475,3476,573,3479,3482,1751,3484,3487,1751,3489,573,3492,3495,1751,3497,3500,3505,3507,573,3512,3516,1751,3518,573,3521,606,3524,940,3526,573,3529,3532,3533,3537,940,3539,573,3543,573,3546,940,3549,3553,940,3555,573,3559,573,3562,940,3565,3569,3571,3572,1751,3574,3578],{},[559,3477,1744],{"className":3478},[562,1190],[559,3480,1748],{"className":3481},[562,1001],[566,3483],{},[559,3485,1208],{"className":3486},[562,944],[566,3488],{},[559,3490,1217],{"className":3491},[562,944],[559,3493,1287],{"className":3494},[562,668],[566,3496],{},[559,3498,1819],{"className":3499},[562,944],[559,3501,3503,1825],{"className":3502},[562,1190],[566,3504],{},[566,3506],{},[559,3508,3510,1744],{"className":3509},[562,1190],[566,3511],{},[559,3513,3515],{"className":3514},[562,1001],"go",[566,3517],{},[559,3519,128],{"className":3520},[562,944],[559,3522,289],{"className":3523},[562,571],[566,3525],{},[559,3527,2893],{"className":3528},[562,944],[559,3530,708],{"className":3531},[562,668],"            ",[559,3534,3536],{"className":3535},[562,563],";; forward 1 step",[566,3538],{},[559,3540,3542],{"className":3541},[562,944],"rt",[559,3544,1790],{"className":3545},[562,571],[559,3547,1287],{"className":3548},[562,668],[559,3550,3552],{"className":3551},[562,563],";; turn right",[566,3554],{},[559,3556,3558],{"className":3557},[562,944],"lt",[559,3560,1790],{"className":3561},[562,571],[559,3563,1287],{"className":3564},[562,668],[559,3566,3568],{"className":3567},[562,563],";; turn left",[566,3570],{},"  ]",[566,3573],{},[559,3575,3577],{"className":3576},[562,944],"tick",[559,3579,3581,1825],{"className":3580},[562,1190],[566,3582],{},[22,3584,3585],{},"Note the use of semicolons to add “comments” to the program. Comments can make\nyour code easier to read and understand, but they don’t affect its behavior.",[22,3587,3588],{},"In this program,",[44,3590,3591,3598,3649],{},[47,3592,3593,409,3595,3597],{},[556,3594,1748],{},[556,3596,3515],{}," are user-defined commands.",[47,3599,3600,290,3604,290,3610,290,3617,290,3623,3631,3632,3640,3641,3648],{},[559,3601,3602],{},[559,3603,1208],{},[319,3605,3606],{"displayText":1217,"permalink":1217},[16,3607,1217],{"href":1503,"rel":3608,"className":3609,"dataDisplayText":1217,"target":330,"title":1217},[327],[329],[319,3611,3612],{"displayText":1819,"permalink":1819},[16,3613,1819],{"href":3614,"rel":3615,"className":3616,"dataDisplayText":1819,"target":330,"title":1819},"/dictionary#reset-ticks",[327],[329],[319,3618,3619],{"displayText":128,"permalink":128},[16,3620,128],{"href":515,"rel":3621,"className":3622,"dataDisplayText":128,"target":330,"title":128},[327],[329],[319,3624,3626],{"displayText":3558,"permalink":3625},"left",[16,3627,3558],{"href":3628,"rel":3629,"className":3630,"dataDisplayText":3558,"target":330,"title":3558},"/dictionary#left",[327],[329],"\n(“left turn”), ",[319,3633,3635],{"displayText":3542,"permalink":3634},"right",[16,3636,3542],{"href":3637,"rel":3638,"className":3639,"dataDisplayText":3542,"target":330,"title":3542},"/dictionary#right",[327],[329]," (“right turn”) and ",[319,3642,3643],{"displayText":3577,"permalink":3577},[16,3644,3577],{"href":3645,"rel":3646,"className":3647,"dataDisplayText":3577,"target":330,"title":3577},"/dictionary#tick",[327],[329],", are all primitive\ncommands.",[47,3650,3651,409,3655,3661,3662,3669,3670,3676],{},[559,3652,3653],{},[559,3654,1790],{},[319,3656,3657],{"displayText":289,"permalink":289},[16,3658,289],{"href":478,"rel":3659,"className":3660,"dataDisplayText":289,"target":330,"title":289},[327],[329]," are primitive reporters. ",[319,3663,3664],{"displayText":1790,"permalink":1790},[16,3665,1790],{"href":3666,"rel":3667,"className":3668,"dataDisplayText":1790,"target":330,"title":1790},"/dictionary#random",[327],[329]," takes a single\nnumber as an input and reports a random integer that is less than the input\n(in this case, between 0 and 9). ",[319,3671,3672],{"displayText":289,"permalink":289},[16,3673,289],{"href":478,"rel":3674,"className":3675,"dataDisplayText":289,"target":330,"title":289},[327],[329]," reports the agentset consisting\nof all the turtles. (We’ll explain about agentsets later.)",[22,3678,3679,409,3681,3683],{},[556,3680,1748],{},[556,3682,3515],{}," can be called by other procedures, or by buttons, or from the\nCommand Center.",[22,3685,3686,3687,3689,3690,301],{},"Many NetLogo models have a once button that calls a procedure called ",[556,3688,1748],{}," and\na forever button that calls a procedure called ",[556,3691,3515],{},[22,3693,3694,3695,3701],{},"In NetLogo, you may specify which agents — turtles, patches, or links — are to\nrun each command. If you don’t specify, the code is run by the observer. In the\ncode above, the observer uses ",[319,3696,3697],{"displayText":128,"permalink":128},[16,3698,128],{"href":515,"rel":3699,"className":3700,"dataDisplayText":128,"target":330,"title":128},[327],[329]," to make the set of all turtles run the\ncommands between the square brackets.",[22,3703,3704,409,3710,3716,3717,3723,3724,409,3730,3738],{},[319,3705,3706],{"displayText":1208,"permalink":1208},[16,3707,1208],{"href":3130,"rel":3708,"className":3709,"dataDisplayText":1208,"target":330,"title":1208},[327],[329],[319,3711,3712],{"displayText":1217,"permalink":1217},[16,3713,1217],{"href":1503,"rel":3714,"className":3715,"dataDisplayText":1217,"target":330,"title":1217},[327],[329]," can only be run by the observer.\n",[319,3718,3719],{"displayText":2893,"permalink":2894},[16,3720,2893],{"href":2897,"rel":3721,"className":3722,"dataDisplayText":2893,"target":330,"title":2893},[327],[329],", on the other hand, can only be run by turtles. Some other\ncommands and reporters, such as ",[319,3725,3726],{"displayText":1230,"permalink":1230},[16,3727,1230],{"href":2334,"rel":3728,"className":3729,"dataDisplayText":1230,"target":330,"title":1230},[327],[329],[319,3731,3733],{"displayText":3732,"permalink":3732},"ticks",[16,3734,3732],{"href":3735,"rel":3736,"className":3737,"dataDisplayText":3732,"target":330,"title":3732},"/dictionary#ticks",[327],[329],", can be run by different\nagent types.",[22,3740,3741],{},"Here are some more advanced features you can take advantage of when defining\nyour own procedures.",[22,3743,3744],{},[281,3745,3746],{},"Procedures with inputs",[22,3748,3749],{},"Procedures can take inputs, just like many primitives do. To create a procedure\nthat accepts inputs, put their names in square brackets after the procedure\nname. For example:",[553,3751,3752],{},[556,3753,3754,573,3757,606,3761,573,3765,3769,3770,3774,1751,3776,3779,1751,3781,573,3785,606,3788,940,3790,573,3793,3796,940,3798,573,3801,573,3805,573,3809,3812,3571,3814],{},[559,3755,1744],{"className":3756},[562,1190],[559,3758,3760],{"className":3759},[562,1001],"draw-polygon",[559,3762,3764],{"className":3763},[562,1001],"num-sides",[559,3766,3768],{"className":3767},[562,1001],"len","]  ",[559,3771,3773],{"className":3772},[562,563],";; turtle procedure",[566,3775],{},[559,3777,3024],{"className":3778},[562,944],[566,3780],{},[559,3782,3784],{"className":3783},[562,944],"repeat",[559,3786,3764],{"className":3787},[562,1001],[566,3789],{},[559,3791,2893],{"className":3792},[562,944],[559,3794,3768],{"className":3795},[562,1001],[566,3797],{},[559,3799,3542],{"className":3800},[562,944],[559,3802,3804],{"className":3803},[562,668],"360",[559,3806,3808],{"className":3807},[562,571],"/",[559,3810,3764],{"className":3811},[562,1001],[566,3813],{},[559,3815,3817,1825],{"className":3816},[562,1190],[566,3818],{},[22,3820,3821],{},"Elsewhere in the program, you might use the procedure by asking the turtles to\neach draw an octagon with a side length equal to its who number:",[553,3823,3824],{},[556,3825,3826,573,3829,951,3832,573,3835,573,3839,958],{},[559,3827,128],{"className":3828},[562,944],[559,3830,289],{"className":3831},[562,571],[559,3833,3760],{"className":3834},[562,1001],[559,3836,3838],{"className":3837},[562,668],"8",[559,3840,3842],{"className":3841},[562,571],"who",[22,3844,3845],{},[281,3846,3847],{},"Reporter procedures",[22,3849,3850,3851,3857,3858,3864,3865,3873],{},"Just like you can define your own commands, you can define your own reporters.\nYou must do two special things. First, use ",[319,3852,3853],{"displayText":3447,"permalink":3447},[16,3854,3447],{"href":3450,"rel":3855,"className":3856,"dataDisplayText":3447,"target":330,"title":3447},[327],[329]," instead of ",[319,3859,3860],{"displayText":1744,"permalink":1744},[16,3861,1744],{"href":3442,"rel":3862,"className":3863,"dataDisplayText":1744,"target":330,"title":1744},[327],[329]," to\nbegin your procedure. Then, in the body of the procedure, use ",[319,3866,3868],{"displayText":3867,"permalink":3867},"report",[16,3869,3867],{"href":3870,"rel":3871,"className":3872,"dataDisplayText":3867,"target":330,"title":3867},"/dictionary#report",[327],[329]," to\nreport the value you want to report.",[553,3875,3876],{},[556,3877,3878,573,3881,606,3885,620,3888,1751,3890,573,3894,573,3897,573,3901,3904,1767,3906,573,3909,958,3912,1767,3914,774,3917,573,3921,3924,3925],{},[559,3879,3447],{"className":3880},[562,1190],[559,3882,3884],{"className":3883},[562,1001],"absolute-value",[559,3886,668],{"className":3887},[562,1001],[566,3889],{},[559,3891,3893],{"className":3892},[562,944],"ifelse",[559,3895,668],{"className":3896},[562,1001],[559,3898,3900],{"className":3899},[562,571],">=",[559,3902,669],{"className":3903},[562,668],[566,3905],{},[559,3907,3867],{"className":3908},[562,944],[559,3910,668],{"className":3911},[562,1001],[566,3913],{},[559,3915,3867],{"className":3916},[562,944],[559,3918,3920],{"className":3919},[562,571],"-",[559,3922,668],{"className":3923},[562,1001],") ]",[559,3926,3928,1825],{"className":3927},[562,1190],[566,3929],{},[270,3931,3933],{"id":128,"className":3932},[14],[16,3934,128],{"className":3935,"href":127},[19],[22,3937,3938,3939,3945,3946,3949],{},"NetLogo uses the ",[319,3940,3941],{"displayText":128,"permalink":128},[16,3942,128],{"href":515,"rel":3943,"className":3944,"dataDisplayText":128,"target":330,"title":128},[327],[329]," command to give commands to turtles, patches, and\nlinks. All code to be run by turtles ",[467,3947,3948],{},"must"," be located in a turtle “context”.\nYou can establish a turtle context in any of three ways:",[44,3951,3952,3955,3958],{},[47,3953,3954],{},"In a button, by choosing “Turtles” from the popup menu. Any code you put in\nthe button will be run by all turtles.",[47,3956,3957],{},"In the Command Center, by choosing “Turtles” from the popup menu. Any commands\nyou enter will be run by all the turtles.",[47,3959,3960,3961,290,3969,3971],{},"By using ",[556,3962,3963,573,3966],{},[559,3964,128],{"className":3965},[562,944],[559,3967,289],{"className":3968},[562,571],[556,3970,1539],{},", or other commands which establish a turtle\ncontext.",[22,3973,3974,3975,3981,3982,3988],{},"The same goes for patches, links, and the observer, except that you cannot\n",[319,3976,3977],{"displayText":128,"permalink":128},[16,3978,128],{"href":515,"rel":3979,"className":3980,"dataDisplayText":128,"target":330,"title":128},[327],[329]," the observer. Any code that is not inside any ",[319,3983,3984],{"displayText":128,"permalink":128},[16,3985,128],{"href":515,"rel":3986,"className":3987,"dataDisplayText":128,"target":330,"title":128},[327],[329]," is by default\nobserver code.",[22,3990,3991,3992,3998,3999,4002],{},"Because agentset members are always read in a random order, when ",[319,3993,3994],{"displayText":128,"permalink":128},[16,3995,128],{"href":515,"rel":3996,"className":3997,"dataDisplayText":128,"target":330,"title":128},[327],[329]," is used\nwith an agentset each agent will take its turn in a random order. See\n",[16,4000,66],{"href":4001},"/programming#agentsets"," for more information.",[22,4004,4005,4006,4012],{},"Here’s an example of the use of ",[319,4007,4008],{"displayText":128,"permalink":128},[16,4009,128],{"href":515,"rel":4010,"className":4011,"dataDisplayText":128,"target":330,"title":128},[327],[329]," in a NetLogo procedure:",[553,4014,4015],{},[556,4016,4017,573,4020,4023,1751,4025,4028,1751,4030,573,4033,4037,4038,4042,1751,4044,573,4047,4050,1767,4052,573,4055,573,4058,940,4061,4065,1780,4067,573,4070,4073,4074,4078,1751,4080,573,4083,4086,1767,4088,573,4091,573,4094,573,4097,4100,4101,4105,4107,4108,573,4111,573,4114,4117,4118,4122,1751,4124,4127],{},[559,4018,1744],{"className":4019},[562,1190],[559,4021,1748],{"className":4022},[562,1001],[566,4024],{},[559,4026,1208],{"className":4027},[562,944],[566,4029],{},[559,4031,1217],{"className":4032},[562,944],[559,4034,4036],{"className":4035},[562,668],"100","   ",[559,4039,4041],{"className":4040},[562,563],";; create 100 turtles with random headings",[566,4043],{},[559,4045,128],{"className":4046},[562,944],[559,4048,289],{"className":4049},[562,571],[566,4051],{},[559,4053,1230],{"className":4054},[562,944],[559,4056,610],{"className":4057},[562,571],[559,4059,619],{"className":4060},[562,618],[559,4062,4064],{"className":4063},[562,563],";; turn them red",[566,4066],{},[559,4068,2893],{"className":4069},[562,944],[559,4071,1764],{"className":4072},[562,668]," ]          ",[559,4075,4077],{"className":4076},[562,563],";; spread them around",[566,4079],{},[559,4081,128],{"className":4082},[562,944],[559,4084,293],{"className":4085},[562,571],[566,4087],{},[559,4089,1615],{"className":4090},[562,944],[559,4092,321],{"className":4093},[562,571],[559,4095,664],{"className":4096},[562,571],[559,4098,669],{"className":4099},[562,668],"         ",[559,4102,4104],{"className":4103},[562,563],";; patches on the right side",[566,4106],{},"        [ ",[559,4109,1230],{"className":4110},[562,944],[559,4112,794],{"className":4113},[562,571],[559,4115,801],{"className":4116},[562,618]," ] ]  ",[559,4119,4121],{"className":4120},[562,563],";; of the view turn green",[566,4123],{},[559,4125,1819],{"className":4126},[562,944],[559,4128,4130,1825],{"className":4129},[562,1190],[566,4131],{},[22,4133,4134],{},"The models in the Models Library are full of other examples. A good place to\nstart looking is in the Code Examples section.",[22,4136,4137,4138,4144,4145,4151,4152,290,4158,290,4166,331,4174,4182],{},"Usually, the observer uses ",[319,4139,4140],{"displayText":128,"permalink":128},[16,4141,128],{"href":515,"rel":4142,"className":4143,"dataDisplayText":128,"target":330,"title":128},[327],[329]," to ask all turtles, all patches or all links\nto run commands. You can also use ",[319,4146,4147],{"displayText":128,"permalink":128},[16,4148,128],{"href":515,"rel":4149,"className":4150,"dataDisplayText":128,"target":330,"title":128},[327],[329]," to have an individual turtle, patch or\nlink run commands. The reporters ",[319,4153,4154],{"displayText":838,"permalink":838},[16,4155,838],{"href":1491,"rel":4156,"className":4157,"dataDisplayText":838,"target":330,"title":838},[327],[329],[319,4159,4161],{"displayText":4160,"permalink":4160},"patch",[16,4162,4160],{"href":4163,"rel":4164,"className":4165,"dataDisplayText":4160,"target":330,"title":4160},"/dictionary#patch",[327],[329],[319,4167,4169],{"displayText":4168,"permalink":4168},"link",[16,4170,4168],{"href":4171,"rel":4172,"className":4173,"dataDisplayText":4168,"target":330,"title":4168},"/dictionary#link",[327],[329],[319,4175,4177],{"displayText":4176,"permalink":4176},"patch-at",[16,4178,4176],{"href":4179,"rel":4180,"className":4181,"dataDisplayText":4176,"target":330,"title":4176},"/dictionary#patch-at",[327],[329]," are useful for this technique. For example:",[553,4184,4185],{},[556,4186,4187,573,4190,4193,1751,4195,4198,1751,4200,573,4204,4207,4208,4212,1751,4214,573,4217,573,4220,4223,4224,4228,1767,4230,573,4233,4236,4237,4241,1751,4243,573,4246,573,4249,4223,4252,4256,1767,4258,573,4261,573,4264,4267,4268,4272,1751,4274,573,4277,573,4280,4223,4284,4288,1767,4290,573,4293,4297,4298,4302,1751,4304,573,4307,573,4310,573,4313,4317,4318,4322,1767,4324,573,4327,573,4330,4267,4333,4337,1751,4339,573,4342,573,4345,4223,4348,4352,1767,4354,573,4357,573,4360,573,4363,3532,4366,4370,4372,4373,573,4376,573,4379,4382,4383,4387,1751,4389,573,4392,573,4395,4223,4398,4402,1767,4404,573,4407,573,4410,2136,4413,4417,1751,4419,573,4422,573,4425,573,4428,4223,4431,4435,1767,4437,573,4440,573,4443,4446,4447,4450,1751,4452,4455],{},[559,4188,1744],{"className":4189},[562,1190],[559,4191,1748],{"className":4192},[562,1001],[566,4194],{},[559,4196,1208],{"className":4197},[562,944],[566,4199],{},[559,4201,4203],{"className":4202},[562,944],"crt",[559,4205,688],{"className":4206},[562,668],"                           ",[559,4209,4211],{"className":4210},[562,563],";; make 3 turtles",[566,4213],{},[559,4215,128],{"className":4216},[562,944],[559,4218,838],{"className":4219},[562,571],[559,4221,669],{"className":4222},[562,668],"                    ",[559,4225,4227],{"className":4226},[562,563],";; tell the first one...",[566,4229],{},[559,4231,2893],{"className":4232},[562,944],[559,4234,708],{"className":4235},[562,668]," ]                      ",[559,4238,4240],{"className":4239},[562,563],";; ...to go forward",[566,4242],{},[559,4244,128],{"className":4245},[562,944],[559,4247,838],{"className":4248},[562,571],[559,4250,708],{"className":4251},[562,668],[559,4253,4255],{"className":4254},[562,563],";; tell the second one...",[566,4257],{},[559,4259,1230],{"className":4260},[562,944],[559,4262,610],{"className":4263},[562,571],[559,4265,801],{"className":4266},[562,618]," ]           ",[559,4269,4271],{"className":4270},[562,563],";; ...to become green",[566,4273],{},[559,4275,128],{"className":4276},[562,944],[559,4278,838],{"className":4279},[562,571],[559,4281,4283],{"className":4282},[562,668],"2",[559,4285,4287],{"className":4286},[562,563],";; tell the third one...",[566,4289],{},[559,4291,3542],{"className":4292},[562,944],[559,4294,4296],{"className":4295},[562,668],"90"," ]                     ",[559,4299,4301],{"className":4300},[562,563],";; ...to turn right",[566,4303],{},[559,4305,128],{"className":4306},[562,944],[559,4308,4160],{"className":4309},[562,571],[559,4311,4283],{"className":4312},[562,668],[559,4314,4316],{"className":4315},[562,668],"-2","                  ",[559,4319,4321],{"className":4320},[562,563],";; ask the patch at (2,-2)",[566,4323],{},[559,4325,1230],{"className":4326},[562,944],[559,4328,794],{"className":4329},[562,571],[559,4331,3230],{"className":4332},[562,618],[559,4334,4336],{"className":4335},[562,563],";; ...to become blue",[566,4338],{},[559,4340,128],{"className":4341},[562,944],[559,4343,838],{"className":4344},[562,571],[559,4346,669],{"className":4347},[562,668],[559,4349,4351],{"className":4350},[562,563],";; ask the first turtle",[566,4353],{},[559,4355,128],{"className":4356},[562,944],[559,4358,4176],{"className":4359},[562,571],[559,4361,708],{"className":4362},[562,668],[559,4364,669],{"className":4365},[562,668],[559,4367,4369],{"className":4368},[562,563],";; ...to ask patch to the east",[566,4371],{},"      [ ",[559,4374,1230],{"className":4375},[562,944],[559,4377,794],{"className":4378},[562,571],[559,4380,619],{"className":4381},[562,618]," ] ]        ",[559,4384,4386],{"className":4385},[562,563],";; ...to become red",[566,4388],{},[559,4390,128],{"className":4391},[562,944],[559,4393,838],{"className":4394},[562,571],[559,4396,669],{"className":4397},[562,668],[559,4399,4401],{"className":4400},[562,563],";; tell the first turtle...",[566,4403],{},[559,4405,2586],{"className":4406},[562,944],[559,4408,838],{"className":4409},[562,571],[559,4411,708],{"className":4412},[562,668],[559,4414,4416],{"className":4415},[562,563],";; ...make a link with the second",[566,4418],{},[559,4420,128],{"className":4421},[562,944],[559,4423,4168],{"className":4424},[562,571],[559,4426,669],{"className":4427},[562,668],[559,4429,708],{"className":4430},[562,668],[559,4432,4434],{"className":4433},[562,563],";; tell the link between turtle 0 and 1",[566,4436],{},[559,4438,1230],{"className":4439},[562,944],[559,4441,610],{"className":4442},[562,571],[559,4444,3230],{"className":4445},[562,618]," ]            ",[559,4448,4336],{"className":4449},[562,563],[566,4451],{},[559,4453,1819],{"className":4454},[562,944],[559,4456,4458,1825],{"className":4457},[562,1190],[566,4459],{},[22,4461,4462],{},"Every turtle created has a who number. The first turtle created is number 0, the\nsecond turtle number 1, and so forth.",[22,4464,1376,4465,4471,4472,4478,4479,4485,4486,4492,4493,4496,4497,4499,4500,4502,4503,301],{},[319,4466,4467],{"displayText":838,"permalink":838},[16,4468,838],{"href":1491,"rel":4469,"className":4470,"dataDisplayText":838,"target":330,"title":838},[327],[329]," primitive reporter takes a who number as an input, and reports\nthe turtle with that who number. The ",[319,4473,4474],{"displayText":4160,"permalink":4160},[16,4475,4160],{"href":4163,"rel":4476,"className":4477,"dataDisplayText":4160,"target":330,"title":4160},[327],[329]," primitive reporter takes values\nfor pxcor and pycor and reports the patch with those coordinates. The ",[319,4480,4481],{"displayText":4168,"permalink":4168},[16,4482,4168],{"href":4171,"rel":4483,"className":4484,"dataDisplayText":4168,"target":330,"title":4168},[327],[329],"\nprimitive takes two inputs, the who numbers of the two turtles it connects. And\nthe ",[319,4487,4488],{"displayText":4176,"permalink":4176},[16,4489,4176],{"href":4179,"rel":4490,"className":4491,"dataDisplayText":4176,"target":330,"title":4176},[327],[329]," primitive reporter takes ",[467,4494,4495],{},"offsets",": distances, in the x and y\ndirections, ",[467,4498,2569],{}," the first agent. In the example ",[556,4501,1748],{}," procedure above, the\nturtle with who number 0 is asked to get the patch east (and no patches north)\nof itself like this: ",[556,4504,4505,573,4508,573,4511,951,4514,573,4517,573,4520,573,4523,951,4526,573,4529,573,4532,4535],{},[559,4506,128],{"className":4507},[562,944],[559,4509,838],{"className":4510},[562,571],[559,4512,669],{"className":4513},[562,668],[559,4515,128],{"className":4516},[562,944],[559,4518,4176],{"className":4519},[562,571],[559,4521,708],{"className":4522},[562,668],[559,4524,669],{"className":4525},[562,668],[559,4527,1230],{"className":4528},[562,944],[559,4530,794],{"className":4531},[562,571],[559,4533,619],{"className":4534},[562,618]," ] ]",[22,4537,4538,4539,4541],{},"You can also select a subset of turtles, or a subset of patches, or a subset of\nlinks and ask them to do something. This involves using ",[281,4540,455],{},". The next\nsection explains them in detail.",[22,4543,4544],{},"When you ask a set of agents to run more than one command, each agent must\nfinish before the next agent starts. One agent runs all of the commands, then\nthe next agent runs all of them, and so on. For example, if you write:",[553,4546,4547],{},[556,4548,4549,573,4552,4555,4557,4558,573,4561,4564,940,4566,573,4569,573,4572,958],{},[559,4550,128],{"className":4551},[562,944],[559,4553,289],{"className":4554},[562,571],[566,4556],{},"  [ ",[559,4559,2893],{"className":4560},[562,944],[559,4562,708],{"className":4563},[562,668],[566,4565],{},[559,4567,1230],{"className":4568},[562,944],[559,4570,610],{"className":4571},[562,571],[559,4573,619],{"className":4574},[562,618],[22,4576,4577],{},"first one turtle moves and turns red, then another turtle moves and turns red,\nand so on.",[22,4579,4580],{},"But if you write it this way:",[553,4582,4583],{},[556,4584,4585,573,4588,951,4591,573,4594,958,4597,4599,573,4602,951,4605,573,4608,573,4611,958],{},[559,4586,128],{"className":4587},[562,944],[559,4589,289],{"className":4590},[562,571],[559,4592,2893],{"className":4593},[562,944],[559,4595,708],{"className":4596},[562,668],[566,4598],{},[559,4600,128],{"className":4601},[562,944],[559,4603,289],{"className":4604},[562,571],[559,4606,1230],{"className":4607},[562,944],[559,4609,610],{"className":4610},[562,571],[559,4612,619],{"className":4613},[562,618],[22,4615,4616],{},"first all the turtles move, then they all turn red.",[270,4618,4620],{"id":134,"className":4619},[14],[16,4621,134],{"className":4622,"href":133},[19],[22,4624,4625,4628,4629,4631],{},[281,4626,4627],{},"NOTE:"," The following information is included only for backwards\ncompatibility. We don’t recommend using the ",[556,4630,134],{}," primitive at all in\nnew models.",[22,4633,4634,4635,4641,4642,4648],{},"In very old versions of NetLogo, ",[319,4636,4637],{"displayText":128,"permalink":128},[16,4638,128],{"href":515,"rel":4639,"className":4640,"dataDisplayText":128,"target":330,"title":128},[327],[329]," had simulated concurrent behavior by\ndefault. Since NetLogo 4.0 (2007), ",[319,4643,4644],{"displayText":128,"permalink":128},[16,4645,128],{"href":515,"rel":4646,"className":4647,"dataDisplayText":128,"target":330,"title":128},[327],[329]," is serial, that is, the agents run\nthe commands inside the ask one at a time.",[22,4650,4651,4652,4659,4660,4666],{},"The following information describes the behavior of the ",[319,4653,4654],{"displayText":134,"permalink":134},[16,4655,134],{"href":4656,"rel":4657,"className":4658,"dataDisplayText":134,"target":330,"title":134},"/dictionary#ask-concurrent",[327],[329],"\ncommand, which behaves the way the old ",[319,4661,4662],{"displayText":128,"permalink":128},[16,4663,128],{"href":515,"rel":4664,"className":4665,"dataDisplayText":128,"target":330,"title":128},[327],[329]," behaved.",[22,4668,4669,4675],{},[319,4670,4671],{"displayText":134,"permalink":134},[16,4672,134],{"href":4656,"rel":4673,"className":4674,"dataDisplayText":134,"target":330,"title":134},[327],[329]," produces simulated concurrency via a mechanism of\nturn-taking. The first agent takes a turn, then the second agent takes a turn,\nand so on until every agent in the asked agentset has had a turn. Then we go\nback to the first agent. This continues until all of the agents have finished\nrunning all of the commands.",[22,4677,4678],{},"An agent’s “turn” ends when it performs an action that affects the state of the\nworld, such as moving, or creating a turtle, or changing the value of a global,\nturtle, patch, or link variable. (Setting a local variable doesn’t count.)",[22,4680,1376,4681,774,4687,4693,4694,774,4702,4709,4710,4716,4717,4726,4727,4741,4742,4744,4745,4754,4755,301],{},[319,4682,4683],{"displayText":2894,"permalink":2894},[16,4684,2894],{"href":2897,"rel":4685,"className":4686,"dataDisplayText":2894,"target":330,"title":2894},[327],[329],[319,4688,4689],{"displayText":2893,"permalink":2894},[16,4690,2893],{"href":2897,"rel":4691,"className":4692,"dataDisplayText":2893,"target":330,"title":2893},[327],[329],") and ",[319,4695,4697],{"displayText":4696,"permalink":4696},"back",[16,4698,4696],{"href":4699,"rel":4700,"className":4701,"dataDisplayText":4696,"target":330,"title":4696},"/dictionary#back",[327],[329],[319,4703,4705],{"displayText":4704,"permalink":4696},"bk",[16,4706,4704],{"href":4699,"rel":4707,"className":4708,"dataDisplayText":4704,"target":330,"title":4704},[327],[329],") commands are treated\nspecially. When used inside ",[319,4711,4712],{"displayText":134,"permalink":134},[16,4713,134],{"href":4656,"rel":4714,"className":4715,"dataDisplayText":134,"target":330,"title":134},[327],[329],", these commands can take multiple\nturns to execute. During its turn, the turtle can only move by one step. Thus,\nfor example, ",[556,4718,4719,573,4722],{},[559,4720,2893],{"className":4721},[562,944],[559,4723,4725],{"className":4724},[562,668],"20"," is equivalent to ",[556,4728,4729,573,4732,951,4735,573,4738,958],{},[559,4730,3784],{"className":4731},[562,944],[559,4733,4725],{"className":4734},[562,668],[559,4736,2893],{"className":4737},[562,944],[559,4739,708],{"className":4740},[562,668],", where the turtle’s\nturn ends after each run of ",[556,4743,2893],{},". If the distance specified isn’t an integer,\nthe last fraction of step takes a full turn. So for example ",[556,4746,4747,573,4750],{},[559,4748,2893],{"className":4749},[562,944],[559,4751,4753],{"className":4752},[562,668],"20.3"," is\nequivalent to ",[556,4756,4757,573,4760,951,4763,573,4766,2136,4769,573,4772],{},[559,4758,3784],{"className":4759},[562,944],[559,4761,4725],{"className":4762},[562,668],[559,4764,2893],{"className":4765},[562,944],[559,4767,708],{"className":4768},[562,668],[559,4770,2893],{"className":4771},[562,944],[559,4773,4775],{"className":4774},[562,668],"0.3",[22,4777,1376,4778,4784],{},[319,4779,4780],{"displayText":2902,"permalink":2902},[16,4781,2902],{"href":2905,"rel":4782,"className":4783,"dataDisplayText":2902,"target":330,"title":2902},[327],[329]," command always takes exactly one turn, regardless of distance.",[22,4786,4787,4788,409,4794,4800],{},"To understand the difference between ",[319,4789,4790],{"displayText":128,"permalink":128},[16,4791,128],{"href":515,"rel":4792,"className":4793,"dataDisplayText":128,"target":330,"title":128},[327],[329],[319,4795,4796],{"displayText":134,"permalink":134},[16,4797,134],{"href":4656,"rel":4798,"className":4799,"dataDisplayText":134,"target":330,"title":134},[327],[329],", consider\nthe following two commands:",[553,4802,4803],{},[556,4804,4805,573,4808,951,4811,573,4814,958,4817,4819,573,4822,951,4825,573,4828,958],{},[559,4806,128],{"className":4807},[562,944],[559,4809,289],{"className":4810},[562,571],[559,4812,2893],{"className":4813},[562,944],[559,4815,1221],{"className":4816},[562,668],[566,4818],{},[559,4820,134],{"className":4821},[562,944],[559,4823,289],{"className":4824},[562,571],[559,4826,2893],{"className":4827},[562,944],[559,4829,1221],{"className":4830},[562,668],[22,4832,4833,4834,4840],{},"With ",[319,4835,4836],{"displayText":128,"permalink":128},[16,4837,128],{"href":515,"rel":4838,"className":4839,"dataDisplayText":128,"target":330,"title":128},[327],[329],", the first turtle takes five steps forward, then the second turtle\ntakes five steps forward, and so on.",[22,4842,4833,4843,4849],{},[319,4844,4845],{"displayText":134,"permalink":134},[16,4846,134],{"href":4656,"rel":4847,"className":4848,"dataDisplayText":134,"target":330,"title":134},[327],[329],", all of the turtles take one step forward. Then they all\ntake a second step, and so on. Thus, the latter command is equivalent to:",[553,4851,4852],{},[556,4853,4854,573,4857,951,4860,573,4863,951,4866,573,4869,4535],{},[559,4855,3784],{"className":4856},[562,944],[559,4858,1221],{"className":4859},[562,668],[559,4861,128],{"className":4862},[562,944],[559,4864,289],{"className":4865},[562,571],[559,4867,2893],{"className":4868},[562,944],[559,4870,708],{"className":4871},[562,668],[1414,4873,4874],{},[22,4875,4876,4878,4879,4885,4886,301],{},[281,4877,1420],{}," Ask-Concurrent Example shows the difference between ",[319,4880,4881],{"displayText":128,"permalink":128},[16,4882,128],{"href":515,"rel":4883,"className":4884,"dataDisplayText":128,"target":330,"title":128},[327],[329],"\nand ",[319,4887,4888],{"displayText":134,"permalink":134},[16,4889,134],{"href":4656,"rel":4890,"className":4891,"dataDisplayText":134,"target":330,"title":134},[327],[329],[22,4893,4894,4895,4901,4902,4908],{},"The behavior of ",[319,4896,4897],{"displayText":134,"permalink":134},[16,4898,134],{"href":4656,"rel":4899,"className":4900,"dataDisplayText":134,"target":330,"title":134},[327],[329]," cannot always be so simply reproduced using\n",[319,4903,4904],{"displayText":128,"permalink":128},[16,4905,128],{"href":515,"rel":4906,"className":4907,"dataDisplayText":128,"target":330,"title":128},[327],[329],", as in this example. Consider this command:",[553,4910,4911],{},[556,4912,4913,573,4916,951,4919,573,4922,573,4925,958],{},[559,4914,134],{"className":4915},[562,944],[559,4917,289],{"className":4918},[562,571],[559,4920,2893],{"className":4921},[562,944],[559,4923,1790],{"className":4924},[562,571],[559,4926,1287],{"className":4927},[562,668],[22,4929,4930,4931,4937],{},"In order to get the same behavior using ",[319,4932,4933],{"displayText":128,"permalink":128},[16,4934,128],{"href":515,"rel":4935,"className":4936,"dataDisplayText":128,"target":330,"title":128},[327],[329],", we would have to write:",[553,4939,4940],{},[556,4941,4942,606,4945,620,4949,4951,573,4954,951,4957,573,4960,573,4963,573,4966,958,4969,4971,606,4975,573,4978,573,4981,606,4984,573,4987,573,4990,4993,4994,1751,4996,573,4999,573,5002,606,5005,573,5008,573,5011,712,5014,940,5016,573,5019,5022,940,5024,573,5027,573,5030,573,5033,573,5036,5039,3571,5041,620],{},[559,4943,1589],{"className":4944},[562,1190],[559,4946,4948],{"className":4947},[562,1001],"steps",[566,4950],{},[559,4952,128],{"className":4953},[562,944],[559,4955,289],{"className":4956},[562,571],[559,4958,1230],{"className":4959},[562,944],[559,4961,4948],{"className":4962},[562,1001],[559,4964,1790],{"className":4965},[562,571],[559,4967,1287],{"className":4968},[562,668],[566,4970],{},[559,4972,4974],{"className":4973},[562,944],"while",[559,4976,872],{"className":4977},[562,571],[559,4979,289],{"className":4980},[562,571],[559,4982,605],{"className":4983},[562,571],[559,4985,4948],{"className":4986},[562,1001],[559,4988,664],{"className":4989},[562,571],[559,4991,669],{"className":4992},[562,668],"]] [",[566,4995],{},[559,4997,128],{"className":4998},[562,944],[559,5000,289],{"className":5001},[562,571],[559,5003,605],{"className":5004},[562,571],[559,5006,4948],{"className":5007},[562,1001],[559,5009,664],{"className":5010},[562,571],[559,5012,669],{"className":5013},[562,668],[566,5015],{},[559,5017,2893],{"className":5018},[562,944],[559,5020,708],{"className":5021},[562,668],[566,5023],{},[559,5025,1230],{"className":5026},[562,944],[559,5028,4948],{"className":5029},[562,1001],[559,5031,4948],{"className":5032},[562,1001],[559,5034,3920],{"className":5035},[562,571],[559,5037,708],{"className":5038},[562,668],[566,5040],{},[566,5042],{},[22,5044,5045,5046,5054,5055,409,5061,5067,5068,5074],{},"To prolong an agent’s “turn”, use the ",[319,5047,5049],{"displayText":5048,"permalink":5048},"without-interruption",[16,5050,5048],{"href":5051,"rel":5052,"className":5053,"dataDisplayText":5048,"target":330,"title":5048},"/dictionary#without-interruption",[327],[329]," command. (The\ncommand blocks inside some commands, such as ",[319,5056,5057],{"displayText":1217,"permalink":1217},[16,5058,1217],{"href":1503,"rel":5059,"className":5060,"dataDisplayText":1217,"target":330,"title":1217},[327],[329],[319,5062,5063],{"displayText":1539,"permalink":1539},[16,5064,1539],{"href":1542,"rel":5065,"className":5066,"dataDisplayText":1539,"target":330,"title":1539},[327],[329],",\nhave an implied ",[319,5069,5070],{"displayText":5048,"permalink":5048},[16,5071,5048],{"href":5051,"rel":5072,"className":5073,"dataDisplayText":5048,"target":330,"title":5048},[327],[329]," around them.)",[22,5076,5077,5078,5084],{},"Note that the behavior of ",[319,5079,5080],{"displayText":134,"permalink":134},[16,5081,134],{"href":4656,"rel":5082,"className":5083,"dataDisplayText":134,"target":330,"title":134},[327],[329]," is completely deterministic. Given\nthe same code and the same initial conditions, the same thing will always happen\n(if you are using the same version of NetLogo and begin your model run with the\nsame random seed).",[22,5086,5087,5088,5090,5091,5093],{},"In general, we suggest you not use ",[556,5089,134],{}," at all. If you do, we\nsuggest you write your model so that it does not depend on the exact details of\nhow ",[556,5092,134],{}," works. We make no guarantees that its semantics will remain\nthe same in future versions of NetLogo, or that it will continue to be supported\nat all.",[270,5095,5098],{"id":5096,"className":5097},"syntax",[14],[16,5099,140],{"className":5100,"href":139},[19],[34,5102,5105],{"id":5103,"className":5104},"colors",[14],[16,5106,5109],{"className":5107,"href":5108},[19],"#colors","Colors",[22,5111,5112],{},"In the Code tab and elsewhere in the NetLogo user interface, program code is\ncolor-coded by the following scheme:",[44,5114,5115,5118,5121,5124,5127,5130],{},[47,5116,5117],{},"Keywords are green",[47,5119,5120],{},"Constants are orange",[47,5122,5123],{},"Comments are gray",[47,5125,5126],{},"Primitive commands are blue",[47,5128,5129],{},"Primitive reporters are purple",[47,5131,5132],{},"Everything else is black",[34,5134,5137],{"id":5135,"className":5136},"notice",[14],[16,5138,5141],{"className":5139,"href":5140},[19],"#notice","Notice",[22,5143,5144],{},"The remainder of this section contains technical terminology which will be\nunfamiliar to some readers.",[34,5146,5149],{"id":5147,"className":5148},"keywords",[14],[16,5150,5153],{"className":5151,"href":5152},[19],"#keywords","Keywords",[22,5155,5156,5157,290,5163,290,5169,396,5175,290,5181,290,5187,1573,5193,5199,5200,5208,5209,5218],{},"The only keywords in the language are ",[319,5158,5159],{"displayText":1191,"permalink":1191},[16,5160,1191],{"href":2255,"rel":5161,"className":5162,"dataDisplayText":1191,"target":330,"title":1191},[327],[329],[319,5164,5165],{"displayText":1451,"permalink":1451},[16,5166,1451],{"href":1454,"rel":5167,"className":5168,"dataDisplayText":1451,"target":330,"title":1451},[327],[329],[319,5170,5171],{"displayText":1589,"permalink":1589},[16,5172,1589],{"href":1592,"rel":5173,"className":5174,"dataDisplayText":1589,"target":330,"title":1589},[327],[329],[319,5176,5177],{"displayText":2281,"permalink":2281},[16,5178,2281],{"href":2284,"rel":5179,"className":5180,"dataDisplayText":2281,"target":330,"title":2281},[327],[329],[319,5182,5183],{"displayText":1744,"permalink":1744},[16,5184,1744],{"href":3442,"rel":5185,"className":5186,"dataDisplayText":1744,"target":330,"title":1744},[327],[329],[319,5188,5189],{"displayText":3447,"permalink":3447},[16,5190,3447],{"href":3450,"rel":5191,"className":5192,"dataDisplayText":3447,"target":330,"title":3447},[327],[329],[319,5194,5195],{"displayText":1825,"permalink":1825},[16,5196,1825],{"href":3458,"rel":5197,"className":5198,"dataDisplayText":1825,"target":330,"title":1825},[327],[329],", plus ",[319,5201,5203],{"displayText":5202,"permalink":5202},"extensions",[16,5204,5202],{"href":5205,"rel":5206,"className":5207,"dataDisplayText":5202,"target":330,"title":5202},"/dictionary#extensions",[327],[329]," and the\nexperimental ",[319,5210,5213],{"displayText":5211,"permalink":5212},"__includes","includes",[16,5214,5211],{"href":5215,"rel":5216,"className":5217,"dataDisplayText":5211,"target":330,"title":5211},"/dictionary#includes",[327],[329]," keyword. (Built-in primitive names may not be\nshadowed or redefined, so they are effectively a kind of keyword as well.)",[34,5220,5223],{"id":5221,"className":5222},"identifiers",[14],[16,5224,5227],{"className":5225,"href":5226},[19],"#identifiers","Identifiers",[22,5229,5230,5231,5237],{},"All primitives, global and agent variable names, and procedure names share a\nsingle global case-insensitive namespace; local names (",[319,5232,5233],{"displayText":2456,"permalink":2456},[16,5234,2456],{"href":2459,"rel":5235,"className":5236,"dataDisplayText":2456,"target":330,"title":2456},[327],[329]," variables and the\nnames of procedure inputs) may not shadow global names or each other.\nIdentifiers may contain any Unicode letter or digit and the following ASCII\ncharacters:",[553,5239,5240],{},[556,5241,5242],{},[559,5243,5245],{"className":5244},[562,1001],".?=*!\u003C>:#+/%$_^'&-",[22,5247,5248],{},"Some primitive names begin with two underscores to indicate that they are\nexperimental and are especially likely to change or be removed in future NetLogo\nreleases.",[34,5250,5253],{"id":5251,"className":5252},"scope",[14],[16,5254,5257],{"className":5255,"href":5256},[19],"#scope","Scope",[22,5259,5260],{},"NetLogo is lexically scoped. Local variables (including inputs to procedures)\nare accessible within the block of commands in which they are declared, but not\naccessible by procedures called by those commands.",[34,5262,5265],{"id":5263,"className":5264},"comments",[14],[16,5266,5269],{"className":5267,"href":5268},[19],"#comments","Comments",[22,5271,5272],{},"The semicolon character introduces a comment, which lasts until the end of the\nline. There is no multi-line comment syntax.",[34,5274,5277],{"id":5275,"className":5276},"structure",[14],[16,5278,5281],{"className":5279,"href":5280},[19],"#structure","Structure",[22,5283,5284,5285,290,5291,396,5297,290,5303,290,5309,290,5316,5322,5323,5329],{},"A program consists of optional declarations (",[319,5286,5287],{"displayText":1191,"permalink":1191},[16,5288,1191],{"href":2255,"rel":5289,"className":5290,"dataDisplayText":1191,"target":330,"title":1191},[327],[329],[319,5292,5293],{"displayText":1451,"permalink":1451},[16,5294,1451],{"href":1454,"rel":5295,"className":5296,"dataDisplayText":1451,"target":330,"title":1451},[327],[329],[319,5298,5299],{"displayText":1589,"permalink":1589},[16,5300,1589],{"href":1592,"rel":5301,"className":5302,"dataDisplayText":1589,"target":330,"title":1589},[327],[329],[319,5304,5305],{"displayText":2281,"permalink":2281},[16,5306,2281],{"href":2284,"rel":5307,"className":5308,"dataDisplayText":2281,"target":330,"title":2281},[327],[329],[319,5310,5312],{"displayText":5311,"permalink":1589},"\u003CBREED>-own",[16,5313,5311],{"href":1592,"rel":5314,"className":5315,"dataDisplayText":5311,"target":330,"title":5311},[327],[329],[319,5317,5318],{"displayText":5202,"permalink":5202},[16,5319,5202],{"href":5205,"rel":5320,"className":5321,"dataDisplayText":5202,"target":330,"title":5202},[327],[329],")\nin any order, followed by zero or more procedure definitions. Multiple breeds\nmay be declared with separate ",[319,5324,5325],{"displayText":1451,"permalink":1451},[16,5326,1451],{"href":1454,"rel":5327,"className":5328,"dataDisplayText":1451,"target":330,"title":1451},[327],[329]," declarations; the other declarations may\nappear once only.",[22,5331,5332,5333,530,5339,5345,5346,5352],{},"Every procedure definition begins with ",[319,5334,5335],{"displayText":1744,"permalink":1744},[16,5336,1744],{"href":3442,"rel":5337,"className":5338,"dataDisplayText":1744,"target":330,"title":1744},[327],[329],[319,5340,5341],{"displayText":3447,"permalink":3447},[16,5342,3447],{"href":3450,"rel":5343,"className":5344,"dataDisplayText":3447,"target":330,"title":3447},[327],[329],", the procedure\nname, and an optional bracketed list of input names. Every procedure definition\nends with ",[319,5347,5348],{"displayText":1825,"permalink":1825},[16,5349,1825],{"href":3458,"rel":5350,"className":5351,"dataDisplayText":1825,"target":330,"title":1825},[327],[329],". In between are zero or more commands.",[34,5354,5357],{"id":5355,"className":5356},"commands-and-reporters",[14],[16,5358,5361],{"className":5359,"href":5360},[19],"#commands-and-reporters","Commands and reporters",[22,5363,5364,5365,5368,5369,5372],{},"Commands take zero or more inputs; the inputs are reporters, which may also take\nzero or more inputs. No punctuation separates or terminates commands; no\npunctuation separates inputs. Identifiers must be separated by whitespace or by\nparentheses or square brackets. (So for example, ",[556,5366,5367],{},"a+b"," is a single identifier,\nbut ",[556,5370,5371],{},"a(b[c]d)e"," contains five identifiers.)",[22,5374,5375],{},"All commands are prefix. All user-defined reporters are prefix. Most primitive\nreporters are prefix, but some (arithmetic operators, boolean operators, and\nsome agentset operators like with and in-points) are infix.",[22,5377,5378,5379,5395,5396,5403,5404,5422],{},"All commands and reporters, both primitive and user-defined, take a fixed number\nof inputs by default. (That’s why the language can be parsed though there is no\npunctuation to separate or terminate commands and/or inputs.) Some primitives\nare variadic, that is, may optionally take a different number of inputs than the\ndefault; parentheses are used to indicate this, e.g. ",[556,5380,5381,5382,573,5386,573,5389,573,5392,784],{},"(",[559,5383,5385],{"className":5384},[562,571],"list",[559,5387,708],{"className":5388},[562,668],[559,5390,4283],{"className":5391},[562,668],[559,5393,688],{"className":5394},[562,668]," (since the\n",[319,5397,5398],{"displayText":5385,"permalink":5385},[16,5399,5385],{"href":5400,"rel":5401,"className":5402,"dataDisplayText":5385,"target":330,"title":5385},"/dictionary#list",[327],[329]," primitive only takes two inputs by default). Parentheses are also used\nto override the default operator precedence, e.g. ",[556,5405,5381,5406,573,5409,573,5412,769,5415,573,5419],{},[559,5407,708],{"className":5408},[562,668],[559,5410,2421],{"className":5411},[562,571],[559,5413,4283],{"className":5414},[562,668],[559,5416,5418],{"className":5417},[562,571],"*",[559,5420,688],{"className":5421},[562,668],", as in other\nprogramming languages.",[22,5424,5425],{},"Sometimes an input to a primitive is a command block (zero or more commands\ninside square brackets) or a reporter block (a single reporter expression inside\nsquare brackets). User-defined procedures may not take a command or reporter\nblock as input.",[22,5427,5428],{},"Operator precedences are as follows, high to low:",[44,5430,5431,5483,5489,5500,5505,5514,5520,5532,5538,5560],{},[47,5432,5433,290,5437,290,5445,290,5453,290,5460,396,5467,290,5475],{},[559,5434,5435],{},[559,5436,605],{},[319,5438,5440],{"displayText":5439,"permalink":5439},"with-min",[16,5441,5439],{"href":5442,"rel":5443,"className":5444,"dataDisplayText":5439,"target":330,"title":5439},"/dictionary#with-min",[327],[329],[319,5446,5448],{"displayText":5447,"permalink":5447},"with-max",[16,5449,5447],{"href":5450,"rel":5451,"className":5452,"dataDisplayText":5447,"target":330,"title":5447},"/dictionary#with-max",[327],[329],[319,5454,5455],{"displayText":703,"permalink":703},[16,5456,703],{"href":5457,"rel":5458,"className":5459,"dataDisplayText":703,"target":330,"title":703},"/dictionary#at-points",[327],[329],[319,5461,5462],{"displayText":684,"permalink":684},[16,5463,684],{"href":5464,"rel":5465,"className":5466,"dataDisplayText":684,"target":330,"title":684},"/dictionary#in-radius",[327],[329],[319,5468,5470],{"displayText":5469,"permalink":5469},"in-cone",[16,5471,5469],{"href":5472,"rel":5473,"className":5474,"dataDisplayText":5469,"target":330,"title":5469},"/dictionary#in-cone",[327],[329],[319,5476,5478],{"displayText":5477,"permalink":5477},"who-are-not",[16,5479,5477],{"href":5480,"rel":5481,"className":5482,"dataDisplayText":5477,"target":330,"title":5477},"/dictionary#who-are-not",[327],[329],[47,5484,5485],{},[559,5486,5487],{},[559,5488,834],{},[47,5490,5491,5492],{},"All other primitives and user-defined procedures, including ",[319,5493,5495],{"displayText":5494,"permalink":5494},"not",[16,5496,5494],{"href":5497,"rel":5498,"className":5499,"dataDisplayText":5494,"target":330,"title":5494},"/dictionary#not",[327],[329],[47,5501,5502],{},[556,5503,5504],{},"^",[47,5506,5507,290,5509,290,5511],{},[556,5508,5418],{},[556,5510,3808],{},[556,5512,5513],{},"mod",[47,5515,5516,290,5518],{},[556,5517,2421],{},[556,5519,3920],{},[47,5521,5522,290,5525,290,5527,290,5530],{},[556,5523,5524],{},"\u003C",[556,5526,664],{},[556,5528,5529],{},"\u003C=",[556,5531,3900],{},[47,5533,5534,290,5536],{},[556,5535,614],{},[556,5537,1136],{},[47,5539,5540,290,5544,290,5552],{},[559,5541,5542],{},[559,5543,773],{},[319,5545,5547],{"displayText":5546,"permalink":5546},"or",[16,5548,5546],{"href":5549,"rel":5550,"className":5551,"dataDisplayText":5546,"target":330,"title":5546},"/dictionary#or",[327],[329],[319,5553,5555],{"displayText":5554,"permalink":5554},"xor",[16,5556,5554],{"href":5557,"rel":5558,"className":5559,"dataDisplayText":5554,"target":330,"title":5554},"/dictionary#xor",[327],[329],[47,5561,5562],{},[559,5563,5564],{},[559,5565,5566],{},"ifelse-value",[22,5568,5569,5570,5589,5590,5607,5608,5619,5620,5622,5623,5625,5626,5628,5629,290,5646,5657,5658,5660],{},"When an expression contains multiple operators with the same precedence, they\nare read in code order left-to-right. Example: ",[556,5571,5572,573,5576,573,5579,573,5583,573,5586],{},[559,5573,5575],{"className":5574},[562,618],"true",[559,5577,5546],{"className":5578},[562,571],[559,5580,5582],{"className":5581},[562,618],"false",[559,5584,773],{"className":5585},[562,571],[559,5587,5582],{"className":5588},[562,618]," is read\nas ",[556,5591,5381,5592,573,5595,573,5598,769,5601,573,5604],{},[559,5593,5575],{"className":5594},[562,618],[559,5596,5546],{"className":5597},[562,571],[559,5599,5582],{"className":5600},[562,618],[559,5602,773],{"className":5603},[562,571],[559,5605,5582],{"className":5606},[562,618]," and so results in ",[556,5609,5381,5610,769,5613,573,5616],{},[559,5611,5575],{"className":5612},[562,618],[559,5614,773],{"className":5615},[562,571],[559,5617,5582],{"className":5618},[562,618],", which is\n",[556,5621,5582],{},". This is different than many other programming languages where ",[556,5624,5546],{}," has\na lower precedence than ",[556,5627,773],{},", so the above statement would be read as\n",[556,5630,5631,573,5634,774,5637,573,5640,573,5643,784],{},[559,5632,5575],{"className":5633},[562,618],[559,5635,5546],{"className":5636},[562,571],[559,5638,5582],{"className":5639},[562,618],[559,5641,773],{"className":5642},[562,571],[559,5644,5582],{"className":5645},[562,618],[556,5647,5648,573,5651,774,5654,784],{},[559,5649,5575],{"className":5650},[562,618],[559,5652,5546],{"className":5653},[562,571],[559,5655,5582],{"className":5656},[562,618],", so ",[556,5659,5575],{},". You can surround\nexpressions in parentheses to ensure you get your desired order of operations.",[34,5662,5665],{"id":5663,"className":5664},"compared-to-other-logos",[14],[16,5666,5669],{"className":5667,"href":5668},[19],"#compared-to-other-logos","Compared to other Logos",[22,5671,5672],{},"There is no agreed-upon standard definition of Logo; it is a loose family of\nlanguages. We believe that NetLogo has enough in common with other Logos to earn\nthe Logo name. Still, NetLogo differs in some respects from most other Logos.\nThe most important differences are as follows.",[5674,5675,5678],"h5",{"id":5676,"className":5677},"surface-differences",[14],[16,5679,5682],{"className":5680,"href":5681},[19],"#surface-differences","Surface differences",[44,5684,5685,5739,5755,5758,5783,5798],{},[47,5686,5687,5688,290,5690,5692,5693,5709,5710,5724,5725,301],{},"The precedence of mathematical operators is different. Infix math operators\n(like ",[556,5689,2421],{},[556,5691,5418],{},", etc.) have lower precedence than reporters with names. For\nexample, in many Logos, if you write ",[556,5694,5695,573,5699,573,5703,573,5706],{},[559,5696,5698],{"className":5697},[562,571],"sin",[559,5700,5702],{"className":5701},[562,1001],"x",[559,5704,2421],{"className":5705},[562,571],[559,5707,708],{"className":5708},[562,668],", it will be interpreted as\n",[556,5711,5712,774,5715,573,5718,573,5721,784],{},[559,5713,5698],{"className":5714},[562,571],[559,5716,5702],{"className":5717},[562,1001],[559,5719,2421],{"className":5720},[562,571],[559,5722,708],{"className":5723},[562,668],". NetLogo, on the other hand, interprets it the way most other\nprogramming languages would, and the way the same expression would be\ninterpreted in standard mathematical notation, namely as ",[556,5726,5381,5727,573,5730,769,5733,573,5736],{},[559,5728,5698],{"className":5729},[562,571],[559,5731,5702],{"className":5732},[562,1001],[559,5734,2421],{"className":5735},[562,571],[559,5737,708],{"className":5738},[562,668],[47,5740,1376,5741,409,5748,5754],{},[319,5742,5743],{"displayText":773,"permalink":773},[16,5744,773],{"href":5745,"rel":5746,"className":5747,"dataDisplayText":773,"target":330,"title":773},"/dictionary#and",[327],[329],[319,5749,5750],{"displayText":5546,"permalink":5546},[16,5751,5546],{"href":5549,"rel":5752,"className":5753,"dataDisplayText":5546,"target":330,"title":5546},[327],[329]," reporters are special forms, not ordinary functions,\nand they “short circuit”, that is, they only evaluate their second input if\nnecessary.",[47,5756,5757],{},"Procedures can only be defined in the Code tab, not interactively in the\nCommand Center.",[47,5759,5760,5761,3857,5767,5773,5774,1690,5780,301],{},"Reporter procedures, that is, procedures that “report” (return) a value, must\nbe defined with ",[319,5762,5763],{"displayText":3447,"permalink":3447},[16,5764,3447],{"href":3450,"rel":5765,"className":5766,"dataDisplayText":3447,"target":330,"title":3447},[327],[329],[319,5768,5769],{"displayText":1744,"permalink":1744},[16,5770,1744],{"href":3442,"rel":5771,"className":5772,"dataDisplayText":1744,"target":330,"title":1744},[327],[329],". The command to report a value\nfrom a reporter procedure is ",[319,5775,5776],{"displayText":3867,"permalink":3867},[16,5777,3867],{"href":3870,"rel":5778,"className":5779,"dataDisplayText":3867,"target":330,"title":3867},[327],[329],[556,5781,5782],{},"output",[47,5784,5785,5786,301],{},"When defining a procedure, the inputs to the procedure must be enclosed in\nsquare brackets, e.g. ",[556,5787,5788,573,5791,606,5795,620],{},[559,5789,1744],{"className":5790},[562,1190],[559,5792,5794],{"className":5793},[562,1001],"square",[559,5796,5702],{"className":5797},[562,1001],[47,5799,5800,5801,5804,5805,530,5808,5811,5812,5815,5816,5822],{},"Variable names are always used without any punctuation: always ",[556,5802,5803],{},"foo",", never\n",[556,5806,5807],{},":foo",[556,5809,5810],{},"\"foo",". (To make this work, instead of a ",[556,5813,5814],{},"make"," command taking a\nquoted argument we supply a ",[319,5817,5818],{"displayText":1230,"permalink":1230},[16,5819,1230],{"href":2334,"rel":5820,"className":5821,"dataDisplayText":1230,"target":330,"title":1230},[327],[329]," special form which does not evaluate its\nfirst input.) As a result, procedures and variables occupy a single shared\nnamespace.",[22,5824,5825],{},"The last three differences are illustrated in the following procedure\ndefinitions:",[29,5827,5830],{"className":5828},[5829],"table-container",[5831,5832,5833,5834],"table",{},"\n  ",[5835,5836,5837,5848],"tbody",{},[5838,5839,5840,5841,5845],"tr",{},"\n    ",[5842,5843,5844],"th",{},"most Logos\n    ",[5842,5846,5847],{},"NetLogo\n  ",[5838,5849,5840,5850,5856],{},[5851,5852,5853,5840],"td",{},[553,5854,5855],{},"to square :x\noutput :x * :x\nend",[5851,5857,5858],{},[553,5859,5860],{},"to-report square [x]\nreport x * x\nend",[5674,5862,5865],{"id":5863,"className":5864},"deeper-differences",[14],[16,5866,5869],{"className":5867,"href":5868},[19],"#deeper-differences","Deeper differences",[44,5871,5872,5875,5915,5926,5953],{},[47,5873,5874],{},"NetLogo’s local variables and inputs to procedures are lexically scoped, not\ndynamically scoped.",[47,5876,5877,5878,5892,5893,5899,5900,5914],{},"NetLogo has no “word” data type (what Lisp calls “symbols”). Eventually, we\nmay add one, but since it is seldom requested, it may be that the need doesn’t\narise much in agent-based modeling. We do have strings. In most situations\nwhere traditional Logo would use words, we simply use strings instead. For\nexample in Logo you could write ",[556,5879,825,5880,573,5884,573,5888,620],{},[559,5881,5883],{"className":5882},[562,1001],"see",[559,5885,5887],{"className":5886},[562,1001],"spot",[559,5889,5891],{"className":5890},[562,944],"run"," (a list of words), but in\nNetLogo you must write ",[556,5894,5895],{},[559,5896,5898],{"className":5897},[562,2994],"\"see spot run\""," (a string) or ",[556,5901,825,5902,573,5906,573,5910,620],{},[559,5903,5905],{"className":5904},[562,2994],"\"see\"",[559,5907,5909],{"className":5908},[562,2994],"\"spot\"",[559,5911,5913],{"className":5912},[562,2994],"\"run\"","\n(a list of strings) instead.",[47,5916,5917,5918,5925],{},"NetLogo’s ",[319,5919,5920],{"displayText":5891,"permalink":5891},[16,5921,5891],{"href":5922,"rel":5923,"className":5924,"dataDisplayText":5891,"target":330,"title":5891},"/dictionary#run",[327],[329]," command works on anonymous procedures and strings, not lists\n(since we have no “word” data type), and does not permit the definition or\nredefinition of procedures.",[47,5927,5928,5929,409,5936,5943,5944,290,5947,1573,5949,5952],{},"Control structures such as ",[319,5930,5931],{"displayText":1615,"permalink":1615},[16,5932,1615],{"href":5933,"rel":5934,"className":5935,"dataDisplayText":1615,"target":330,"title":1615},"/dictionary#if",[327],[329],[319,5937,5938],{"displayText":4974,"permalink":4974},[16,5939,4974],{"href":5940,"rel":5941,"className":5942,"dataDisplayText":4974,"target":330,"title":4974},"/dictionary#while",[327],[329]," are special forms, not\nordinary functions. You can’t define your own special forms, so you can’t\ndefine your own control structures. (You can do something similar using\nanonymous procedures, but you must use the ",[556,5945,5946],{},"->",[556,5948,5891],{},[556,5950,5951],{},"runresult","\nprimitives for that, you cannot make them implicit.)",[47,5954,5955],{},"Anonymous procedures (aka function values or lambda) are true lexically-scoped\nclosures. This feature is available in NetLogo and in modern Lisps, but not in\nstandard Logo.",[22,5957,5958],{},"Of course, the NetLogo language also contains other features not found in most\nLogos, most importantly agents and agentsets.",[270,5960,5963],{"id":5961,"className":5962},"multiple-source-files",[14],[16,5964,146],{"className":5965,"href":145},[19],[22,5967,1376,5968,5974],{},[319,5969,5970],{"displayText":5211,"permalink":5212},[16,5971,5211],{"href":5215,"rel":5972,"className":5973,"dataDisplayText":5211,"target":330,"title":5211},[327],[329]," keyword allows you to use multiple source files in a single\nNetLogo model.",[22,5976,5977],{},"The keyword begins with two underscores to indicate that the feature is\nexperimental and may change in future NetLogo releases.",[22,5979,5980,5981,5988],{},"When you open a model that uses the ",[319,5982,5983],{"displayText":5211,"permalink":5211},[16,5984,5211],{"href":5985,"rel":5986,"className":5987,"dataDisplayText":5211,"target":330,"title":5211},"/dictionary#__includes",[327],[329]," keyword, or if you add it to\nthe top of a model and hit the Check button, the includes menu will appear in\nthe toolbar. From the includes menu you can select from the files included in\nthis model.",[22,5990,5991,5992,5996],{},"When you open included files they appear in additional tabs. See the\n",[16,5993,5995],{"href":5994},"/codetab#included-files-menu","Interface Guide"," for more details.",[22,5998,5999,6000,6003,6004,290,6010,290,6016,290,6022,396,6028,6035,6036,6039,6040,6042,6043,6045,6046,6048],{},"You can have anything in external source files (",[556,6001,6002],{},".nls",") that you would normally\nput in the Code tab: ",[319,6005,6006],{"displayText":1191,"permalink":1191},[16,6007,1191],{"href":2255,"rel":6008,"className":6009,"dataDisplayText":1191,"target":330,"title":1191},[327],[329],[319,6011,6012],{"displayText":1451,"permalink":1451},[16,6013,1451],{"href":1454,"rel":6014,"className":6015,"dataDisplayText":1451,"target":330,"title":1451},[327],[329],[319,6017,6018],{"displayText":1589,"permalink":1589},[16,6019,1589],{"href":1592,"rel":6020,"className":6021,"dataDisplayText":1589,"target":330,"title":1589},[327],[329],[319,6023,6024],{"displayText":2281,"permalink":2281},[16,6025,2281],{"href":2284,"rel":6026,"className":6027,"dataDisplayText":2281,"target":330,"title":2281},[327],[329],[319,6029,6031],{"displayText":6030,"permalink":1589},"breeds-own",[16,6032,6030],{"href":1592,"rel":6033,"className":6034,"dataDisplayText":6030,"target":330,"title":6030},[327],[329],", procedure definitions, etc. Note though that these\ndeclarations all share the same namespace. That is, if you declare a global\n",[556,6037,6038],{},"my-global"," in the Code tab you cannot declare a global (or anything else) with\nthe name ",[556,6041,6038],{}," in any file that is included in the model. ",[556,6044,6038],{}," will\nbe accessible from all the included files. The same would be true if ",[556,6047,6038],{},"\nwere declared in one of the included files.",[270,6050,6053],{"id":6051,"className":6052},"buttons",[14],[16,6054,152],{"className":6055,"href":151},[19],[22,6057,6058],{},"Buttons in the interface tab provide an easy way to control the model. Typically\na model will have at least a “setup” button, to set up the initial state of the\nworld, and a “go” button to make the model run continuously. Some models will\nhave additional buttons that perform other actions.",[22,6060,6061],{},"A button contains some NetLogo code. That code is run when you press the button.",[22,6063,6064],{},"A button may be either a “once button”, or a “forever button”. You can control\nthis by editing the button and checking or unchecking the “Forever” checkbox.\nOnce buttons run their code once, then stop and pop back up. Forever buttons\nkeep running their code over and over again.",[22,6066,6067],{},"A forever button stops if the user presses the button again to stop it. The\nbutton waits until the current iteration has finished, then pops up.",[22,6069,6070],{},"A forever button can also be stopped from code. If the forever button directly\ncalls a procedure, then when that procedure stops, the button stops. (In a\nturtle or patch forever button, the button won’t stop until every turtle or\npatch stops — a single turtle or patch doesn’t have the power to stop the whole\nbutton.)",[22,6072,6073],{},"Normally, a button is labeled with the code that it runs. For example, a button\nthat says “go” on it usually contains the code “go”, which means “run the go\nprocedure”. (Procedures are defined in the Code tab; see below.) But you can\nalso edit a button and enter a “display name” for the button, which is a text\nthat appears on the button instead of the code. You might use this feature if\nyou think the actual code would be confusing to your users.",[22,6075,6076,6077,6083],{},"When you put code in a button, you must also specify which agents you want to\nrun that code. You can choose to have the observer run the code, or all turtles,\nor all patches, or all links. (If you want the code to be run by only some\nturtles or some patches, you could make an observer button, and then have the\nobserver use the ",[319,6078,6079],{"displayText":128,"permalink":128},[16,6080,128],{"href":515,"rel":6081,"className":6082,"dataDisplayText":128,"target":330,"title":128},[327],[329]," command to ask only some of the turtles or patches to\ndo something.)",[22,6085,6086],{},"When you edit a button, you have the option to assign an “action key”. This\nmakes that key on the keyboard behave just like a button press. If the button is\na forever button, it will stay down until the key is pressed again (or the\nbutton is clicked). Action keys are particularly useful for games or any model\nwhere rapid triggering of buttons is needed.",[22,6088,6089],{},[281,6090,6091],{},"Buttons take turns",[22,6093,6094],{},"More than one button can be pressed at a time. If this happens, the buttons\n“take turns”, which means that only one button runs at a time. Each button runs\nits code all the way through once while the other buttons wait, then the next\nbutton gets its turn.",[22,6096,6097],{},"In the following examples, “setup” is a once button and “go” is a forever\nbutton.",[22,6099,6100],{},"Example #1: The user presses “setup”, then presses “go” immediately, before the\n“setup” has popped back up. Result: “setup” finishes before “go” starts.",[22,6102,6103],{},"Example #2: While the “go” button is down, the user presses “setup”. Result: the\n“go” button finishes its current iteration. Then the “setup” button runs. Then\n“go” starts running again.",[22,6105,6106],{},"Example #3: The user has two forever buttons down at the same time. Result:\nfirst one button runs its code all the way through, then the other runs its code\nall the way through, and so on, alternating.",[22,6108,6109],{},"Note that if one button gets stuck in an infinite loop, then no other buttons\nwill run.",[22,6111,6112],{},[281,6113,6114],{},"Turtle, patch, and link forever buttons",[22,6116,6117,6118,290,6126,530,6134,6142,6143,6149],{},"There is a subtle difference between putting commands in a turtle, patch or link\nforever button, and putting the same commands in an observer button that does\n",[556,6119,6120,573,6123],{},[559,6121,128],{"className":6122},[562,944],[559,6124,289],{"className":6125},[562,571],[556,6127,6128,573,6131],{},[559,6129,128],{"className":6130},[562,944],[559,6132,293],{"className":6133},[562,571],[556,6135,6136,573,6139],{},[559,6137,128],{"className":6138},[562,944],[559,6140,296],{"className":6141},[562,571],". An “ask” doesn’t complete until all\nof the agents have finished running all of the commands in the “ask”. So the\nagents, as they all run the commands concurrently, can be out of sync with each\nother, but they all sync up again at the end of the ask. The same isn’t true of\nturtle, patch and link forever buttons. Since ",[319,6144,6145],{"displayText":128,"permalink":128},[16,6146,128],{"href":515,"rel":6147,"className":6148,"dataDisplayText":128,"target":330,"title":128},[327],[329]," was not used, each turtle\nor patch runs the given code over and over again, so they can become (and\nremain) out of sync with each other.",[22,6151,6152],{},"At present, this capability is very rarely used in the models in our Models\nLibrary. A model that does use the capability is the Termites model, in the\nBiology section of Sample Models. The “go” button is a turtle forever button, so\neach termite proceeds independently of every other termite, and the observer is\nnot involved at all. This means that if, for example, you wanted to add ticks\nand/or a plot to the model, you would need to add a second forever button (an\nobserver forever button), and run both forever buttons at the same time. Note\nalso that a model like this cannot be used with BehaviorSpace.",[1414,6154,6155],{},[22,6156,6157,6159],{},[281,6158,1420],{}," State Machine Example shows how Termites can be recoded in a\ntick-based way, without using a turtle forever button.",[22,6161,6162],{},"At present, NetLogo has no way for one forever button to start another. Buttons\nare only started when you press them.",[270,6164,6167],{"id":6165,"className":6166},"anonymous-procedures",[14],[16,6168,158],{"className":6169,"href":157},[19],[22,6171,6172],{},"Anonymous procedures let you store code to be run later. Just like regular\nNetLogo procedures, an anonymous procedures can be either a command (anonymous\ncommand) or a reporter (anonymous reporter).",[22,6174,6175],{},"Anonymous procedures are values, which means they may be passed as input,\nreported as a result, or stored in a variable.",[22,6177,6178],{},"An anonymous procedure might be run once, multiple times, or not at all.",[22,6180,6181],{},"In other programming languages anonymous procedures are known as first-class\nfunctions, closures, or lambda.",[34,6183,6186],{"id":6184,"className":6185},"anonymous-procedure-primitives",[14],[16,6187,6190],{"className":6188,"href":6189},[19],"#anonymous-procedure-primitives","Anonymous procedure primitives",[22,6192,6193,6194,290,6196,6199,6200,301],{},"Primitives specific to anonymous procedures are ",[556,6195,5946],{},[556,6197,6198],{},"is-anonymous-command?",",\nand ",[556,6201,6202],{},"is-anonymous-reporter?",[22,6204,1376,6205,6207,6208,6220,6221,6223,6224,6235,6236,6238],{},[556,6206,5946],{}," creates an anonymous procedure. The anonymous procedure it reports\nmight be a command or a reporter, depending on what kind of block you pass it.\nFor example ",[556,6209,6210,6211,573,6214,573,6217,958],{},"[ ",[559,6212,5946],{"className":6213},[562,571],[559,6215,2893],{"className":6216},[562,944],[559,6218,708],{"className":6219},[562,668]," reports an anonymous command, because ",[556,6222,2893],{}," is a\ncommand, while ",[556,6225,6210,6226,573,6229,573,6232,958],{},[559,6227,5946],{"className":6228},[562,571],[559,6230,894],{"className":6231},[562,571],[559,6233,289],{"className":6234},[562,571]," reports an anonymous reporter, because\n",[556,6237,894],{}," is a reporter.",[22,6240,6241,6242,290,6245,396,6248,290,6251,290,6254,290,6257,6260,6261,6263,6264,6276,6277,6298,6299,301],{},"These primitives require anonymous procedures as input: ",[556,6243,6244],{},"foreach",[556,6246,6247],{},"map",[556,6249,6250],{},"reduce",[556,6252,6253],{},"filter",[556,6255,6256],{},"n-values",[556,6258,6259],{},"sort-by",". When calling these primitives, using\nan ",[556,6262,5946],{}," is optional if your anonymous procedure contains a single primitive\nwhich has requires no more inputs than are are provided by the primitive. For\nexample one may write simply ",[556,6265,6266,573,6269,573,6273],{},[559,6267,6244],{"className":6268},[562,944],[559,6270,6272],{"className":6271},[562,1001],"mylist",[559,6274,1245],{"className":6275},[562,944]," instead of\n",[556,6278,6279,573,6282,6285,6286,830,6289,573,6292,573,6295,958],{},[559,6280,6244],{"className":6281},[562,944],[559,6283,6272],{"className":6284},[562,1001]," [ [",[559,6287,5702],{"className":6288},[562,1001],[559,6290,5946],{"className":6291},[562,571],[559,6293,1245],{"className":6294},[562,944],[559,6296,5702],{"className":6297},[562,1001],", though the latter is also accepted.\nDepending on the anonymous procedure, various parts of the anonymous procedure\nsyntax can be omitted. For a summary of optional syntax, see\n",[16,6300,6302],{"href":6301},"#what-is-optional","the table below",[22,6304,1376,6305,6307],{},[556,6306,5891],{}," command accepts anonymous commands as well as strings.",[22,6309,1376,6310,6312],{},[556,6311,5951],{}," reporter accepts anonymous reporters as well as strings.",[22,6314,6315,409,6317,6319,6320,6332,6333,6349],{},[556,6316,5891],{},[556,6318,5951],{}," allow passing inputs to an anonymous procedure. As with\nall primitives accepting varying number of inputs, the whole call must be\nsurrounded with parentheses, so for example ",[556,6321,5381,6322,573,6325,573,6329,784],{},[559,6323,5891],{"className":6324},[562,944],[559,6326,6328],{"className":6327},[562,1001],"my-anonymous-command",[559,6330,1221],{"className":6331},[562,668]," or\n",[556,6334,5381,6335,573,6338,573,6342,573,6346,784],{},[559,6336,5951],{"className":6337},[562,571],[559,6339,6341],{"className":6340},[562,1001],"my-anonymous-reporter",[559,6343,6345],{"className":6344},[562,2994],"\"foo\"",[559,6347,4283],{"className":6348},[562,668],". When not passing input, no\nparentheses are required.",[34,6351,6354],{"id":6352,"className":6353},"anonymous-procedure-inputs",[14],[16,6355,6358],{"className":6356,"href":6357},[19],"#anonymous-procedure-inputs","Anonymous procedure inputs",[22,6360,6361,6362,290,6384,409,6386,6388],{},"An anonymous procedure may take zero or more inputs. The inputs are referenced\nthe variables declared before the arrow. For instance, in the anonymous reporter\n",[556,6363,6364,6365,573,6368,830,6372,573,6375,573,6378,573,6381,958],{},"[ [",[559,6366,16],{"className":6367},[562,1001],[559,6369,6371],{"className":6370},[562,1001],"b",[559,6373,5946],{"className":6374},[562,571],[559,6376,16],{"className":6377},[562,1001],[559,6379,2421],{"className":6380},[562,571],[559,6382,6371],{"className":6383},[562,1001],[556,6385,16],{},[556,6387,6371],{}," are inputs.",[34,6390,6393],{"id":6391,"className":6392},"anonymous-procedures-and-strings",[14],[16,6394,6397],{"className":6395,"href":6396},[19],"#anonymous-procedures-and-strings","Anonymous procedures and strings",[22,6399,6400,6401,530,6403,6405],{},"Creating and running anonymous procedures is fast. To use ",[556,6402,5891],{},[556,6404,5951],{},"\non a new string for the first time is about 100x slower than running an\nanonymous procedure. Modelers should normally use anonymous procedures instead\nof running strings, except when running strings entered by the user.",[34,6407,6410],{"id":6408,"className":6409},"concise-syntax",[14],[16,6411,6414],{"className":6412,"href":6413},[19],"#concise-syntax","Concise syntax",[22,6416,6417,6418,290,6420,290,6422,290,6424,290,6426,1573,6428,6430],{},"Simple uses of ",[556,6419,6244],{},[556,6421,6247],{},[556,6423,6250],{},[556,6425,6253],{},[556,6427,6256],{},[556,6429,6259],{},"\ncan be written with an especially concise syntax. You can write:",[553,6432,6433],{},[556,6434,6435,573,6438,606,6442,573,6445,573,6448,573,6451,620,6455,6457,6461,6463,573,6466,606,6469,573,6472,573,6475,573,6478,620,6482,6484,6488,6490,573,6493,606,6497,573,6500,573,6504,620,6507,6509,6513,6515,606,6518,573,6521,573,6524,573,6527,830,6530,6533,6535],{},[559,6436,6247],{"className":6437},[562,571],[559,6439,6441],{"className":6440},[562,571],"abs",[559,6443,708],{"className":6444},[562,668],[559,6446,4316],{"className":6447},[562,668],[559,6449,688],{"className":6450},[562,668],[559,6452,6454],{"className":6453},[562,668],"-4",[566,6456],{},[559,6458,6460],{"className":6459},[562,563],";; => [1 2 3 4]",[566,6462],{},[559,6464,6250],{"className":6465},[562,571],[559,6467,2421],{"className":6468},[562,571],[559,6470,708],{"className":6471},[562,668],[559,6473,4283],{"className":6474},[562,668],[559,6476,688],{"className":6477},[562,668],[559,6479,6481],{"className":6480},[562,668],"4",[566,6483],{},[559,6485,6487],{"className":6486},[562,563],";; => 10",[566,6489],{},[559,6491,6253],{"className":6492},[562,571],[559,6494,6496],{"className":6495},[562,571],"is-number?",[559,6498,708],{"className":6499},[562,668],[559,6501,6503],{"className":6502},[562,2994],"\"x\"",[559,6505,688],{"className":6506},[562,668],[566,6508],{},[559,6510,6512],{"className":6511},[562,563],";; => [1 3]",[566,6514],{},[559,6516,6244],{"className":6517},[562,944],[559,6519,708],{"className":6520},[562,668],[559,6522,4283],{"className":6523},[562,668],[559,6525,688],{"className":6526},[562,668],[559,6528,6481],{"className":6529},[562,668],[559,6531,1245],{"className":6532},[562,944],[566,6534],{},[559,6536,6538],{"className":6537},[562,563],";; prints 1 through 4",[22,6540,6541],{},"In older NetLogo versions (4 and earlier), these had to be written:",[553,6543,6544],{},[556,6545,6546,606,6549,573,6552,712,6556,573,6559,573,6562,573,6565,620,6568,6570,6573,6575,606,6578,573,6582,573,6585,712,6589,573,6592,573,6595,573,6598,620,6601,6603,6606,6608,606,6611,573,6614,712,6617,573,6620,573,6623,620,6626,6628,6631,6633,606,6636,573,6639,573,6642,573,6645,1003,6648,573,6651,958,6654,6656],{},[559,6547,6247],{"className":6548},[562,571],[559,6550,6441],{"className":6551},[562,571],[559,6553,6555],{"className":6554},[562,1001],"?",[559,6557,708],{"className":6558},[562,668],[559,6560,4316],{"className":6561},[562,668],[559,6563,688],{"className":6564},[562,668],[559,6566,6454],{"className":6567},[562,668],[566,6569],{},[559,6571,6460],{"className":6572},[562,563],[566,6574],{},[559,6576,6250],{"className":6577},[562,571],[559,6579,6581],{"className":6580},[562,1001],"?1",[559,6583,2421],{"className":6584},[562,571],[559,6586,6588],{"className":6587},[562,1001],"?2",[559,6590,708],{"className":6591},[562,668],[559,6593,4283],{"className":6594},[562,668],[559,6596,688],{"className":6597},[562,668],[559,6599,6481],{"className":6600},[562,668],[566,6602],{},[559,6604,6487],{"className":6605},[562,563],[566,6607],{},[559,6609,6253],{"className":6610},[562,571],[559,6612,6496],{"className":6613},[562,571],[559,6615,6555],{"className":6616},[562,1001],[559,6618,708],{"className":6619},[562,668],[559,6621,6503],{"className":6622},[562,2994],[559,6624,688],{"className":6625},[562,668],[566,6627],{},[559,6629,6512],{"className":6630},[562,563],[566,6632],{},[559,6634,6244],{"className":6635},[562,944],[559,6637,708],{"className":6638},[562,668],[559,6640,4283],{"className":6641},[562,668],[559,6643,688],{"className":6644},[562,668],[559,6646,6481],{"className":6647},[562,668],[559,6649,1245],{"className":6650},[562,944],[559,6652,6555],{"className":6653},[562,1001],[566,6655],{},[559,6657,6538],{"className":6658},[562,563],[34,6660,6663],{"id":6661,"className":6662},"anonymous-procedures-as-closures",[14],[16,6664,6667],{"className":6665,"href":6666},[19],"#anonymous-procedures-as-closures","Anonymous procedures as closures",[22,6669,6670],{},"Anonymous procedures are “closures”; that means they capture or “close over” the\nbindings (not just the current values) of local variables and procedure inputs.\nThey do not capture agent variables and do not capture the identity (or even the\nagent type) of the current agent.",[34,6672,6675],{"id":6673,"className":6674},"nonlocal-exits",[14],[16,6676,6679],{"className":6677,"href":6678},[19],"#nonlocal-exits","Nonlocal exits",[22,6681,1376,6682,409,6685,6687],{},[556,6683,6684],{},"stop",[556,6686,3867],{}," commands exit from the dynamically enclosing procedure,\nnot the enclosing anonymous procedure. (This is backward-compatible with older\nNetLogo versions.)",[34,6689,6692],{"id":6690,"className":6691},"anonymous-procedures-and-extensions",[14],[16,6693,6696],{"className":6694,"href":6695},[19],"#anonymous-procedures-and-extensions","Anonymous procedures and extensions",[22,6698,6699],{},"The extensions API supports writing primitives that accept anonymous procedures\nas input. Write us for sample code.",[34,6701,6704],{"id":6702,"className":6703},"limitations",[14],[16,6705,6708],{"className":6706,"href":6707},[19],"#limitations","Limitations",[22,6710,6711],{},"We hope to address at least some of the following limitations in future NetLogo\nversions:",[44,6713,6714,6720,6723,6735,6847],{},[47,6715,6716,6719],{},[556,6717,6718],{},"import-world"," does not support anonymous procedures.",[47,6721,6722],{},"Anonymous procedures can’t be variadic (accept a varying number of inputs).",[47,6724,6725,6726,6728,6729,6731,6732,6734],{},"Anonymous reporters can’t contain commands, only a single reporter expression.\nSo for example you must use ",[556,6727,5566],{}," not ",[556,6730,1615],{},", and you don’t use\n",[556,6733,3867],{}," at all. If your code is too complex to be written as one reporter,\nyou’ll need to move the code to a separate reporter procedure, and then call\nthat procedure from your anonymous reporter, passing it any needed inputs.",[47,6736,6737,6738,409,6740,6742,6743,409,6745,6747,6748,6776,6777,409,6792,6807,6808,6822,6823,301],{},"Anonymous procedures are not interchangeable with command blocks and reporter\nblocks. Only the primitives listed above accept anonymous procedures as input.\nControl primitives such as ",[556,6739,3893],{},[556,6741,4974],{}," and agent primitives such as\n",[556,6744,834],{},[556,6746,605],{}," don’t accept anonymous procedures. So for example if I have an\nanonymous reporter ",[556,6749,6750,573,6753,951,6757,573,6760,573,6763,573,6766,573,6769,573,6773,958],{},[559,6751,2456],{"className":6752},[562,944],[559,6754,6756],{"className":6755},[562,1001],"r",[559,6758,5946],{"className":6759},[562,571],[559,6761,1615],{"className":6762},[562,944],[559,6764,1790],{"className":6765},[562,571],[559,6767,4283],{"className":6768},[562,668],[559,6770,6772],{"className":6771},[562,1001],"==",[559,6774,669],{"className":6775},[562,668]," and two anonymous commands\n",[556,6778,6779,573,6782,951,6786,573,6789,958],{},[559,6780,2456],{"className":6781},[562,944],[559,6783,6785],{"className":6784},[562,1001],"c1",[559,6787,5946],{"className":6788},[562,571],[559,6790,3577],{"className":6791},[562,944],[556,6793,6794,573,6797,951,6801,573,6804,958],{},[559,6795,2456],{"className":6796},[562,944],[559,6798,6800],{"className":6799},[562,1001],"c2",[559,6802,5946],{"className":6803},[562,571],[559,6805,6684],{"className":6806},[562,944],", I can’t write ",[556,6809,6810,573,6813,573,6816,573,6819],{},[559,6811,3893],{"className":6812},[562,944],[559,6814,6756],{"className":6815},[562,1001],[559,6817,6785],{"className":6818},[562,1001],[559,6820,6800],{"className":6821},[562,1001],",\nI must write ",[556,6824,6825,573,6828,573,6831,951,6834,573,6837,6840,6841,573,6844,958],{},[559,6826,3893],{"className":6827},[562,944],[559,6829,5951],{"className":6830},[562,571],[559,6832,6756],{"className":6833},[562,1001],[559,6835,5891],{"className":6836},[562,944],[559,6838,6785],{"className":6839},[562,1001]," ] [ ",[559,6842,5891],{"className":6843},[562,944],[559,6845,6800],{"className":6846},[562,1001],[47,6848,6849,6850,6852,6853,6855,6856,6728,6867,301],{},"The concise syntax where ",[556,6851,5946],{}," may be omitted is only available to primitives\nand extension primitives, not ordinary procedures. So for example if I have a\nprocedure ",[556,6854,22],{}," that accepts an anonymous procedure as input, it must be called\nas e.g. ",[556,6857,6858,951,6861,573,6864,3571],{},[559,6859,22],{"className":6860},[562,1001],[559,6862,5946],{"className":6863},[562,571],[559,6865,1629],{"className":6866},[562,1001],[556,6868,6869,951,6872,958],{},[559,6870,22],{"className":6871},[562,1001],[559,6873,1629],{"className":6874},[562,1001],[34,6876,6879],{"id":6877,"className":6878},"what-is-optional",[14],[16,6880,6882],{"className":6881,"href":6301},[19],"What is Optional?",[22,6884,6885],{},"There are several different ways of writing anonymous procedures which allow\nusers to omit part or all of the anonymous procedure syntax. These are\nsummarized in the table below.",[29,6887,6889],{"className":6888},[5829],[5831,6890,6894,6909],{"className":6891},[6892,6893],"line-border","anon-procedure-table",[6895,6896,6897],"thead",{},[5838,6898,5833,6899,5833,6903,5833,6906],{},[5842,6900,6902],{"scope":6901},"col","What is the anonymous procedure like?",[5842,6904,6905],{"scope":6901},"What can be left out?",[5842,6907,6908],{"scope":6901},"Examples",[5835,6910,5833,6911,5833,6962,5833,6990,5833,7032],{},[5838,6912,5840,6913,5840,6916,5840,6931,5833],{},[5851,6914,6915],{},"The anonymous procedure is a single primitive",[5851,6917,6918,6919,5840],{},"\n      ",[44,6920,6921,6922,6921,6925,6921,6928,6918],{},"\n        ",[47,6923,6924],{},"input names",[47,6926,6927],{},"arrow",[47,6929,6930],{},"block brackets",[5851,6932,6918,6933,5840],{},[44,6934,6921,6937,6921,6942,6921,6947,6921,6952,6921,6957,6918],{"className":6935},[6936],"no-bullets",[47,6938,6939],{},[556,6940,6941],{},"foreach mylist stamp  ; no inputs",[47,6943,6944],{},[556,6945,6946],{},"foreach mylist print  ; single input",[47,6948,6949],{},[556,6950,6951],{},"(foreach xs ys setxy) ; multiple inputs",[47,6953,6954],{},[556,6955,6956],{},"map round [1.3 2.4 3.5] ; reporter, single input",[47,6958,6959],{},[556,6960,6961],{},"(map + [1 2 3] [4 5 6]) ; reporter, multiple inputs",[5838,6963,5840,6964,5840,6967,5840,6975,5833],{},[5851,6965,6966],{},"The anonymous procedure takes no inputs",[5851,6968,6918,6969,5840],{},[44,6970,6921,6971,6921,6973,6918],{},[47,6972,6924],{},[47,6974,6927],{},[5851,6976,6918,6977,5840],{},[44,6978,6921,6980,6921,6985,6918],{"className":6979},[6936],[47,6981,6982],{},[556,6983,6984],{},"foreach mylist [ print \"abc\" ]",[47,6986,6987],{},[556,6988,6989],{},"map [ 4 ] mylist",[5838,6991,5840,6992,5840,6995,5840,7002,5833],{},[5851,6993,6994],{},"The anonymous procedure has zero or one input(s)",[5851,6996,6918,6997,5840],{},[44,6998,6921,6999,6918],{},[47,7000,7001],{},"brackets around input names",[5851,7003,6918,7004,5840],{},[44,7005,6921,7007,6921,7012,6921,7017,6921,7022,6921,7027,573],{"className":7006},[6936],[47,7008,7009],{},[556,7010,7011],{},"foreach mylist [ -> stamp ] ; no inputs",[47,7013,7014],{},[556,7015,7016],{},"foreach mylist [ x -> print x ] ; single input",[47,7018,7019],{},[556,7020,7021],{},"foreach mylist [ x -> rt x fd x ] ; multiple primitives, single input",[47,7023,7024],{},[556,7025,7026],{},"map [ -> world-width ] mylist ; reporter, no inputs",[47,7028,7029],{},[556,7030,7031],{},"map [ x -> x ^ 2 ] mylist ; reporter, single input",[5838,7033,5840,7034,5840,7037,5840,7044,5833],{},[5851,7035,7036],{},"Anonymous procedure takes more than one input",[5851,7038,6918,7039,5840],{},[44,7040,6921,7041,6918],{},[47,7042,7043],{},"nothing",[5851,7045,6918,7046,5840],{},[44,7047,6921,7049,6921,7054,6918],{"className":7048},[6936],[47,7050,7051],{},[556,7052,7053],{},"(foreach xs ys [ [ x y ] -> setx x + y ])",[47,7055,7056],{},[556,7057,7058],{},"(map [ [ x y ] -> x mod round y ] xs ys)",[22,7060,7061,7064,7065,7068],{},[281,7062,7063],{},"Note",": brackets around input names were ",[281,7066,7067],{},"always required"," in NetLogo 6.0.0.\nIf you copy and paste code into NetLogo 6.0.0 using anonymous procedures with\nunbracketed input names, the code will not compile until you add the brackets.",[34,7070,7073],{"id":7071,"className":7072},"code-example",[14],[16,7074,7077],{"className":7075,"href":7076},[19],"#code-example","Code example",[1414,7079,7080],{},[22,7081,7082,7084],{},[281,7083,1420],{}," State Machine Example",[262,7086,7088],{"id":307,"className":7087},[14],[16,7089,164],{"className":7090,"href":163},[19],[270,7092,7095],{"id":7093,"className":7094},"tick-counter",[14],[16,7096,172],{"className":7097,"href":171},[19],[22,7099,7100],{},"In many NetLogo models, time passes in discrete steps, called “ticks”. NetLogo\nincludes a built-in tick counter so you can keep track of how many ticks have\npassed.",[22,7102,7103],{},"The current value of the tick counter is shown above the view. (You can use the\nSettings button to hide the tick counter, or change the word “ticks” to\nsomething else.)",[22,7105,7106,7107,7113,7114,7120,7121,7127],{},"In code, to retrieve the current value of the tick counter, use the ",[319,7108,7109],{"displayText":3732,"permalink":3732},[16,7110,3732],{"href":3735,"rel":7111,"className":7112,"dataDisplayText":3732,"target":330,"title":3732},[327],[329],"\nreporter. The ",[319,7115,7116],{"displayText":3577,"permalink":3577},[16,7117,3577],{"href":3645,"rel":7118,"className":7119,"dataDisplayText":3577,"target":330,"title":3577},[327],[329]," command advances the tick counter by 1. The ",[319,7122,7123],{"displayText":1208,"permalink":1208},[16,7124,1208],{"href":3130,"rel":7125,"className":7126,"dataDisplayText":1208,"target":330,"title":1208},[327],[329],"\ncommand clears the tick counter along with everything else.",[22,7129,7130,7131,7137],{},"When the tick counter is clear, it’s an error to try to read or modify it. Use\nthe ",[319,7132,7133],{"displayText":1819,"permalink":1819},[16,7134,1819],{"href":3614,"rel":7135,"className":7136,"dataDisplayText":1819,"target":330,"title":1819},[327],[329]," command when your model is done setting up, to start the\ntick counter.",[22,7139,7140,7141,7147,7148,301],{},"If your model is set to use tick-based updates, then the ",[319,7142,7143],{"displayText":3577,"permalink":3577},[16,7144,3577],{"href":3645,"rel":7145,"className":7146,"dataDisplayText":3577,"target":330,"title":3577},[327],[329]," command will\nusually also update the view. See the later section,\n",[16,7149,7150],{"href":177},"View Updates",[34,7152,7155],{"id":7153,"className":7154},"when-to-tick",[14],[16,7156,7159],{"className":7157,"href":7158},[19],"#when-to-tick","When to tick",[22,7161,860,7162,7168],{},[319,7163,7164],{"displayText":1819,"permalink":1819},[16,7165,1819],{"href":3614,"rel":7166,"className":7167,"dataDisplayText":1819,"target":330,"title":1819},[327],[329]," at the end of your setup procedure.",[22,7170,860,7171,7177],{},[319,7172,7173],{"displayText":3577,"permalink":3577},[16,7174,3577],{"href":3645,"rel":7175,"className":7176,"dataDisplayText":3577,"target":330,"title":3577},[327],[329]," at the end of your go procedure.",[553,7179,7180],{},[556,7181,7182,573,7185,7188,1751,7190,7193,1751,7195,573,7198,7201,1751,7203,7206,7211,7213,573,7218,7221,1751,7223,573,7226,951,7229,573,7232,958,7235,1751,7237,7240],{},[559,7183,1744],{"className":7184},[562,1190],[559,7186,1748],{"className":7187},[562,1001],[566,7189],{},[559,7191,1208],{"className":7192},[562,944],[566,7194],{},[559,7196,1217],{"className":7197},[562,944],[559,7199,1287],{"className":7200},[562,668],[566,7202],{},[559,7204,1819],{"className":7205},[562,944],[559,7207,7209,1825],{"className":7208},[562,1190],[566,7210],{},[566,7212],{},[559,7214,7216,1744],{"className":7215},[562,1190],[566,7217],{},[559,7219,3515],{"className":7220},[562,1001],[566,7222],{},[559,7224,128],{"className":7225},[562,944],[559,7227,289],{"className":7228},[562,571],[559,7230,2893],{"className":7231},[562,944],[559,7233,708],{"className":7234},[562,668],[566,7236],{},[559,7238,3577],{"className":7239},[562,944],[559,7241,7243,1825],{"className":7242},[562,1190],[566,7244],{},[34,7246,7249],{"id":7247,"className":7248},"fractional-ticks",[14],[16,7250,7253],{"className":7251,"href":7252},[19],"#fractional-ticks","Fractional ticks",[22,7255,7256],{},"In most models, the tick counter starts at 0 and goes up 1 at a time, from\ninteger to integer. But it’s also possible for the tick counter to take on\nin-between floating point values.",[22,7258,7259,7260,7268],{},"To advance the tick counter by a fractional amount, use the ",[319,7261,7263],{"displayText":7262,"permalink":7262},"tick-advance",[16,7264,7262],{"href":7265,"rel":7266,"className":7267,"dataDisplayText":7262,"target":330,"title":7262},"/dictionary#tick-advance",[327],[329],"\ncommand. This command takes a numeric input specifying how far to advance the\ntick counter.",[22,7270,7271],{},"A typical use of fractional ticks is to approximate continuous or curved motion.\nSee, for example, the GasLab models in the Models Library (under Chemistry &\nPhysics). These models calculate the exact time at which a future event is to\noccur, then advance the tick counter to exactly that time.",[270,7273,7276],{"id":7274,"className":7275},"view-updates",[14],[16,7277,178],{"className":7278,"href":177},[19],[22,7280,7281],{},"The “view” in NetLogo lets you see the agents in your model on your computer’s\nscreen. As your agents move and change, you see them moving and changing in the\nview.",[22,7283,7284],{},"Of course, you can’t really see your agents directly. The view is a picture that\nNetLogo paints, showing you how your agents look at a particular instant. Once\nthat instant passes and your agents move and change some more, that picture\nneeds to be repainted to reflect the new state of the world. Repainting the\npicture is called “updating” the view.",[22,7286,7287],{},"When does the view get updated? This section discusses how NetLogo decides when\nto update the view, and how you can influence when it gets updated.",[22,7289,7290],{},"NetLogo offers two updates modes, “continuous” updates and “tick-based” updates.\nYou can switch between NetLogo’s two view update modes using a popup menu at the\ntop of the Interface tab.",[22,7292,7293],{},"Continuous updates are the default when you start up NetLogo or start a new\nmodel. Nearly every model in our Models Library, however, uses tick-based\nupdates.",[22,7295,7296],{},"Continuous updates are simplest, but tick-based updates give you more control\nover when and how often updates happen.",[22,7298,7299],{},"It’s important exactly when an update happens, because when updates happen\ndetermines what you see on the screen. If an update comes at an unexpected time,\nyou may see something unexpected — perhaps something confusing or misleading.",[22,7301,7302],{},"It’s also important how often updates happen, because updates take time. The\nmore time NetLogo spends updating the view, the slower your model will run. With\nfewer updates, your model runs faster.",[34,7304,7307],{"id":7305,"className":7306},"continuous-updates",[14],[16,7308,7311],{"className":7309,"href":7310},[19],"#continuous-updates","Continuous updates",[22,7313,7314],{},"Continuous updates are very simple. With continuous updates, NetLogo updates the\nview a certain number of times per second — by default, 30 times a second when\nthe speed slider is in the default, middle setting.",[22,7316,7317],{},"If you move the speed slider to a slower setting, NetLogo will update more than\n30 times a second, effectively slowing down the model. On a faster setting,\nNetLogo will update less than 30 times a second. On the fastest setting, updates\nwill be separated by several seconds.",[22,7319,7320],{},"At extremely slow settings, NetLogo will be updating so often that you will see\nyour agents moving (or changing color, etc.) one at a time.",[22,7322,7323,7324,7332,7333,7341],{},"If you need to temporarily shut off continuous updates, use the ",[319,7325,7327],{"displayText":7326,"permalink":7326},"no-display",[16,7328,7326],{"href":7329,"rel":7330,"className":7331,"dataDisplayText":7326,"target":330,"title":7326},"/dictionary#no-display",[327],[329],"\ncommand. The ",[319,7334,7336],{"displayText":7335,"permalink":7335},"display",[16,7337,7335],{"href":7338,"rel":7339,"className":7340,"dataDisplayText":7335,"target":330,"title":7335},"/dictionary#display",[327],[329]," command turns updates back on, and also forces an\nimmediate update (unless the user is fast-forwarding the model using the speed\nslider).",[34,7343,7346],{"id":7344,"className":7345},"tick-based-updates",[14],[16,7347,7350],{"className":7348,"href":7349},[19],"#tick-based-updates","Tick-based updates",[22,7352,7353,7354,7357],{},"As discussed above in the ",[16,7355,7356],{"href":171},"Tick Counter"," section, in many NetLogo\nmodels, time passes in discrete steps, called “ticks”. Typically, you want the\nview to update once per tick, between ticks. That’s the default behavior with\ntick-based updates.",[22,7359,7360,7361,7367],{},"If you want additional view updates, you can force an update using the\n",[319,7362,7363],{"displayText":7335,"permalink":7335},[16,7364,7335],{"href":7338,"rel":7365,"className":7366,"dataDisplayText":7335,"target":330,"title":7335},[327],[329]," command. (The update may be skipped if the user is fast-forwarding\nthe model using the speed slider.)",[22,7369,7370,7371,7377],{},"You don’t have to use the tick counter to use tick-based updates. If the tick\ncounter never advances, the view will update only when you use the ",[319,7372,7373],{"displayText":7335,"permalink":7335},[16,7374,7335],{"href":7338,"rel":7375,"className":7376,"dataDisplayText":7335,"target":330,"title":7335},[327],[329],"\ncommand.",[22,7379,7380],{},"If you move the speed slider to a fast enough setting, eventually NetLogo will\nskip some of the updates that would ordinarily have happened. Moving the speed\nslider to a slower setting doesn’t cause additional updates; rather, it makes\nNetLogo pause after each update. The slower the setting, the longer the pause.",[22,7382,7383,7384,7390,7391,7397,7398,7404],{},"Even under tick-based updates, the view also updates whenever a button in the\ninterface pops up (both once and forever buttons) and when a command entered in\nthe Command Center finishes. So it’s not necessary to add the ",[319,7385,7386],{"displayText":7335,"permalink":7335},[16,7387,7335],{"href":7338,"rel":7388,"className":7389,"dataDisplayText":7335,"target":330,"title":7335},[327],[329],"\ncommand to once buttons that don’t advance the tick counter. Many forever\nbuttons that don’t advance the tick counter do need to use the ",[319,7392,7393],{"displayText":7335,"permalink":7335},[16,7394,7335],{"href":7338,"rel":7395,"className":7396,"dataDisplayText":7335,"target":330,"title":7335},[327],[329],"\ncommand. An example in the Models Library is the Life model (under Computer\nScience -> Cellular Automata). The forever buttons that let the user draw in the\nview use the ",[319,7399,7400],{"displayText":7335,"permalink":7335},[16,7401,7335],{"href":7338,"rel":7402,"className":7403,"dataDisplayText":7335,"target":330,"title":7335},[327],[329]," command so the user can see what they are drawing, even\nthough the tick counter is not advancing.",[34,7406,7409],{"id":7407,"className":7408},"choosing-a-mode",[14],[16,7410,7413],{"className":7411,"href":7412},[19],"#choosing-a-mode","Choosing a mode",[22,7415,7416],{},"Advantages of tick-based updates over continuous updates include:",[7418,7419,7420,7423,7426],"ol",{},[47,7421,7422],{},"Consistent, predictable view update behavior which does not vary from\ncomputer to computer or from run to run.",[47,7424,7425],{},"Continuous updates can confuse the user of your model by letting them see\nmodel states they aren’t supposed to see, which may be misleading.",[47,7427,7428,7429,7431],{},"Since ",[556,7430,1748],{}," buttons don’t advance the tick counter, they are unaffected by\nthe speed slider; this is normally the desired behavior.",[22,7433,7434],{},"Nearly every model in our Models Library uses tick-based updates.",[22,7436,7437],{},"Continuous updates are occasionally useful for those rare models in which\nexecution is not divided into short, discrete phases. An example in the Models\nLibrary is Termites. (See also, however, the State Machine Example model, which\nshows how to re-code Termites using ticks.)",[22,7439,7440],{},"Even for models that would normally be set to tick-based updates, it may be\nuseful to switch to continuous updates temporarily for debugging purposes.\nSeeing what’s going on within a tick, instead of only seeing the end result of a\ntick, could help with troubleshooting. After switching to continuous updates,\nyou may want to use the speed slider to slow the model down until you see your\nagents moving one at a time. Don’t forget to change back to tick-based updates\nwhen you are done, as the choice of update mode is saved with the model.",[22,7442,7443],{},"Changing the update mode also affects model speed. Updating the view takes time;\noften enforcing a single update per tick (by using tick-based updates) will make\nyour model faster. On the other hand, continuous updates will be faster when\nrunning a single tick is faster than drawing a frame of the model. Most models\nrun faster under tick-based updates, but for an example of a model which is\nfaster with continuous updates see the “Heroes and Cowards” library model.",[34,7445,7448],{"id":7446,"className":7447},"frame-rate",[14],[16,7449,7452],{"className":7450,"href":7451},[19],"#frame-rate","Frame rate",[22,7454,7455],{},"One of the model settings in NetLogo’s “Settings…” dialog is “Frame rate”\nwhich defaults to 30 frames per second.",[22,7457,7458],{},"The frame rate setting affects both continuous updates and tick-based updates.",[22,7460,7461],{},"With continuous updates, the setting directly determines the frequency of\nupdates.",[22,7463,7464,7465,7468],{},"With tick-based updates, the setting is a ",[467,7466,7467],{},"ceiling"," on how many updates per\nsecond you get. If the frame rate is 30, then NetLogo will ensure that the model\nnever runs faster than that when the speed slider is in the default position. If\nany frame takes less than 1/30 of a second to compute and display, NetLogo will\npause and wait until the full 1/30 of a second has passed before continuing.",[22,7470,7471],{},"The frame rate settings lets you set what you consider to be a normal speed for\nyour model. Then you, or the user of your model, can use the speed slider to\ntemporarily get a faster or slower speed.",[270,7473,7476],{"id":7474,"className":7475},"topology",[14],[16,7477,184],{"className":7478,"href":183},[19],[22,7480,7481],{},"The way the world of patches is connected can change. By default the world is a\ntorus which means it isn’t bounded, but “wraps” — so when a turtle moves past\nthe edge of the world, it disappears and reappears on the opposite edge and\nevery patch has the same number of “neighbor” patches. If you’re a patch on the\nedge of the world, some of your “neighbors” are on the opposite edge.",[22,7483,7484],{},"However, you can change the wrap settings with the Settings button. If wrapping\nis not allowed in a given direction then in that direction (x or y) the world is\nbounded. Patches along that boundary will have fewer than 8 neighbors and\nturtles will not move beyond the edge of the world.",[22,7486,7487],{},"The topology of the NetLogo world has four potential values, torus, box,\nvertical cylinder, or horizontal cylinder. The topology is controlled by\nenabling or disabling wrapping in the x or y directions. The default world is a\ntorus.",[22,7489,7490],{},"A torus wraps in both directions, meaning that the top and bottom edges of the\nworld are connected and the left and right edges are connected. So if a turtle\nmoves beyond the right edge of the world it appears again on the left and the\nsame for the top and bottom.",[22,7492,7493],{},"A box does not wrap in either direction. The world is bounded so turtles that\ntry to move off the edge of the world cannot. Note that the patches around edge\nof the world have fewer than eight neighbors; the corners have three and the\nrest have five.",[22,7495,7496],{},"Horizontal and vertical cylinders wrap in one direction but not the other. A\nhorizontal cylinder wraps vertically, so the top of the world is connected to\nthe bottom. but the left and right edges are bounded. A vertical cylinder is the\nopposite; it wraps horizontally so the left and right edges are connected, but\nthe top and bottom edges are bounded.",[1414,7498,7499],{},[22,7500,7501,7503],{},[281,7502,1420],{}," Neighbors Example",[22,7505,7506],{},"When coordinates wrap, turtles and links wrap visually in the view, too. If a\nturtle shape or link extends past an edge, part of it will appear at the other\nedge. (Turtles themselves are points that take up no space, so they cannot be on\nboth sides of the world at once, but in the view, they appear to take up space\nbecause they have a shape.)",[22,7508,7509,7510],{},"Wrapping also affects how the view looks when you are following a turtle. On a\ntorus, wherever the turtle goes, you will always see the whole world around it:\n",[2749,7511],{"alt":7512,"className":7513,"src":7514,"width":7515,"height":7515,"style":7516},"programming/torus.png",[2753],"/_content/images/programming/torus.png",300,{"aspectRatio":7517},"300/300",[22,7519,7520,7521],{},"Whereas in a box or cylinder the world has edges, so the areas past those edges\nshow up in the view as gray: ",[2749,7522],{"alt":7523,"className":7524,"src":7525,"width":7515,"height":7515,"style":7526},"programming/box.png",[2753],"/_content/images/programming/box.png",{"aspectRatio":7517},[1414,7528,7529],{},[22,7530,7531,7533],{},[281,7532,1420],{}," Termites Perspective Demo (torus), Ants Perspective Demo\n(box)",[22,7535,7536],{},"The topology settings also control the behavior of the distance(xy), in-radius,\nin-cone, face(xy), and towards(xy) primitives. The topology controls whether the\nprimitives wrap or not. They always use the shortest path allowed by the\ntopology. For example, the distance from the center of the patches in the bottom\nleft corner (min-pxcor, min-pycor) and the upper right corner (max-pxcor,\nmax-pycor) will be as follows for each topology given that the min and max pxcor\nand pycor are +/-2:",[44,7538,7539,7542,7545,7548],{},[47,7540,7541],{},"Torus - sqrt(2) ~ 1.414 (this will be the same for all world sizes since the\npatches are directly diagonal to each other in a torus.)",[47,7543,7544],{},"Box - sqrt(world-width^2 + world-height^2) ~ 7.07",[47,7546,7547],{},"Vertical Cylinder - sqrt(world-height^2 + 1) ~ 5.099",[47,7549,7550],{},"Horizontal Cylinder - sqrt(world-width^2 + 1) ~ 5.099",[22,7552,7553,7554,7557],{},"All the other primitives will act similarly to distance. If you formerly used\n",[556,7555,7556],{},"-nowrap"," primitives in your model we recommend removing them and changing the\ntopology of the world instead.",[22,7559,7560,7561,3341],{},"If your model has turtles that move around you’ll need to think about what\nhappens to them when they reach the edge of the world, if the topology you’re\nusing has some non-wrapping edges. There are a few common options: the turtle is\nreflected back into the world (either systematically or randomly), the turtle\nexits the system (dies), or the turtle is hidden. It is no longer necessary to\ncheck the bounds using turtle coordinates, instead we can just ask NetLogo if a\nturtle is at the edge of the world. There are a couple ways of doing this, the\nsimplest is to use the ",[319,7562,7564],{"displayText":7563,"permalink":7563},"can-move?",[16,7565,7563],{"href":7566,"rel":7567,"className":7568,"dataDisplayText":7563,"target":330,"title":7563},"/dictionary#can-move",[327],[329],[553,7570,7571],{},[556,7572,7573,573,7576,573,7579,573,7582,951,7586,573,7589,958],{},[559,7574,1615],{"className":7575},[562,944],[559,7577,5494],{"className":7578},[562,571],[559,7580,7563],{"className":7581},[562,571],[559,7583,7585],{"className":7584},[562,571],"distance",[559,7587,3542],{"className":7588},[562,944],[559,7590,7592],{"className":7591},[562,668],"180",[22,7594,7595,7596,7598,7599,7615,7616,7622,7623,7629,7630,409,7639,301],{},"can-move? merely returns true if the position ",[467,7597,7585],{}," in front of the turtle\nis inside the NetLogo world, false otherwise. In this case, if the turtle is at\nthe edge of the world it simple goes back the way it came. You can also use\n",[556,7600,7601,573,7605,573,7608,573,7611],{},[559,7602,7604],{"className":7603},[562,571],"patch-ahead",[559,7606,708],{"className":7607},[562,668],[559,7609,1136],{"className":7610},[562,571],[559,7612,7614],{"className":7613},[562,618],"nobody"," in place of ",[319,7617,7618],{"displayText":7563,"permalink":7563},[16,7619,7563],{"href":7566,"rel":7620,"className":7621,"dataDisplayText":7563,"target":330,"title":7563},[327],[329],". If you need to do something\nsmarter that simply turning around it may be useful to use ",[319,7624,7625],{"displayText":4176,"permalink":4176},[16,7626,4176],{"href":4179,"rel":7627,"className":7628,"dataDisplayText":4176,"target":330,"title":4176},[327],[329]," with\n",[319,7631,7634],{"displayText":7632,"permalink":7633},"dx","dxy",[16,7635,7632],{"href":7636,"rel":7637,"className":7638,"dataDisplayText":7632,"target":330,"title":7632},"/dictionary#dxy",[327],[329],[319,7640,7642],{"displayText":7641,"permalink":7633},"dy",[16,7643,7641],{"href":7636,"rel":7644,"className":7645,"dataDisplayText":7641,"target":330,"title":7641},[327],[329],[553,7647,7648],{},[556,7649,7650,573,7653,573,7656,573,7659,573,7662,573,7665,606,7668,1751,7670,573,7673,774,7676,573,7679,784,7682,620,7684,7686,573,7689,573,7692,573,7695,573,7698,573,7701,606,7704,1751,7706,573,7709,774,7712,573,7715,573,7718,784,7721,620],{},[559,7651,1615],{"className":7652},[562,944],[559,7654,4176],{"className":7655},[562,571],[559,7657,7632],{"className":7658},[562,571],[559,7660,669],{"className":7661},[562,668],[559,7663,614],{"className":7664},[562,571],[559,7666,7614],{"className":7667},[562,618],[566,7669],{},[559,7671,1230],{"className":7672},[562,944],[559,7674,2218],{"className":7675},[562,571],[559,7677,3920],{"className":7678},[562,571],[559,7680,2218],{"className":7681},[562,571],[566,7683],{},[566,7685],{},[559,7687,1615],{"className":7688},[562,944],[559,7690,4176],{"className":7691},[562,571],[559,7693,669],{"className":7694},[562,668],[559,7696,7641],{"className":7697},[562,571],[559,7699,614],{"className":7700},[562,571],[559,7702,7614],{"className":7703},[562,618],[566,7705],{},[559,7707,1230],{"className":7708},[562,944],[559,7710,2218],{"className":7711},[562,571],[559,7713,7592],{"className":7714},[562,668],[559,7716,3920],{"className":7717},[562,571],[559,7719,2218],{"className":7720},[562,571],[566,7722],{},[22,7724,7725],{},"This tests whether the turtle is hitting a horizontal or vertical wall and\nbounces off that wall.",[22,7727,7728],{},"In some models if a turtle can’t move forward it simply dies (exits the system,\nlike in Conductor or Mousetraps).",[553,7730,7731],{},[556,7732,7733,573,7736,573,7739,573,7742,6210,7745,958],{},[559,7734,1615],{"className":7735},[562,944],[559,7737,5494],{"className":7738},[562,571],[559,7740,7563],{"className":7741},[562,571],[559,7743,7585],{"className":7744},[562,571],[559,7746,1007],{"className":7747},[562,944],[22,7749,7750,7751,7753,7754,7756,7757,7759],{},"If you are moving turtles using ",[556,7752,2910],{}," rather than ",[556,7755,2894],{}," you should test to\nmake sure the patch you are about to move to exists since ",[556,7758,2910],{}," throws a\nruntime error if it is given coordinates outside the world. This is a common\nsituation when the model is simulating an infinite plane and turtles outside the\nview should simply be hidden.",[553,7761,7762],{},[556,7763,7764,573,7767,573,7771,7775,7777,573,7780,573,7784,7788,7790,7792,573,7795,774,7798,573,7801,573,7804,7807,7808,573,7811,573,7814,769,7817,573,7820,7823,4557,7825,958,7829,4557,7831,573,7834,573,7837,7840,940,7842,958],{},[559,7765,2456],{"className":7766},[562,944],[559,7768,7770],{"className":7769},[562,1001],"new-x",[559,7772,7774],{"className":7773},[562,1001],"new-value-of-xcor",[566,7776],{},[559,7778,2456],{"className":7779},[562,944],[559,7781,7783],{"className":7782},[562,1001],"new-y",[559,7785,7787],{"className":7786},[562,1001],"new-value-of-ycor",[566,7789],{},[566,7791],{},[559,7793,3893],{"className":7794},[562,944],[559,7796,4176],{"className":7797},[562,571],[559,7799,7770],{"className":7800},[562,1001],[559,7802,3920],{"className":7803},[562,571],[559,7805,435],{"className":7806},[562,571],") (",[559,7809,7783],{"className":7810},[562,1001],[559,7812,3920],{"className":7813},[562,571],[559,7815,443],{"className":7816},[562,571],[559,7818,614],{"className":7819},[562,571],[559,7821,7614],{"className":7822},[562,618],[566,7824],{},[559,7826,7828],{"className":7827},[562,944],"hide-turtle",[566,7830],{},[559,7832,2910],{"className":7833},[562,944],[559,7835,7770],{"className":7836},[562,1001],[559,7838,7783],{"className":7839},[562,1001],[566,7841],{},[559,7843,7845],{"className":7844},[562,944],"show-turtle",[22,7847,7848],{},"Several models in the Models Library use this technique, Gravitation, N-Bodies,\nand Electrostatics are good examples.",[22,7850,1376,7851,409,7854,7857,7858,7860],{},[556,7852,7853],{},"diffuse",[556,7855,7856],{},"diffuse4"," commands behave correctly in all topologies. Each\npatch diffuses and equal amount of the diffuse variable to each of its\nneighbors, if it has fewer than 8 neighbors (or 4 if you are using ",[556,7859,7856],{},"),\nthe remainder stays on the diffusing patch. This means that the overall sum of\npatch-variable across the world remains constant. However, if you want the\ndiffuse matter to still fall off the edges of the world as it would on an\ninfinite plane you still need to clear the edges each step as in the Diffuse Off\nEdges Example.",[262,7862,7865],{"id":7863,"className":7864},"observer-perspective",[14],[16,7866,190],{"className":7867,"href":189},[19],[22,7869,7870,7871,290,7879,409,7887,7895,7896,396,7904,409,7912,7920,7921,7927,7928,7936,7937,7945],{},"The 2D and the 3D view show the world from the perspective of the observer. By\ndefault the observer is looking down on the world from the positive z-axis at\nthe origin. You can change the perspective of the observer by using the\n",[319,7872,7874],{"displayText":7873,"permalink":7873},"follow",[16,7875,7873],{"href":7876,"rel":7877,"className":7878,"dataDisplayText":7873,"target":330,"title":7873},"/dictionary#follow",[327],[329],[319,7880,7882],{"displayText":7881,"permalink":7881},"ride",[16,7883,7881],{"href":7884,"rel":7885,"className":7886,"dataDisplayText":7881,"target":330,"title":7881},"/dictionary#ride",[327],[329],[319,7888,7890],{"displayText":7889,"permalink":7889},"watch",[16,7891,7889],{"href":7892,"rel":7893,"className":7894,"dataDisplayText":7889,"target":330,"title":7889},"/dictionary#watch",[327],[329]," observer commands and ",[319,7897,7899],{"displayText":7898,"permalink":7898},"follow-me",[16,7900,7898],{"href":7901,"rel":7902,"className":7903,"dataDisplayText":7898,"target":330,"title":7898},"/dictionary#follow-me",[327],[329],[319,7905,7907],{"displayText":7906,"permalink":7906},"ride-me",[16,7908,7906],{"href":7909,"rel":7910,"className":7911,"dataDisplayText":7906,"target":330,"title":7906},"/dictionary#ride-me",[327],[329],[319,7913,7915],{"displayText":7914,"permalink":7914},"watch-me",[16,7916,7914],{"href":7917,"rel":7918,"className":7919,"dataDisplayText":7914,"target":330,"title":7914},"/dictionary#watch-me",[327],[329]," turtle commands. ",[319,7922,7923],{"displayText":7914,"permalink":7914},[16,7924,7914],{"href":7917,"rel":7925,"className":7926,"dataDisplayText":7914,"target":330,"title":7914},[327],[329]," is also a patch or\nlink command. When in follow or ride mode the observer moves with the subject\nagent around the world. The difference between follow and ride is only visible\nin the 3D view. In the 3D view the user can change the distance behind the agent\nusing the mouse. When the observer is following at zero distance from the agent\nit is actually riding the agent. When the observer is in watch mode it tracks\nthe movements of one turtle (or patch or link) without moving. In both views you\nwill see a spotlight appear on the subject and in the 3D view the observer will\nturn to face the subject. To determine which agent is the focus you can use the\n",[319,7929,7931],{"displayText":7930,"permalink":7930},"subject",[16,7932,7930],{"href":7933,"rel":7934,"className":7935,"dataDisplayText":7930,"target":330,"title":7930},"/dictionary#subject",[327],[329]," reporter. Use the ",[319,7938,7940],{"displayText":7939,"permalink":7939},"reset-perspective",[16,7941,7939],{"href":7942,"rel":7943,"className":7944,"dataDisplayText":7939,"target":330,"title":7939},"/dictionary#reset-perspective",[327],[329]," command to stop the observer\nfrom watching, following, or riding. In the 3D view, the observer also returns\nto its default position (above the origin, looking straight down).",[1414,7947,7948],{},[22,7949,7950,7952],{},[281,7951,1420],{}," Perspective Example",[262,7954,7957],{"id":7955,"className":7956},"inputoutput",[14],[16,7958,196],{"className":7959,"href":195},[19],[270,7961,7963],{"id":5782,"className":7962},[14],[16,7964,204],{"className":7965,"href":203},[19],[22,7967,7968,7969,7978,7979,301],{},"This section is about output to the screen. Output to the screen can also be\nlater saved to a file using the ",[319,7970,7973],{"displayText":7971,"permalink":7972},"export-output","export-cmds",[16,7974,7971],{"href":7975,"rel":7976,"className":7977,"dataDisplayText":7971,"target":330,"title":7971},"/dictionary#export-cmds",[327],[329]," command. If you\nneed a more flexible method of writing data to external files, see the next\nsection, ",[16,7980,210],{"href":209},[22,7982,7983,7984,396,7991,290,7998,1573,8006,8014],{},"The basic commands for generating output to the screen in NetLogo are ",[319,7985,7986],{"displayText":1245,"permalink":1245},[16,7987,1245],{"href":7988,"rel":7989,"className":7990,"dataDisplayText":1245,"target":330,"title":1245},"/dictionary#print",[327],[329],[319,7992,7993],{"displayText":1050,"permalink":1050},[16,7994,1050],{"href":7995,"rel":7996,"className":7997,"dataDisplayText":1050,"target":330,"title":1050},"/dictionary#show",[327],[329],[319,7999,8001],{"displayText":8000,"permalink":8000},"type",[16,8002,8000],{"href":8003,"rel":8004,"className":8005,"dataDisplayText":8000,"target":330,"title":8000},"/dictionary#type",[327],[329],[319,8007,8009],{"displayText":8008,"permalink":8008},"write",[16,8010,8008],{"href":8011,"rel":8012,"className":8013,"dataDisplayText":8008,"target":330,"title":8008},"/dictionary#write",[327],[329],". These commands send their output to the\nCommand Center.",[22,8016,8017],{},"For full details on these four commands, see their entries in the NetLogo\nDictionary. Here is how they are typically used:",[44,8019,8020,8027,8034,8041],{},[47,8021,8022,8026],{},[559,8023,8024],{},[559,8025,1245],{}," is useful in most situations.",[47,8028,8029,8033],{},[559,8030,8031],{},[559,8032,1050],{}," lets you see which agent is printing what.",[47,8035,8036,8040],{},[559,8037,8038],{},[559,8039,8000],{}," lets you print several things on the same line.",[47,8042,8043,8047,8048,301],{},[559,8044,8045],{},[559,8046,8008],{}," lets you print values in a format which can be read back in using\n",[319,8049,8051],{"displayText":8050,"permalink":8050},"file-read",[16,8052,8050],{"href":8053,"rel":8054,"className":8055,"dataDisplayText":8050,"target":330,"title":8050},"/dictionary#file-read",[327],[329],[22,8057,8058,8059,290,8068,396,8075,1573,8082,8089],{},"A NetLogo model may optionally have an “output area” in its Interface tab,\nseparate from the Command Center. To send output there instead of the Command\nCenter, use the ",[319,8060,8063],{"displayText":8061,"permalink":8062},"output-print","output-cmds",[16,8064,8061],{"href":8065,"rel":8066,"className":8067,"dataDisplayText":8061,"target":330,"title":8061},"/dictionary#output-cmds",[327],[329],[319,8069,8071],{"displayText":8070,"permalink":8062},"output-show",[16,8072,8070],{"href":8065,"rel":8073,"className":8074,"dataDisplayText":8070,"target":330,"title":8070},[327],[329],[319,8076,8078],{"displayText":8077,"permalink":8062},"output-type",[16,8079,8077],{"href":8065,"rel":8080,"className":8081,"dataDisplayText":8077,"target":330,"title":8077},[327],[329],[319,8083,8085],{"displayText":8084,"permalink":8062},"output-write",[16,8086,8084],{"href":8065,"rel":8087,"className":8088,"dataDisplayText":8084,"target":330,"title":8084},[327],[329]," commands.",[22,8091,8092,8093,8101,8102,8108,8109,8116,8117,8124],{},"The output area can be cleared with the ",[319,8094,8096],{"displayText":8095,"permalink":8095},"clear-output",[16,8097,8095],{"href":8098,"rel":8099,"className":8100,"dataDisplayText":8095,"target":330,"title":8095},"/dictionary#clear-output",[327],[329]," command and saved to a\nfile with ",[319,8103,8104],{"displayText":7971,"permalink":7972},[16,8105,7971],{"href":7975,"rel":8106,"className":8107,"dataDisplayText":7971,"target":330,"title":7971},[327],[329],". The contents of the output area will be\nsaved by the ",[319,8110,8112],{"displayText":8111,"permalink":7972},"export-world",[16,8113,8111],{"href":7975,"rel":8114,"className":8115,"dataDisplayText":8111,"target":330,"title":8111},[327],[329]," command. The ",[319,8118,8119],{"displayText":6718,"permalink":6718},[16,8120,6718],{"href":8121,"rel":8122,"className":8123,"dataDisplayText":6718,"target":330,"title":6718},"/dictionary#import-world",[327],[329]," command\nwill clear the output area and set its contents to the value in imported world\nfile. It should be noted that large amounts of data being sent to the output\narea can increase the size of your exported worlds.",[22,8126,8127,8128,290,8134,396,8140,290,8146,290,8152,8158,8159,8165],{},"If you use ",[319,8129,8130],{"displayText":8061,"permalink":8062},[16,8131,8061],{"href":8065,"rel":8132,"className":8133,"dataDisplayText":8061,"target":330,"title":8061},[327],[329],[319,8135,8136],{"displayText":8070,"permalink":8062},[16,8137,8070],{"href":8065,"rel":8138,"className":8139,"dataDisplayText":8070,"target":330,"title":8070},[327],[329],[319,8141,8142],{"displayText":8077,"permalink":8062},[16,8143,8077],{"href":8065,"rel":8144,"className":8145,"dataDisplayText":8077,"target":330,"title":8077},[327],[329],[319,8147,8148],{"displayText":8084,"permalink":8062},[16,8149,8084],{"href":8065,"rel":8150,"className":8151,"dataDisplayText":8084,"target":330,"title":8084},[327],[329],[319,8153,8154],{"displayText":8095,"permalink":8095},[16,8155,8095],{"href":8098,"rel":8156,"className":8157,"dataDisplayText":8095,"target":330,"title":8095},[327],[329],", or\n",[319,8160,8161],{"displayText":7971,"permalink":7972},[16,8162,7971],{"href":7975,"rel":8163,"className":8164,"dataDisplayText":7971,"target":330,"title":7971},[327],[329]," in a model which does not have a separate output\narea, then the commands apply to the output portion of the Command Center.",[34,8167,8170],{"id":8168,"className":8169},"how-output-primitives-differ",[14],[16,8171,8174],{"className":8172,"href":8173},[19],"#how-output-primitives-differ","How Output Primitives Differ",[22,8176,8177],{},"This information is a quick reference for more advanced users.",[22,8179,1376,8180,290,8186,290,8192,1573,8198,8204],{},[319,8181,8182],{"displayText":1245,"permalink":1245},[16,8183,1245],{"href":7988,"rel":8184,"className":8185,"dataDisplayText":1245,"target":330,"title":1245},[327],[329],[319,8187,8188],{"displayText":1050,"permalink":1050},[16,8189,1050],{"href":7995,"rel":8190,"className":8191,"dataDisplayText":1050,"target":330,"title":1050},[327],[329],[319,8193,8194],{"displayText":8000,"permalink":8000},[16,8195,8000],{"href":8003,"rel":8196,"className":8197,"dataDisplayText":8000,"target":330,"title":8000},[327],[329],[319,8199,8200],{"displayText":8008,"permalink":8008},[16,8201,8008],{"href":8011,"rel":8202,"className":8203,"dataDisplayText":8008,"target":330,"title":8008},[327],[329]," primitives differ on the\nfollowing facets:",[44,8206,8207,8210,8213,8216],{},[47,8208,8209],{},"What types of values does the primitive accept?",[47,8211,8212],{},"Does the primitive output a newline at the end?",[47,8214,8215],{},"Are strings output with quotes surrounding them?",[47,8217,8218],{},"Does the primitive output the agent which printed it?",[22,8220,8221],{},"The following table summarizes the behavior of each primitive.",[29,8223,8225],{"className":8224},[5829],[5831,8226,8227,8249],{},[6895,8228,8229],{},[5838,8230,8231,8234,8237,8240,8243],{},[5842,8232,8233],{},"Primitive",[5842,8235,8236],{},"Acceptable values",[5842,8238,8239],{},"Adds newline?",[5842,8241,8242],{},"Strings quoted?",[5842,8244,8245,8246,6555],{},"Outputs ",[556,8247,8248],{},"self",[5835,8250,8251,8272,8290,8308],{},[5838,8252,8253,8261,8264,8267,8270],{},[5851,8254,8255],{},[319,8256,8257],{"displayText":1245,"permalink":1245},[16,8258,1245],{"href":7988,"rel":8259,"className":8260,"dataDisplayText":1245,"target":330,"title":1245},[327],[329],[5851,8262,8263],{},"any NetLogo value",[5851,8265,8266],{},"yes",[5851,8268,8269],{},"no",[5851,8271,8269],{},[5838,8273,8274,8282,8284,8286,8288],{},[5851,8275,8276],{},[319,8277,8278],{"displayText":1050,"permalink":1050},[16,8279,1050],{"href":7995,"rel":8280,"className":8281,"dataDisplayText":1050,"target":330,"title":1050},[327],[329],[5851,8283,8263],{},[5851,8285,8266],{},[5851,8287,8266],{},[5851,8289,8266],{},[5838,8291,8292,8300,8302,8304,8306],{},[5851,8293,8294],{},[319,8295,8296],{"displayText":8000,"permalink":8000},[16,8297,8000],{"href":8003,"rel":8298,"className":8299,"dataDisplayText":8000,"target":330,"title":8000},[327],[329],[5851,8301,8263],{},[5851,8303,8269],{},[5851,8305,8269],{},[5851,8307,8269],{},[5838,8309,8310,8318,8321,8323,8325],{},[5851,8311,8312],{},[319,8313,8314],{"displayText":8008,"permalink":8008},[16,8315,8008],{"href":8011,"rel":8316,"className":8317,"dataDisplayText":8008,"target":330,"title":8008},[327],[329],[5851,8319,8320],{},"boolean, number, string, lists containing only these types",[5851,8322,8269],{},[5851,8324,8266],{},[5851,8326,8269],{},[34,8328,8331],{"id":8329,"className":8330},"user-interaction-primitives",[14],[16,8332,8335],{"className":8333,"href":8334},[19],"#user-interaction-primitives","User Interaction Primitives",[22,8337,8338,8339,396,8343,396,8347,396,8351,396,8355,396,8359,2719,8363,301],{},"NetLogo features several primitives which allow a model to interact with the\nuser. These primitives include ",[16,8340,8342],{"href":8341},"dictionary#user-directory","user-directory",[16,8344,8346],{"href":8345},"dictionary#user-file","user-file",[16,8348,8350],{"href":8349},"dictionary#user-new-file","user-new-file",[16,8352,8354],{"href":8353},"dictionary#user-input","user-input",[16,8356,8358],{"href":8357},"dictionary#user-message","user-message",[16,8360,8362],{"href":8361},"dictionary#user-one-of","user-one-of",[16,8364,8366],{"href":8365},"dictionary#user-yes-or-no","user-yes-or-no?",[22,8368,8369,8370,290,8372,1573,8374,8376,8377,290,8379,1573,8381,8383,8384,8386],{},"These primitives differ in precisely what interaction they take with the user.\n",[556,8371,8342],{},[556,8373,8346],{},[556,8375,8350],{}," are all reporters which\nprompt the user to select an item from the file system and report the path of\nthe selected item to NetLogo. ",[556,8378,8366],{},[556,8380,8362],{},[556,8382,8354],{},"\nall prompt the user to provide input in the form of text or a selection.\n",[556,8385,8358],{}," simply presents a message to the user.",[22,8388,8389],{},"Note that all active forever buttons will pause when one of these primitives is\nused and will resume only when the user completes the interaction with the\nbutton.",[34,8391,8394],{"id":8392,"className":8393},"what-does-halt-mean",[14],[16,8395,8398],{"className":8396,"href":8397},[19],"#what-does-halt-mean","What does “Halt” mean?",[22,8400,8401,8402,8404],{},"The primitives which prompt the user for input, as well as ",[556,8403,8358],{}," all\nprovide a “Halt” button. The effect of this button is the same for all of these\nprimitives - it halts the model. When the model is halted all running code is\nstopped, including buttons and the command center. Since halting stops code in\nthe middle of whatever it happened to be doing at the time it was halted, you\nmay see strange results if you continue to run the model after a halt without\nsetting it up again.",[270,8406,8409],{"id":8407,"className":8408},"file-io",[14],[16,8410,210],{"className":8411,"href":209},[19],[22,8413,8414,8415,301],{},"In NetLogo, there is a set of primitives that give you the power to interact\nwith outside files. They all begin with the prefix ",[281,8416,8417],{},"file-",[22,8419,8420],{},"There are two main modes when dealing with files: reading and writing. The\ndifference is the direction of the flow of data. When you are reading in\ninformation from a file, data that is stored in the file flows into your model.\nOn the other hand, writing allows data to flow out of your model and into a\nfile.",[22,8422,8423,8424,8432],{},"When working with files, always begin by using the primitive ",[319,8425,8427],{"displayText":8426,"permalink":8426},"file-open",[16,8428,8426],{"href":8429,"rel":8430,"className":8431,"dataDisplayText":8426,"target":330,"title":8426},"/dictionary#file-open",[327],[329],". This\nspecifies which file you will be interacting with. None of the other primitives\nwork unless you open a file first.",[22,8434,8435,8436,8438],{},"The next ",[281,8437,8417],{}," primitive you use dictates which mode the file will be in\nuntil the file is closed, reading or writing. To switch modes, close and then\nreopen the file.",[22,8440,8441,8442,290,8448,396,8456,1573,8464,8472],{},"The reading primitives include ",[319,8443,8444],{"displayText":8050,"permalink":8050},[16,8445,8050],{"href":8053,"rel":8446,"className":8447,"dataDisplayText":8050,"target":330,"title":8050},[327],[329],[319,8449,8451],{"displayText":8450,"permalink":8450},"file-read-line",[16,8452,8450],{"href":8453,"rel":8454,"className":8455,"dataDisplayText":8450,"target":330,"title":8450},"/dictionary#file-read-line",[327],[329],[319,8457,8459],{"displayText":8458,"permalink":8458},"file-read-characters",[16,8460,8458],{"href":8461,"rel":8462,"className":8463,"dataDisplayText":8458,"target":330,"title":8458},"/dictionary#file-read-characters",[327],[329],[319,8465,8467],{"displayText":8466,"permalink":8466},"file-at-end?",[16,8468,8466],{"href":8469,"rel":8470,"className":8471,"dataDisplayText":8466,"target":330,"title":8466},"/dictionary#file-at-end",[327],[329],". Note that the file must exist\nalready before you can open it for reading.",[1414,8474,8475],{},[22,8476,8477,8479],{},[281,8478,2831],{}," File Input Example",[22,8481,8482,8483,290,8491,290,8499,1573,8507,8515,8516,8524],{},"The primitives for writing are similar to the primitives that print things in\nthe Command Center, except that the output gets saved to a file. They include\n",[319,8484,8486],{"displayText":8485,"permalink":8485},"file-print",[16,8487,8485],{"href":8488,"rel":8489,"className":8490,"dataDisplayText":8485,"target":330,"title":8485},"/dictionary#file-print",[327],[329],[319,8492,8494],{"displayText":8493,"permalink":8493},"file-show",[16,8495,8493],{"href":8496,"rel":8497,"className":8498,"dataDisplayText":8493,"target":330,"title":8493},"/dictionary#file-show",[327],[329],[319,8500,8502],{"displayText":8501,"permalink":8501},"file-type",[16,8503,8501],{"href":8504,"rel":8505,"className":8506,"dataDisplayText":8501,"target":330,"title":8501},"/dictionary#file-type",[327],[329],[319,8508,8510],{"displayText":8509,"permalink":8509},"file-write",[16,8511,8509],{"href":8512,"rel":8513,"className":8514,"dataDisplayText":8509,"target":330,"title":8509},"/dictionary#file-write",[327],[329],". Note that you\ncan never “overwrite” data. In other words, if you attempt to write to a file\nwith existing data, all new data will be appended to the end of the file. (If\nyou want to overwrite a file, use ",[319,8517,8519],{"displayText":8518,"permalink":8518},"file-delete",[16,8520,8518],{"href":8521,"rel":8522,"className":8523,"dataDisplayText":8518,"target":330,"title":8518},"/dictionary#file-delete",[327],[329]," to delete it, then open it for\nwriting.)",[1414,8526,8527],{},[22,8528,8529,8531],{},[281,8530,2831],{}," File Output Example",[22,8533,8534,8535,8543,8544,8550,8551,8557],{},"When you are finished using a file, you can use the command ",[319,8536,8538],{"displayText":8537,"permalink":8537},"file-close",[16,8539,8537],{"href":8540,"rel":8541,"className":8542,"dataDisplayText":8537,"target":330,"title":8537},"/dictionary#file-close",[327],[329]," to\nend your session with the file. If you wish to remove the file afterwards, use\nthe primitive ",[319,8545,8546],{"displayText":8518,"permalink":8518},[16,8547,8518],{"href":8521,"rel":8548,"className":8549,"dataDisplayText":8518,"target":330,"title":8518},[327],[329]," to delete it. To close multiple opened files, one\nneeds to first select the file by using ",[319,8552,8553],{"displayText":8426,"permalink":8426},[16,8554,8426],{"href":8429,"rel":8555,"className":8556,"dataDisplayText":8426,"target":330,"title":8426},[327],[329]," before closing it.",[553,8559,8560],{},[556,8561,8562,8566,8568,573,8571,8575,8577,573,8580,8584,8586,573,8589,8593,8595,8597,8601,8603,8606,8608,573,8611,8614,8616,8619,8621,573,8624,8627,8629],{},[559,8563,8565],{"className":8564},[562,563],";; Open 3 files",[566,8567],{},[559,8569,8426],{"className":8570},[562,944],[559,8572,8574],{"className":8573},[562,2994],"\"myfile1.txt\"",[566,8576],{},[559,8578,8426],{"className":8579},[562,944],[559,8581,8583],{"className":8582},[562,2994],"\"myfile2.txt\"",[566,8585],{},[559,8587,8426],{"className":8588},[562,944],[559,8590,8592],{"className":8591},[562,2994],"\"myfile3.txt\"",[566,8594],{},[566,8596],{},[559,8598,8600],{"className":8599},[562,563],";; Now close the 3 files",[566,8602],{},[559,8604,8537],{"className":8605},[562,944],[566,8607],{},[559,8609,8426],{"className":8610},[562,944],[559,8612,8583],{"className":8613},[562,2994],[566,8615],{},[559,8617,8537],{"className":8618},[562,944],[566,8620],{},[559,8622,8426],{"className":8623},[562,944],[559,8625,8574],{"className":8626},[562,2994],[566,8628],{},[559,8630,8537],{"className":8631},[562,944],[22,8633,8634,8635,301],{},"Or, if you know you just want to close every file, you can use\n",[319,8636,8638],{"displayText":8637,"permalink":8637},"file-close-all",[16,8639,8637],{"href":8640,"rel":8641,"className":8642,"dataDisplayText":8637,"target":330,"title":8637},"/dictionary#file-close-all",[327],[329],[22,8644,8645,8646,409,8652,8658],{},"Two primitives worth noting are ",[319,8647,8648],{"displayText":8509,"permalink":8509},[16,8649,8509],{"href":8512,"rel":8650,"className":8651,"dataDisplayText":8509,"target":330,"title":8509},[327],[329],[319,8653,8654],{"displayText":8050,"permalink":8050},[16,8655,8050],{"href":8053,"rel":8656,"className":8657,"dataDisplayText":8050,"target":330,"title":8050},[327],[329]," . These\nprimitives are designed to easily save and retrieve NetLogo constants such as\nnumbers, lists, booleans, and strings. file-write will always output the\nvariable in such a manner that file-read will be able to interpret it correctly.",[553,8660,8661],{},[556,8662,8663,573,8666,1751,8670,8674,8676,573,8679,8682,4557,8684,573,8687,573,8690,573,8693,958,8696,8698,8701,8703,8705,573,8708,1751,8711,8715,8717,573,8720,8723,4557,8725,573,8728,573,8731,958,8734,8736],{},[559,8664,8426],{"className":8665},[562,944],[559,8667,8669],{"className":8668},[562,2994],"\"myfile.txt\"",[559,8671,8673],{"className":8672},[562,563],";; Opening file for writing",[566,8675],{},[559,8677,128],{"className":8678},[562,944],[559,8680,289],{"className":8681},[562,571],[566,8683],{},[559,8685,8509],{"className":8686},[562,944],[559,8688,435],{"className":8689},[562,571],[559,8691,8509],{"className":8692},[562,944],[559,8694,443],{"className":8695},[562,571],[566,8697],{},[559,8699,8537],{"className":8700},[562,944],[566,8702],{},[566,8704],{},[559,8706,8426],{"className":8707},[562,944],[559,8709,8669],{"className":8710},[562,2994],[559,8712,8714],{"className":8713},[562,563],";; Opening file for reading",[566,8716],{},[559,8718,128],{"className":8719},[562,944],[559,8721,289],{"className":8722},[562,571],[566,8724],{},[559,8726,2910],{"className":8727},[562,944],[559,8729,8050],{"className":8730},[562,571],[559,8732,8050],{"className":8733},[562,571],[566,8735],{},[559,8737,8537],{"className":8738},[562,944],[1414,8740,8741],{},[22,8742,8743,8745],{},[281,8744,2831],{}," File Input Example and File Output Example",[22,8747,8748],{},[281,8749,8750],{},"Letting the user choose",[22,8752,1376,8753,290,8760,1573,8767,8774],{},[319,8754,8755],{"displayText":8342,"permalink":8342},[16,8756,8342],{"href":8757,"rel":8758,"className":8759,"dataDisplayText":8342,"target":330,"title":8342},"/dictionary#user-directory",[327],[329],[319,8761,8762],{"displayText":8346,"permalink":8346},[16,8763,8346],{"href":8764,"rel":8765,"className":8766,"dataDisplayText":8346,"target":330,"title":8346},"/dictionary#user-file",[327],[329],[319,8768,8769],{"displayText":8350,"permalink":8350},[16,8770,8350],{"href":8771,"rel":8772,"className":8773,"dataDisplayText":8350,"target":330,"title":8350},"/dictionary#user-new-file",[327],[329]," primitives are\nuseful when you want the user to choose a file or directory for your code to\noperate on.",[262,8776,8779],{"id":8777,"className":8778},"lists",[14],[16,8780,216],{"className":8781,"href":215},[19],[22,8783,8784],{},"In the simplest models, each variable holds only one piece of information,\nusually a number or a string. Lists let you store multiple pieces of information\nin a single value by collecting that information in a list. Each value in the\nlist can be any type of value: a number, or a string, an agent or agentset, or\neven another list.",[22,8786,8787],{},"Lists allow for the convenient packaging of information in NetLogo. If your\nagents carry out a repetitive calculation on multiple variables, it might be\neasier to have a list variable, instead of multiple number variables. Several\nprimitives simplify the process of performing the same computation on each value\nin a list.",[22,8789,1376,8790,8793],{},[16,8791,8792],{"href":3429},"NetLogo Dictionary"," has a section that lists all of the\nlist-related primitives.",[22,8795,8796],{},[281,8797,8798],{},"Constant lists",[22,8800,8801,8802,8823,8824,301],{},"You can make a list by simply putting the values you want in the list between\nbrackets, like this: ",[556,8803,8804,573,8807,606,8810,573,8813,573,8816,573,8820,620],{},[559,8805,1230],{"className":8806},[562,944],[559,8808,6272],{"className":8809},[562,1001],[559,8811,4283],{"className":8812},[562,668],[559,8814,6481],{"className":8815},[562,668],[559,8817,8819],{"className":8818},[562,668],"6",[559,8821,3838],{"className":8822},[562,668],". Note that the individual values are\nseparated by spaces. You can make lists that contain numbers and strings this\nway, as well as lists within lists, for example ",[556,8825,8826,8827,573,8830,712,8833,573,8836,732],{},"[[",[559,8828,4283],{"className":8829},[562,668],[559,8831,6481],{"className":8832},[562,668],[559,8834,688],{"className":8835},[562,668],[559,8837,1221],{"className":8838},[562,668],[22,8840,8841,8842,301],{},"The empty list is written by putting nothing between the brackets, like this:\n",[556,8843,8844],{},"[]",[22,8846,8847],{},[281,8848,8849],{},"Building lists on the fly",[22,8851,8852,8853,8859,8860,8866],{},"If you want to make a list in which the values are determined by reporters, as\nopposed to being a series of constants, use the ",[319,8854,8855],{"displayText":5385,"permalink":5385},[16,8856,5385],{"href":5400,"rel":8857,"className":8858,"dataDisplayText":5385,"target":330,"title":5385},[327],[329]," reporter. The ",[319,8861,8862],{"displayText":5385,"permalink":5385},[16,8863,5385],{"href":5400,"rel":8864,"className":8865,"dataDisplayText":5385,"target":330,"title":5385},[327],[329],"\nreporter accepts two other reporters, runs them, and reports the results as a\nlist.",[22,8868,8869],{},"If I wanted a list to contain two random values, I might use the following code:",[553,8871,8872],{},[556,8873,8874,573,8877,573,8881,774,8884,573,8887,7807,8890,573,8893,784],{},[559,8875,1230],{"className":8876},[562,944],[559,8878,8880],{"className":8879},[562,1001],"random-list",[559,8882,5385],{"className":8883},[562,571],[559,8885,1790],{"className":8886},[562,571],[559,8888,1287],{"className":8889},[562,668],[559,8891,1790],{"className":8892},[562,571],[559,8894,4725],{"className":8895},[562,668],[22,8897,8898,8899,8901],{},"This will set ",[556,8900,8880],{}," to a new list of two random integers each time it\nruns.",[22,8903,8904,8905,8911],{},"To make longer or shorter lists, you can use the ",[319,8906,8907],{"displayText":5385,"permalink":5385},[16,8908,5385],{"href":5400,"rel":8909,"className":8910,"dataDisplayText":5385,"target":330,"title":5385},[327],[329]," reporter with fewer or\nmore than two inputs, but in order to do so, you must enclose the entire call in\nparentheses, e.g.:",[553,8913,8914],{},[556,8915,5381,8916,573,8919,573,8922,784,8925,5381,8927,573,8930,573,8933,573,8936,573,8939,573,8942,573,8945,784],{},[559,8917,5385],{"className":8918},[562,571],[559,8920,1790],{"className":8921},[562,571],[559,8923,1287],{"className":8924},[562,668],[566,8926],{},[559,8928,5385],{"className":8929},[562,571],[559,8931,1790],{"className":8932},[562,571],[559,8934,1287],{"className":8935},[562,668],[559,8937,1790],{"className":8938},[562,571],[559,8940,4725],{"className":8941},[562,668],[559,8943,1790],{"className":8944},[562,571],[559,8946,8948],{"className":8947},[562,668],"30",[22,8950,8951,8952,301],{},"For more information, see ",[16,8953,8955],{"href":8954},"#variadic","Varying number of inputs",[22,8957,8958,8959,8966],{},"Some kinds of lists are most easily built using the ",[319,8960,8961],{"displayText":6256,"permalink":6256},[16,8962,6256],{"href":8963,"rel":8964,"className":8965,"dataDisplayText":6256,"target":330,"title":6256},"/dictionary#n-values",[327],[329]," reporter, which\nallows you to construct a list of a specific length by repeatedly running a\ngiven reporter. You can make a list of the same value repeated, or all the\nnumbers in a range, or a lot of random numbers, or many other possibilities. See\ndictionary entry for details and examples.",[22,8968,1376,8969,8975,8976,8982],{},[319,8970,8971],{"displayText":834,"permalink":834},[16,8972,834],{"href":1026,"rel":8973,"className":8974,"dataDisplayText":834,"target":330,"title":834},[327],[329]," primitive lets you construct a list from an agentset. It reports a\nlist containing each agent’s value for the given reporter. (The reporter could\nbe a simple variable name, or a more complex expression — even a call to a\nprocedure defined using ",[319,8977,8978],{"displayText":3447,"permalink":3447},[16,8979,3447],{"href":3450,"rel":8980,"className":8981,"dataDisplayText":3447,"target":330,"title":3447},[327],[329],".) A common idiom is",[553,8984,8985],{},[556,8986,8987,606,8991,830,8994,573,8997,9000,9002,606,9005,830,9008,573,9011],{},[559,8988,8990],{"className":8989},[562,571],"max",[559,8992,1629],{"className":8993},[562,1001],[559,8995,834],{"className":8996},[562,571],[559,8998,289],{"className":8999},[562,571],[566,9001],{},[559,9003,997],{"className":9004},[562,571],[559,9006,1629],{"className":9007},[562,1001],[559,9009,834],{"className":9010},[562,571],[559,9012,289],{"className":9013},[562,571],[22,9015,9016],{},"and so on.",[22,9018,9019,9020,9028,9029,290,9035,9041],{},"You can combine two or more lists using the ",[319,9021,9023],{"displayText":9022,"permalink":9022},"sentence",[16,9024,9022],{"href":9025,"rel":9026,"className":9027,"dataDisplayText":9022,"target":330,"title":9022},"/dictionary#sentence",[327],[329]," reporter, which\nconcatenates lists by combining their contents into a single, larger list. Like\n",[319,9030,9031],{"displayText":5385,"permalink":5385},[16,9032,5385],{"href":5400,"rel":9033,"className":9034,"dataDisplayText":5385,"target":330,"title":5385},[327],[329],[319,9036,9037],{"displayText":9022,"permalink":9022},[16,9038,9022],{"href":9025,"rel":9039,"className":9040,"dataDisplayText":9022,"target":330,"title":9022},[327],[329]," normally takes two inputs, but can accept any number of\ninputs if the call is surrounded by parentheses.",[22,9043,9044],{},[281,9045,9046],{},"Changing list items",[22,9048,9049,9050,9056],{},"Technically, lists can’t be modified, but you can construct new lists based on\nold lists. If you want the new list to replace the old list, use ",[319,9051,9052],{"displayText":1230,"permalink":1230},[16,9053,1230],{"href":2334,"rel":9054,"className":9055,"dataDisplayText":1230,"target":330,"title":1230},[327],[329],". For\nexample:",[553,9058,9059],{},[556,9060,9061,573,9064,606,9067,573,9070,573,9074,573,9077,606,9081,573,9084,573,9087,732,9090,9092,9096,9098,573,9101,573,9104,573,9108,573,9111,573,9114,9117,9119],{},[559,9062,1230],{"className":9063},[562,944],[559,9065,6272],{"className":9066},[562,1001],[559,9068,4283],{"className":9069},[562,668],[559,9071,9073],{"className":9072},[562,668],"7",[559,9075,1221],{"className":9076},[562,668],[559,9078,9080],{"className":9079},[562,1001],"Bob",[559,9082,688],{"className":9083},[562,668],[559,9085,669],{"className":9086},[562,668],[559,9088,4316],{"className":9089},[562,668],[566,9091],{},[559,9093,9095],{"className":9094},[562,563],"; mylist is now [2 7 5 Bob [3 0 -2]]",[566,9097],{},[559,9099,1230],{"className":9100},[562,944],[559,9102,6272],{"className":9103},[562,1001],[559,9105,9107],{"className":9106},[562,571],"replace-item",[559,9109,4283],{"className":9110},[562,668],[559,9112,6272],{"className":9113},[562,1001],[559,9115,1287],{"className":9116},[562,668],[566,9118],{},[559,9120,9122],{"className":9121},[562,563],"; mylist is now [2 7 10 Bob [3 0 -2]]",[22,9124,1376,9125,9132],{},[319,9126,9127],{"displayText":9107,"permalink":9107},[16,9128,9107],{"href":9129,"rel":9130,"className":9131,"dataDisplayText":9107,"target":330,"title":9107},"/dictionary#replace-item",[327],[329]," reporter takes three inputs. The first input specifies\nwhich item in the list is to be changed. 0 means the first item, 1 means the\nsecond item, and so forth.",[22,9134,9135,9136,9144,9145,9153],{},"To add an item, say 42, to the end of a list, use the ",[319,9137,9139],{"displayText":9138,"permalink":9138},"lput",[16,9140,9138],{"href":9141,"rel":9142,"className":9143,"dataDisplayText":9138,"target":330,"title":9138},"/dictionary#lput",[327],[329]," reporter.\n(",[319,9146,9148],{"displayText":9147,"permalink":9147},"fput",[16,9149,9147],{"href":9150,"rel":9151,"className":9152,"dataDisplayText":9147,"target":330,"title":9147},"/dictionary#fput",[327],[329]," adds an item to the beginning of a list.)",[553,9155,9156],{},[556,9157,9158,573,9161,573,9164,573,9167,573,9171,9174,9176],{},[559,9159,1230],{"className":9160},[562,944],[559,9162,6272],{"className":9163},[562,1001],[559,9165,9138],{"className":9166},[562,571],[559,9168,9170],{"className":9169},[562,668],"42",[559,9172,6272],{"className":9173},[562,1001],[566,9175],{},[559,9177,9179],{"className":9178},[562,563],"; mylist is now [2 7 10 Bob [3 0 -2] 42]",[22,9181,9182,9183,774,9192,9195],{},"But what if you changed your mind? The ",[319,9184,9187],{"displayText":9185,"permalink":9186},"but-last","but-first-and-last",[16,9188,9185],{"href":9189,"rel":9190,"className":9191,"dataDisplayText":9185,"target":330,"title":9185},"/dictionary#but-first-and-last",[327],[329],[556,9193,9194],{},"bl"," for\nshort) reporter reports all the list items but the last.",[553,9197,9198],{},[556,9199,9200,573,9203,573,9206,573,9209,9212,9214],{},[559,9201,1230],{"className":9202},[562,944],[559,9204,6272],{"className":9205},[562,1001],[559,9207,9185],{"className":9208},[562,571],[559,9210,6272],{"className":9211},[562,1001],[566,9213],{},[559,9215,9122],{"className":9216},[562,563],[22,9218,9219],{},"Suppose you want to get rid of item 0, the 2 at the beginning of the list.",[553,9221,9222],{},[556,9223,9224,573,9227,573,9230,573,9234,9237,9239],{},[559,9225,1230],{"className":9226},[562,944],[559,9228,6272],{"className":9229},[562,1001],[559,9231,9233],{"className":9232},[562,571],"but-first",[559,9235,6272],{"className":9236},[562,1001],[566,9238],{},[559,9240,9242],{"className":9241},[562,563],"; mylist is now [7 10 Bob [3 0 -2]]",[22,9244,9245,9246,9249,9250,9262,9263,9269],{},"Suppose you wanted to change the third item that’s nested inside item 3 from -2\nto 9? The key is to realize that the name that can be used to call the nested\nlist ",[559,9247,9248],{},"3 0 -2"," is ",[556,9251,9252,573,9256,573,9259],{},[559,9253,9255],{"className":9254},[562,571],"item",[559,9257,688],{"className":9258},[562,668],[559,9260,6272],{"className":9261},[562,1001],". Then the ",[319,9264,9265],{"displayText":9107,"permalink":9107},[16,9266,9107],{"href":9129,"rel":9267,"className":9268,"dataDisplayText":9107,"target":330,"title":9107},[327],[329]," reporter can be\nnested to change the list-within-a-list. The parentheses are added for clarity.",[553,9271,9272],{},[556,9273,9274,573,9277,774,9280,573,9283,573,9286,9289,9291,9292,573,9295,774,9298,573,9301,573,9304,769,9307,9311,9312,9314],{},[559,9275,1230],{"className":9276},[562,944],[559,9278,6272],{"className":9279},[562,1001],[559,9281,9107],{"className":9282},[562,571],[559,9284,688],{"className":9285},[562,668],[559,9287,6272],{"className":9288},[562,1001],[566,9290],{},"                  (",[559,9293,9107],{"className":9294},[562,571],[559,9296,4283],{"className":9297},[562,668],[559,9299,9255],{"className":9300},[562,571],[559,9302,688],{"className":9303},[562,668],[559,9305,6272],{"className":9306},[562,1001],[559,9308,9310],{"className":9309},[562,668],"9","))",[566,9313],{},[559,9315,9317],{"className":9316},[562,563],"; mylist is now [7 10 Bob [3 0 9]]",[22,9319,9320],{},[281,9321,9322],{},"Iterating over lists",[22,9324,9325,9326,9333,9334,9341],{},"If you want to do some operation on each item in a list in turn, the ",[319,9327,9328],{"displayText":6244,"permalink":6244},[16,9329,6244],{"href":9330,"rel":9331,"className":9332,"dataDisplayText":6244,"target":330,"title":6244},"/dictionary#foreach",[327],[329],"\ncommand and the ",[319,9335,9336],{"displayText":6247,"permalink":6247},[16,9337,6247],{"href":9338,"rel":9339,"className":9340,"dataDisplayText":6247,"target":330,"title":6247},"/dictionary#map",[327],[329]," reporter may be helpful.",[22,9343,9344,9350],{},[319,9345,9346],{"displayText":6244,"permalink":6244},[16,9347,6244],{"href":9330,"rel":9348,"className":9349,"dataDisplayText":6244,"target":330,"title":6244},[327],[329]," is used to run a command or commands on each item in a list. It\ntakes an input list and a command name or block of commands, like this:",[553,9352,9353],{},[556,9354,9355,606,9358,573,9361,573,9364,830,9367,9370,9372,573,9376,9379,9381,573,9384,9387,9389,573,9392,9395,9397,606,9400,573,9403,573,9406,620,9409,4557,9411,573,9415,573,9418,573,9421,9424,940,9426,774,9429,573,9433,573,9437,573,9440,3924,9444,9446,573,9449,573,9453,573,9456,9459,9461,573,9464,573,9467,573,9470,9473,9475,573,9478,573,9481,573,9484],{},[559,9356,6244],{"className":9357},[562,944],[559,9359,708],{"className":9360},[562,668],[559,9362,4283],{"className":9363},[562,668],[559,9365,688],{"className":9366},[562,668],[559,9368,1050],{"className":9369},[562,944],[566,9371],{},[559,9373,9375],{"className":9374},[562,1001],"=>",[559,9377,708],{"className":9378},[562,668],[566,9380],{},[559,9382,9375],{"className":9383},[562,1001],[559,9385,4283],{"className":9386},[562,668],[566,9388],{},[559,9390,9375],{"className":9391},[562,1001],[559,9393,688],{"className":9394},[562,668],[566,9396],{},[559,9398,6244],{"className":9399},[562,944],[559,9401,4283],{"className":9402},[562,668],[559,9404,6481],{"className":9405},[562,668],[559,9407,8819],{"className":9408},[562,668],[566,9410],{},[559,9412,9414],{"className":9413},[562,1001],"n",[559,9416,5946],{"className":9417},[562,571],[559,9419,4203],{"className":9420},[562,944],[559,9422,9414],{"className":9423},[562,1001],[566,9425],{},[559,9427,1050],{"className":9428},[562,944],[559,9430,9432],{"className":9431},[562,571],"word",[559,9434,9436],{"className":9435},[562,2994],"\"created \"",[559,9438,9414],{"className":9439},[562,1001],[559,9441,9443],{"className":9442},[562,2994],"\" turtles\"",[566,9445],{},[559,9447,9375],{"className":9448},[562,1001],[559,9450,9452],{"className":9451},[562,1001],"created",[559,9454,4283],{"className":9455},[562,668],[559,9457,289],{"className":9458},[562,571],[566,9460],{},[559,9462,9375],{"className":9463},[562,1001],[559,9465,9452],{"className":9466},[562,1001],[559,9468,6481],{"className":9469},[562,668],[559,9471,289],{"className":9472},[562,571],[566,9474],{},[559,9476,9375],{"className":9477},[562,1001],[559,9479,9452],{"className":9480},[562,1001],[559,9482,8819],{"className":9483},[562,668],[559,9485,289],{"className":9486},[562,571],[22,9488,9489,9490,9492],{},"In the block, the variable ",[556,9491,9414],{}," holds the current value from the input list.",[22,9494,9495,9496,9502],{},"Here are some more examples of ",[319,9497,9498],{"displayText":6244,"permalink":6244},[16,9499,6244],{"href":9330,"rel":9500,"className":9501,"dataDisplayText":6244,"target":330,"title":6244},[327],[329],":",[553,9504,9505],{},[556,9506,9507,606,9510,573,9513,573,9516,1003,9519,573,9522,573,9525,573,9528,951,9531,573,9534,4535,9537,9539,9543,9545,606,9548,573,9551,573,9554,573,9557,1003,9560,573,9564,573,9567,573,9570,951,9573,573,9576,951,9579,573,9582,9585,9586,9588],{},[559,9508,6244],{"className":9509},[562,944],[559,9511,708],{"className":9512},[562,668],[559,9514,4283],{"className":9515},[562,668],[559,9517,688],{"className":9518},[562,668],[559,9520,4948],{"className":9521},[562,1001],[559,9523,5946],{"className":9524},[562,571],[559,9526,128],{"className":9527},[562,944],[559,9529,289],{"className":9530},[562,571],[559,9532,2893],{"className":9533},[562,944],[559,9535,4948],{"className":9536},[562,1001],[566,9538],{},[559,9540,9542],{"className":9541},[562,563],";; turtles move forward 6 patches",[566,9544],{},[559,9546,6244],{"className":9547},[562,944],[559,9549,5575],{"className":9550},[562,618],[559,9552,5582],{"className":9553},[562,618],[559,9555,5575],{"className":9556},[562,618],[559,9558,5575],{"className":9559},[562,618],[559,9561,9563],{"className":9562},[562,1001],"should-move?",[559,9565,5946],{"className":9566},[562,571],[559,9568,128],{"className":9569},[562,944],[559,9571,289],{"className":9572},[562,571],[559,9574,1615],{"className":9575},[562,944],[559,9577,9563],{"className":9578},[562,1001],[559,9580,2893],{"className":9581},[562,944],[559,9583,708],{"className":9584},[562,668]," ] ] ]",[566,9587],{},[559,9589,9591],{"className":9590},[562,563],";; turtles move forward 3 patches",[22,9593,9594,9600,9601,9607,9608,9614],{},[319,9595,9596],{"displayText":6247,"permalink":6247},[16,9597,6247],{"href":9338,"rel":9598,"className":9599,"dataDisplayText":6247,"target":330,"title":6247},[327],[329]," is similar to ",[319,9602,9603],{"displayText":6244,"permalink":6244},[16,9604,6244],{"href":9330,"rel":9605,"className":9606,"dataDisplayText":6244,"target":330,"title":6244},[327],[329],", but it is a reporter. It takes an input list\nand a reporter name or reporter block. Note that unlike ",[319,9609,9610],{"displayText":6244,"permalink":6244},[16,9611,6244],{"href":9330,"rel":9612,"className":9613,"dataDisplayText":6244,"target":330,"title":6244},[327],[329],", the\nreporter comes first, like this:",[553,9616,9617],{},[556,9618,9619,573,9622,573,9625,606,9629,573,9633,573,9637,620,9641,9643],{},[559,9620,1050],{"className":9621},[562,944],[559,9623,6247],{"className":9624},[562,571],[559,9626,9628],{"className":9627},[562,571],"round",[559,9630,9632],{"className":9631},[562,668],"1.2",[559,9634,9636],{"className":9635},[562,668],"2.2",[559,9638,9640],{"className":9639},[562,668],"2.7",[566,9642],{},[559,9644,9646],{"className":9645},[562,563],";; prints [1 2 3]",[22,9648,9649,9655,9656,9658],{},[319,9650,9651],{"displayText":6247,"permalink":6247},[16,9652,6247],{"href":9338,"rel":9653,"className":9654,"dataDisplayText":6247,"target":330,"title":6247},[327],[329]," reports a list containing the results of applying the reporter to each\nitem in the input list. Again, use the variable named in the anonymous procedure\n(",[556,9657,5702],{}," in the examples below) to refer to the current item in the list.",[22,9660,9661,9662,9502],{},"Here are a couple more examples of ",[319,9663,9664],{"displayText":6247,"permalink":6247},[16,9665,6247],{"href":9338,"rel":9666,"className":9667,"dataDisplayText":6247,"target":330,"title":6247},[327],[329],[553,9669,9670],{},[556,9671,9672,573,9675,951,9678,573,9681,573,9684,573,9687,573,9690,9693,9694,573,9697,573,9700,573,9703,573,9706,573,9709,620,9713,9715,9719,9721,573,9724,951,9727,573,9730,573,9733,573,9736,573,9739,9693,9742,573,9745,573,9748,620,9751,9753],{},[559,9673,1050],{"className":9674},[562,944],[559,9676,6247],{"className":9677},[562,571],[559,9679,5702],{"className":9680},[562,1001],[559,9682,5946],{"className":9683},[562,571],[559,9685,5702],{"className":9686},[562,1001],[559,9688,5524],{"className":9689},[562,571],[559,9691,669],{"className":9692},[562,668]," ] [",[559,9695,708],{"className":9696},[562,668],[559,9698,722],{"className":9699},[562,668],[559,9701,688],{"className":9702},[562,668],[559,9704,6481],{"className":9705},[562,668],[559,9707,4316],{"className":9708},[562,668],[559,9710,9712],{"className":9711},[562,668],"-10",[566,9714],{},[559,9716,9718],{"className":9717},[562,563],";; prints [false true false false true true]",[566,9720],{},[559,9722,1050],{"className":9723},[562,944],[559,9725,6247],{"className":9726},[562,571],[559,9728,5702],{"className":9729},[562,1001],[559,9731,5946],{"className":9732},[562,571],[559,9734,5702],{"className":9735},[562,1001],[559,9737,5418],{"className":9738},[562,571],[559,9740,5702],{"className":9741},[562,1001],[559,9743,708],{"className":9744},[562,668],[559,9746,4283],{"className":9747},[562,668],[559,9749,688],{"className":9750},[562,668],[566,9752],{},[559,9754,9756],{"className":9755},[562,563],";; prints [1 4 9]",[22,9758,9759,9760,409,9762,9764,9765,290,9772,1573,9779,301],{},"Besides ",[556,9761,6247],{},[556,9763,6244],{},", other primitives for processing whole lists in a\nconfigurable way include ",[319,9766,9767],{"displayText":6253,"permalink":6253},[16,9768,6253],{"href":9769,"rel":9770,"className":9771,"dataDisplayText":6253,"target":330,"title":6253},"/dictionary#filter",[327],[329],[319,9773,9774],{"displayText":6250,"permalink":6250},[16,9775,6250],{"href":9776,"rel":9777,"className":9778,"dataDisplayText":6250,"target":330,"title":6250},"/dictionary#reduce",[327],[329],[319,9780,9781],{"displayText":6259,"permalink":6259},[16,9782,6259],{"href":9783,"rel":9784,"className":9785,"dataDisplayText":6259,"target":330,"title":6259},"/dictionary#sort-by",[327],[329],[22,9787,9788,9789,530,9796,9802],{},"These primitives aren’t always the solution for every situation in which you\nwant to operate on an entire list. In some situations, you may need to use some\nother technique such as a loop using ",[319,9790,9791],{"displayText":3784,"permalink":3784},[16,9792,3784],{"href":9793,"rel":9794,"className":9795,"dataDisplayText":3784,"target":330,"title":3784},"/dictionary#repeat",[327],[329],[319,9797,9798],{"displayText":4974,"permalink":4974},[16,9799,4974],{"href":5940,"rel":9800,"className":9801,"dataDisplayText":4974,"target":330,"title":4974},[327],[329],", or a recursive\nprocedure.",[22,9804,9805,9806,409,9808,9810,9811,9814,9815,9817],{},"The blocks of code we’re giving to ",[556,9807,6247],{},[556,9809,6244],{}," in these examples are\nactually ",[281,9812,9813],{},"anonymous procedures",". Anonymous procedures are explained in more\ndetail in ",[16,9816,158],{"href":157},", below.",[22,9819,9820],{},[281,9821,8955],{},[22,9823,9824],{},"Some commands and reporters involving lists and strings may take a varying\nnumber of inputs. In these cases, in order to pass them a number of inputs other\nthan their default, the primitive and its inputs must be surrounded by\nparentheses. Here are some examples:",[553,9826,9827],{},[556,9828,9829,573,9832,573,9835,573,9838,9841,9843,606,9846,573,9849,620,9852,9854,774,9857,573,9860,573,9863,573,9866,573,9869,784,9872,9874,606,9877,573,9880,573,9883,573,9886,620,9889,9891,774,9894,784,9897,9899,9902],{},[559,9830,1050],{"className":9831},[562,944],[559,9833,5385],{"className":9834},[562,571],[559,9836,708],{"className":9837},[562,668],[559,9839,4283],{"className":9840},[562,668],[566,9842],{},[559,9844,9375],{"className":9845},[562,1001],[559,9847,708],{"className":9848},[562,668],[559,9850,4283],{"className":9851},[562,668],[566,9853],{},[559,9855,1050],{"className":9856},[562,944],[559,9858,5385],{"className":9859},[562,571],[559,9861,708],{"className":9862},[562,668],[559,9864,4283],{"className":9865},[562,668],[559,9867,688],{"className":9868},[562,668],[559,9870,6481],{"className":9871},[562,668],[566,9873],{},[559,9875,9375],{"className":9876},[562,1001],[559,9878,708],{"className":9879},[562,668],[559,9881,4283],{"className":9882},[562,668],[559,9884,688],{"className":9885},[562,668],[559,9887,6481],{"className":9888},[562,668],[566,9890],{},[559,9892,1050],{"className":9893},[562,944],[559,9895,5385],{"className":9896},[562,571],[566,9898],{},[559,9900,9375],{"className":9901},[562,1001]," []",[22,9904,9905,9906,290,9912,290,9919,290,9925,290,9931,290,9937,2719,9943,301],{},"Note that each of these special primitives has a default number of inputs for\nwhich no parentheses are required. The primitives which have this capability are\n",[319,9907,9908],{"displayText":5385,"permalink":5385},[16,9909,5385],{"href":5400,"rel":9910,"className":9911,"dataDisplayText":5385,"target":330,"title":5385},[327],[329],[319,9913,9914],{"displayText":9432,"permalink":9432},[16,9915,9432],{"href":9916,"rel":9917,"className":9918,"dataDisplayText":9432,"target":330,"title":9432},"/dictionary#word",[327],[329],[319,9920,9921],{"displayText":9022,"permalink":9022},[16,9922,9022],{"href":9025,"rel":9923,"className":9924,"dataDisplayText":9022,"target":330,"title":9022},[327],[329],[319,9926,9927],{"displayText":6247,"permalink":6247},[16,9928,6247],{"href":9338,"rel":9929,"className":9930,"dataDisplayText":6247,"target":330,"title":6247},[327],[329],[319,9932,9933],{"displayText":6244,"permalink":6244},[16,9934,6244],{"href":9330,"rel":9935,"className":9936,"dataDisplayText":6244,"target":330,"title":6244},[327],[329],[319,9938,9939],{"displayText":5891,"permalink":5891},[16,9940,5891],{"href":5922,"rel":9941,"className":9942,"dataDisplayText":5891,"target":330,"title":5891},[327],[329],[319,9944,9945],{"displayText":5951,"permalink":5891},[16,9946,5951],{"href":5922,"rel":9947,"className":9948,"dataDisplayText":5951,"target":330,"title":5951},[327],[329],[22,9950,9951],{},[281,9952,9953],{},"Lists of agents",[22,9955,9956],{},"Earlier, we said that agentsets are always in random order, a different random\norder every time. If you need your agents to do something in a fixed order, you\nneed to make a list of the agents instead.",[22,9958,9959,9960,409,9968,301],{},"There are two primitives that help you do this, ",[319,9961,9963],{"displayText":9962,"permalink":9962},"sort",[16,9964,9962],{"href":9965,"rel":9966,"className":9967,"dataDisplayText":9962,"target":330,"title":9962},"/dictionary#sort",[327],[329],[319,9969,9970],{"displayText":6259,"permalink":6259},[16,9971,6259],{"href":9783,"rel":9972,"className":9973,"dataDisplayText":6259,"target":330,"title":6259},[327],[329],[22,9975,9976,9977,409,9983,9989],{},"Both ",[319,9978,9979],{"displayText":9962,"permalink":9962},[16,9980,9962],{"href":9965,"rel":9981,"className":9982,"dataDisplayText":9962,"target":330,"title":9962},[327],[329],[319,9984,9985],{"displayText":6259,"permalink":6259},[16,9986,6259],{"href":9783,"rel":9987,"className":9988,"dataDisplayText":6259,"target":330,"title":6259},[327],[329]," can take an agentset as input. The result is\nalways a new list, containing the same agents as the agentset did, but in a\nparticular order.",[22,9991,8127,9992,9998,9999,10006],{},[319,9993,9994],{"displayText":9962,"permalink":9962},[16,9995,9962],{"href":9965,"rel":9996,"className":9997,"dataDisplayText":9962,"target":330,"title":9962},[327],[329]," on an agentset of turtles, the result is a list of turtles\nsorted in ascending order by ",[319,10000,10001],{"displayText":3842,"permalink":3842},[16,10002,3842],{"href":10003,"rel":10004,"className":10005,"dataDisplayText":3842,"target":330,"title":3842},"/dictionary#who",[327],[329]," number.",[22,10008,8127,10009,10015],{},[319,10010,10011],{"displayText":9962,"permalink":9962},[16,10012,9962],{"href":9965,"rel":10013,"className":10014,"dataDisplayText":9962,"target":330,"title":9962},[327],[329]," on an agentset of patches, the result is a list of patches\nsorted left-to-right, top-to-bottom.",[22,10017,8127,10018,10024,10025,10031,10032,10038],{},[319,10019,10020],{"displayText":9962,"permalink":9962},[16,10021,9962],{"href":9965,"rel":10022,"className":10023,"dataDisplayText":9962,"target":330,"title":9962},[327],[329]," on an agentset of links, the result is a list of links,\nsorted in ascending order first by ",[319,10026,10027],{"displayText":2662,"permalink":2662},[16,10028,2662],{"href":2859,"rel":10029,"className":10030,"dataDisplayText":2662,"target":330,"title":2662},[327],[329]," then by ",[319,10033,10034],{"displayText":2665,"permalink":2665},[16,10035,2665],{"href":2866,"rel":10036,"className":10037,"dataDisplayText":2665,"target":330,"title":2665},[327],[329]," any remaining ties\nare resolved by breed in the order they are declared in the Code tab.",[22,10040,10041,10042,10050,10051,10057,10058,301],{},"If you need descending order instead, you can combine ",[319,10043,10045],{"displayText":10044,"permalink":10044},"reverse",[16,10046,10044],{"href":10047,"rel":10048,"className":10049,"dataDisplayText":10044,"target":330,"title":10044},"/dictionary#reverse",[327],[329]," with ",[319,10052,10053],{"displayText":9962,"permalink":9962},[16,10054,9962],{"href":9965,"rel":10055,"className":10056,"dataDisplayText":9962,"target":330,"title":9962},[327],[329],",\nfor example ",[556,10059,10060,573,10063,573,10066],{},[559,10061,10044],{"className":10062},[562,571],[559,10064,9962],{"className":10065},[562,571],[559,10067,289],{"className":10068},[562,571],[22,10070,10071,10072,10078,10079,3176],{},"If you want your agents to be ordered by some other criterion than the standard\nones ",[319,10073,10074],{"displayText":9962,"permalink":9962},[16,10075,9962],{"href":9965,"rel":10076,"className":10077,"dataDisplayText":9962,"target":330,"title":9962},[327],[329]," uses, you’ll need to use ",[319,10080,10081],{"displayText":6259,"permalink":6259},[16,10082,6259],{"href":9783,"rel":10083,"className":10084,"dataDisplayText":6259,"target":330,"title":6259},[327],[329],[22,10086,10087],{},"Here’s an example:",[553,10089,10090],{},[556,10091,10092,6285,10095,573,10098,830,10101,606,10104,830,10108,573,10111,573,10114,606,10117,830,10120,573,10123,2136,10126],{},[559,10093,6259],{"className":10094},[562,571],[559,10096,16],{"className":10097},[562,1001],[559,10099,6371],{"className":10100},[562,1001],[559,10102,5946],{"className":10103},[562,571],[559,10105,10107],{"className":10106},[562,571],"size",[559,10109,834],{"className":10110},[562,571],[559,10112,16],{"className":10113},[562,1001],[559,10115,5524],{"className":10116},[562,571],[559,10118,10107],{"className":10119},[562,571],[559,10121,834],{"className":10122},[562,571],[559,10124,6371],{"className":10125},[562,1001],[559,10127,289],{"className":10128},[562,571],[22,10130,10131,10132,301],{},"This returns a list of turtles sorted in ascending order by their turtle\nvariable ",[319,10133,10134],{"displayText":10107,"permalink":10107},[16,10135,10107],{"href":10136,"rel":10137,"className":10138,"dataDisplayText":10107,"target":330,"title":10107},"/dictionary#size",[327],[329],[22,10140,10141,10142,409,10148,10155,10156,9502],{},"There’s a common pattern to get a list of agents in a random order, using a\ncombination of ",[319,10143,10144],{"displayText":834,"permalink":834},[16,10145,834],{"href":1026,"rel":10146,"className":10147,"dataDisplayText":834,"target":330,"title":834},[327],[329],[319,10149,10150],{"displayText":8248,"permalink":8248},[16,10151,8248],{"href":10152,"rel":10153,"className":10154,"dataDisplayText":8248,"target":330,"title":8248},"/dictionary#self",[327],[329],", in the rare case that you cannot just use\n",[319,10157,10158],{"displayText":128,"permalink":128},[16,10159,128],{"href":515,"rel":10160,"className":10161,"dataDisplayText":128,"target":330,"title":128},[327],[329],[553,10163,10164],{},[556,10165,825,10166,830,10169,573,10172],{},[559,10167,8248],{"className":10168},[562,571],[559,10170,834],{"className":10171},[562,571],[559,10173,10175],{"className":10174},[562,1001],"my-agentset",[22,10177,10178],{},[281,10179,10180],{},"Asking a list of agents",[22,10182,10183,10184,409,10190,10196],{},"Once you have a list of agents, you might want to ask them each to do something.\nTo do this, use the ",[319,10185,10186],{"displayText":6244,"permalink":6244},[16,10187,6244],{"href":9330,"rel":10188,"className":10189,"dataDisplayText":6244,"target":330,"title":6244},[327],[329],[319,10191,10192],{"displayText":128,"permalink":128},[16,10193,128],{"href":515,"rel":10194,"className":10195,"dataDisplayText":128,"target":330,"title":128},[327],[329]," commands in combination, like this:",[553,10198,10199],{},[556,10200,10201,573,10204,573,10207,951,10210,573,10214,10217,1751,10219,573,10222,606,10225,940,10227,10230,3571,10232,620],{},[559,10202,6244],{"className":10203},[562,944],[559,10205,9962],{"className":10206},[562,571],[559,10208,289],{"className":10209},[562,571],[559,10211,10213],{"className":10212},[562,1001],"the-turtle",[559,10215,5946],{"className":10216},[562,571],[566,10218],{},[559,10220,128],{"className":10221},[562,944],[559,10223,10213],{"className":10224},[562,1001],[566,10226],{},[559,10228,1629],{"className":10229},[562,1001],[566,10231],{},[566,10233],{},[22,10235,10236],{},"This will ask each turtle in ascending order by who number. Substitute “patches”\nfor “turtles” to ask patches in left-to-right, top-to-bottom order.",[22,10238,10239,10240,10246,10247,10253],{},"Note that you can’t use ",[319,10241,10242],{"displayText":128,"permalink":128},[16,10243,128],{"href":515,"rel":10244,"className":10245,"dataDisplayText":128,"target":330,"title":128},[327],[329]," directly on a list of turtles. ",[319,10248,10249],{"displayText":128,"permalink":128},[16,10250,128],{"href":515,"rel":10251,"className":10252,"dataDisplayText":128,"target":330,"title":128},[327],[329]," only\nworks with agentsets and single agents.",[22,10255,10256],{},[281,10257,10258],{},"Performance of lists",[22,10260,10261,10262,290,10264,290,10266,290,10269,290,10272,290,10275,1573,10277,301],{},"The data structure underlying NetLogo’s lists is a sophisticated tree-based data\nstructure on which most operations run in near-constant time. That includes\n",[556,10263,9147],{},[556,10265,9138],{},[556,10267,10268],{},"butfirst",[556,10270,10271],{},"butlast",[556,10273,10274],{},"length",[556,10276,9255],{},[556,10278,9107],{},[22,10280,10281,10282,10284],{},"One exception to the fast-performance rule is that concatenating two lists with\n",[556,10283,9022],{}," requires traversing and copying the whole second list. (This may be\nfixed in a future version.)",[22,10286,10287],{},"Technically, “near-constant time” is actually logarithmic time, proportional to\nthe depth of the underlying tree, but these trees have large nodes and a high\nbranching factor, so they are never more than a few levels deep. This means that\nchanges can be made in at most a few steps. The trees are immutable, but they\nshare structure with each other, so the whole tree doesn’t need to be copied to\nmake a changed version.",[22,10289,10290,10291,10297],{},"The actual data structure used is the immutable Vector class from the Scala\ncollections library. These are 32-wide\n",[16,10292,10296],{"href":10293,"rel":10294},"https://en.wikipedia.org/wiki/Hash_array_mapped_trie",[10295],"nofollow","hash array mapped tries",",\nas implemented by Tiark Rompf, based in part on work by Phil Bagwell and Rich\nHickey.",[262,10299,10302],{"id":10300,"className":10301},"strings",[14],[16,10303,222],{"className":10304,"href":221},[19],[22,10306,10307],{},"Strings may contain any Unicode characters.",[22,10309,10310],{},"To input a constant string in NetLogo, surround it with double quotes.",[22,10312,10313,10314,301],{},"The empty string is written by putting nothing between the quotes, like this:\n",[556,10315,10316],{},"\"\"",[22,10318,10319],{},"Most of the list primitives work on strings as well:",[553,10321,10322],{},[556,10323,10324,573,10327,573,10331,573,10334,10338,10340,573,10343,573,10346,573,10349,10353,10355,573,10359,573,10362,573,10365,10368,10370,573,10373,573,10376,573,10379,10382,10384,573,10388,573,10391,573,10394,10398,10400,573,10403,573,10406,573,10409,573,10412,10416,10418,573,10422,573,10425,573,10428,10432,10434,573,10437,573,10440,573,10443,10446,10448,573,10451,573,10454,573,10457,573,10460,10463,10465,573,10468,573,10472,573,10475,573,10478,10481,10483,573,10486,573,10490,573,10493,573,10496,10499,10501,573,10505,573,10508,573,10511,573,10514,10517,10519,573,10522,573,10525,573,10528,573,10531,10534,10536,573,10539,573,10542,573,10545,573,10548,10551,10553,573,10557,573,10560,573,10563,573,10566,10570,10572,573,10575,573,10578,573,10582,573,10585,10588,10590,573,10593,573,10596,573,10599,573,10603,573,10606,10610,10612,573,10615,573,10618,573,10621],{},[559,10325,9233],{"className":10326},[562,571],[559,10328,10330],{"className":10329},[562,2994],"\"string\"",[559,10332,9375],{"className":10333},[562,1001],[559,10335,10337],{"className":10336},[562,2994],"\"tring\"",[566,10339],{},[559,10341,9185],{"className":10342},[562,571],[559,10344,10330],{"className":10345},[562,2994],[559,10347,9375],{"className":10348},[562,1001],[559,10350,10352],{"className":10351},[562,2994],"\"strin\"",[566,10354],{},[559,10356,10358],{"className":10357},[562,571],"empty?",[559,10360,10316],{"className":10361},[562,2994],[559,10363,9375],{"className":10364},[562,1001],[559,10366,5575],{"className":10367},[562,618],[566,10369],{},[559,10371,10358],{"className":10372},[562,571],[559,10374,10330],{"className":10375},[562,2994],[559,10377,9375],{"className":10378},[562,1001],[559,10380,5582],{"className":10381},[562,618],[566,10383],{},[559,10385,10387],{"className":10386},[562,571],"first",[559,10389,10330],{"className":10390},[562,2994],[559,10392,9375],{"className":10393},[562,1001],[559,10395,10397],{"className":10396},[562,2994],"\"s\"",[566,10399],{},[559,10401,9255],{"className":10402},[562,571],[559,10404,4283],{"className":10405},[562,668],[559,10407,10330],{"className":10408},[562,2994],[559,10410,9375],{"className":10411},[562,1001],[559,10413,10415],{"className":10414},[562,2994],"\"r\"",[566,10417],{},[559,10419,10421],{"className":10420},[562,571],"last",[559,10423,10330],{"className":10424},[562,2994],[559,10426,9375],{"className":10427},[562,1001],[559,10429,10431],{"className":10430},[562,2994],"\"g\"",[566,10433],{},[559,10435,10274],{"className":10436},[562,571],[559,10438,10330],{"className":10439},[562,2994],[559,10441,9375],{"className":10442},[562,1001],[559,10444,8819],{"className":10445},[562,668],[566,10447],{},[559,10449,1145],{"className":10450},[562,571],[559,10452,10397],{"className":10453},[562,2994],[559,10455,10330],{"className":10456},[562,2994],[559,10458,9375],{"className":10459},[562,1001],[559,10461,5575],{"className":10462},[562,618],[566,10464],{},[559,10466,1145],{"className":10467},[562,571],[559,10469,10471],{"className":10470},[562,2994],"\"rin\"",[559,10473,10330],{"className":10474},[562,2994],[559,10476,9375],{"className":10477},[562,1001],[559,10479,5575],{"className":10480},[562,618],[566,10482],{},[559,10484,1145],{"className":10485},[562,571],[559,10487,10489],{"className":10488},[562,2994],"\"ron\"",[559,10491,10330],{"className":10492},[562,2994],[559,10494,9375],{"className":10495},[562,1001],[559,10497,5582],{"className":10498},[562,618],[566,10500],{},[559,10502,10504],{"className":10503},[562,571],"position",[559,10506,10397],{"className":10507},[562,2994],[559,10509,10330],{"className":10510},[562,2994],[559,10512,9375],{"className":10513},[562,1001],[559,10515,669],{"className":10516},[562,668],[566,10518],{},[559,10520,10504],{"className":10521},[562,571],[559,10523,10471],{"className":10524},[562,2994],[559,10526,10330],{"className":10527},[562,2994],[559,10529,9375],{"className":10530},[562,1001],[559,10532,4283],{"className":10533},[562,668],[566,10535],{},[559,10537,10504],{"className":10538},[562,571],[559,10540,10489],{"className":10541},[562,2994],[559,10543,10330],{"className":10544},[562,2994],[559,10546,9375],{"className":10547},[562,1001],[559,10549,5582],{"className":10550},[562,618],[566,10552],{},[559,10554,10556],{"className":10555},[562,571],"remove",[559,10558,10415],{"className":10559},[562,2994],[559,10561,10330],{"className":10562},[562,2994],[559,10564,9375],{"className":10565},[562,1001],[559,10567,10569],{"className":10568},[562,2994],"\"sting\"",[566,10571],{},[559,10573,10556],{"className":10574},[562,571],[559,10576,10397],{"className":10577},[562,2994],[559,10579,10581],{"className":10580},[562,2994],"\"strings\"",[559,10583,9375],{"className":10584},[562,1001],[559,10586,10337],{"className":10587},[562,2994],[566,10589],{},[559,10591,9107],{"className":10592},[562,571],[559,10594,688],{"className":10595},[562,668],[559,10597,10330],{"className":10598},[562,2994],[559,10600,10602],{"className":10601},[562,2994],"\"o\"",[559,10604,9375],{"className":10605},[562,1001],[559,10607,10609],{"className":10608},[562,2994],"\"strong\"",[566,10611],{},[559,10613,10044],{"className":10614},[562,571],[559,10616,10330],{"className":10617},[562,2994],[559,10619,9375],{"className":10620},[562,1001],[559,10622,10624],{"className":10623},[562,2994],"\"gnirts\"",[22,10626,10627,10628,396,10635,1573,10644,9502],{},"A few primitives are specific to strings, such as ",[319,10629,10631],{"displayText":10630,"permalink":1577},"is-string?",[16,10632,10630],{"href":1580,"rel":10633,"className":10634,"dataDisplayText":10630,"target":330,"title":10630},[327],[329],[319,10636,10639],{"displayText":10637,"permalink":10638},"substring","subliststring",[16,10640,10637],{"href":10641,"rel":10642,"className":10643,"dataDisplayText":10637,"target":330,"title":10637},"/dictionary#subliststring",[327],[329],[319,10645,10646],{"displayText":9432,"permalink":9432},[16,10647,9432],{"href":9916,"rel":10648,"className":10649,"dataDisplayText":9432,"target":330,"title":9432},[327],[329],[553,10651,10652],{},[556,10653,10654,573,10657,573,10660,573,10663,10666,10668,573,10671,573,10675,573,10678,10681,10683,573,10686,573,10689,573,10692,573,10695,573,10698,10701,10703,573,10706,573,10710,573,10714,573,10717],{},[559,10655,10630],{"className":10656},[562,571],[559,10658,10330],{"className":10659},[562,2994],[559,10661,9375],{"className":10662},[562,1001],[559,10664,5575],{"className":10665},[562,618],[566,10667],{},[559,10669,10630],{"className":10670},[562,571],[559,10672,10674],{"className":10673},[562,668],"37",[559,10676,9375],{"className":10677},[562,1001],[559,10679,5582],{"className":10680},[562,618],[566,10682],{},[559,10684,10637],{"className":10685},[562,571],[559,10687,10330],{"className":10688},[562,2994],[559,10690,4283],{"className":10691},[562,668],[559,10693,1221],{"className":10694},[562,668],[559,10696,9375],{"className":10697},[562,1001],[559,10699,10471],{"className":10700},[562,2994],[566,10702],{},[559,10704,9432],{"className":10705},[562,571],[559,10707,10709],{"className":10708},[562,2994],"\"tur\"",[559,10711,10713],{"className":10712},[562,2994],"\"tle\"",[559,10715,9375],{"className":10716},[562,1001],[559,10718,10720],{"className":10719},[562,2994],"\"turtle\"",[22,10722,10723],{},"Strings can be compared using the =, !=, \u003C, >, \u003C=, and >= operators.",[22,10725,10726],{},"If you need to embed a special character in a string, use the following escape\nsequences:",[44,10728,10729,10735,10741,10747],{},[47,10730,10731,10734],{},[556,10732,10733],{},"\\n"," = newline",[47,10736,10737,10740],{},[556,10738,10739],{},"\\t"," = tab",[47,10742,10743,10746],{},[556,10744,10745],{},"\\\""," = double quote",[47,10748,10749,10752],{},[556,10750,10751],{},"\\\\"," = backslash",[262,10754,10757],{"id":10755,"className":10756},"mathematics",[14],[16,10758,228],{"className":10759,"href":227},[19],[270,10761,10764],{"id":10762,"className":10763},"math",[14],[16,10765,236],{"className":10766,"href":235},[19],[22,10768,10769],{},"All numbers in NetLogo are stored internally as double precision floating point\nnumbers, as defined in the IEEE 754 standard. They are 64 bit numbers consisting\nof one sign bit, an 11-bit exponent, and a 52-bit mantissa. See the IEEE 754\nstandard for details.",[22,10771,10772],{},"An “integer” in NetLogo is simply a number that happens to have no fractional\npart. No distinction is made between 3 and 3.0; they are the same number. (This\nis the same as how most people use numbers in everyday contexts, but different\nfrom some programming languages. Some languages treat integers and floating\npoint numbers as distinct types.)",[22,10774,10775],{},"Integers are always printed by NetLogo without the trailing “.0”:",[553,10777,10778],{},[556,10779,10780,573,10783,573,10787,573,10790,10793,10795,573,10799],{},[559,10781,1050],{"className":10782},[562,944],[559,10784,10786],{"className":10785},[562,668],"1.5",[559,10788,2421],{"className":10789},[562,571],[559,10791,10786],{"className":10792},[562,668],[566,10794],{},[559,10796,10798],{"className":10797},[562,1001],"observer:",[559,10800,688],{"className":10801},[562,668],[22,10803,10804,10805,10814],{},"If a number with a fractional part is supplied in a context where an integer is\nexpected, the fractional part is simply discarded. So for example, ",[556,10806,10807,573,10810],{},[559,10808,4203],{"className":10809},[562,944],[559,10811,10813],{"className":10812},[562,668],"3.5","\ncreates three turtles; the extra 0.5 is ignored.",[22,10816,10817],{},"The range of integers is +/-9007199254740992 (2^53, about 9 quadrillion).\nCalculations that exceed this range will not cause runtime errors, but precision\nwill be lost when the least significant (binary) digits are rounded off in order\nfit the number into 64 bits. With very large numbers, this rounding can result\nin imprecise answers which may be surprising:",[553,10819,10820],{},[556,10821,10822,573,10825,573,10828,573,10831,573,10835,573,10838,573,10841,573,10844,573,10847,573,10850,10853,10855,573,10858],{},[559,10823,1050],{"className":10824},[562,944],[559,10826,4283],{"className":10827},[562,668],[559,10829,5504],{"className":10830},[562,571],[559,10832,10834],{"className":10833},[562,668],"60",[559,10836,2421],{"className":10837},[562,571],[559,10839,708],{"className":10840},[562,668],[559,10842,614],{"className":10843},[562,571],[559,10845,4283],{"className":10846},[562,668],[559,10848,5504],{"className":10849},[562,571],[559,10851,10834],{"className":10852},[562,668],[566,10854],{},[559,10856,9375],{"className":10857},[562,1001],[559,10859,5575],{"className":10860},[562,618],[22,10862,10863],{},"Calculations with smaller numbers can also produce surprising results if they\ninvolve fractional quantities, since not all fractions can be precisely\nrepresented and roundoff may occur. For example:",[553,10865,10866],{},[556,10867,10868,573,10871,573,10874,573,10877,573,10880,573,10883,573,10886,573,10889,573,10892,573,10895,573,10898,573,10901,573,10904,573,10907,573,10910,573,10913,573,10916,573,10919,573,10922,573,10925,573,10928,573,10931,573,10934,573,10937,10940,10942,573,10945,10949,10951,573,10954,573,10957,573,10960,573,10963,573,10966,573,10969,573,10972,573,10975,573,10978,573,10981,573,10984,573,10987,573,10990,573,10993,573,10996,573,10999,573,11002,573,11005,573,11008,573,11011,573,11014,573,11017,573,11020,573,11023,573,11026,573,11029,573,11032,573,11035,573,11038,573,11041,573,11044,573,11047,573,11050,573,11053,573,11056,11059,11061,573,11064],{},[559,10869,1050],{"className":10870},[562,944],[559,10872,708],{"className":10873},[562,668],[559,10875,3808],{"className":10876},[562,571],[559,10878,8819],{"className":10879},[562,668],[559,10881,2421],{"className":10882},[562,571],[559,10884,708],{"className":10885},[562,668],[559,10887,3808],{"className":10888},[562,571],[559,10890,8819],{"className":10891},[562,668],[559,10893,2421],{"className":10894},[562,571],[559,10896,708],{"className":10897},[562,668],[559,10899,3808],{"className":10900},[562,571],[559,10902,8819],{"className":10903},[562,668],[559,10905,2421],{"className":10906},[562,571],[559,10908,708],{"className":10909},[562,668],[559,10911,3808],{"className":10912},[562,571],[559,10914,8819],{"className":10915},[562,668],[559,10917,2421],{"className":10918},[562,571],[559,10920,708],{"className":10921},[562,668],[559,10923,3808],{"className":10924},[562,571],[559,10926,8819],{"className":10927},[562,668],[559,10929,2421],{"className":10930},[562,571],[559,10932,708],{"className":10933},[562,668],[559,10935,3808],{"className":10936},[562,571],[559,10938,8819],{"className":10939},[562,668],[566,10941],{},[559,10943,9375],{"className":10944},[562,1001],[559,10946,10948],{"className":10947},[562,668],"0.9999999999999999",[566,10950],{},[559,10952,1050],{"className":10953},[562,944],[559,10955,708],{"className":10956},[562,668],[559,10958,3808],{"className":10959},[562,571],[559,10961,9310],{"className":10962},[562,668],[559,10964,2421],{"className":10965},[562,571],[559,10967,708],{"className":10968},[562,668],[559,10970,3808],{"className":10971},[562,571],[559,10973,9310],{"className":10974},[562,668],[559,10976,2421],{"className":10977},[562,571],[559,10979,708],{"className":10980},[562,668],[559,10982,3808],{"className":10983},[562,571],[559,10985,9310],{"className":10986},[562,668],[559,10988,2421],{"className":10989},[562,571],[559,10991,708],{"className":10992},[562,668],[559,10994,3808],{"className":10995},[562,571],[559,10997,9310],{"className":10998},[562,668],[559,11000,2421],{"className":11001},[562,571],[559,11003,708],{"className":11004},[562,668],[559,11006,3808],{"className":11007},[562,571],[559,11009,9310],{"className":11010},[562,668],[559,11012,2421],{"className":11013},[562,571],[559,11015,708],{"className":11016},[562,668],[559,11018,3808],{"className":11019},[562,571],[559,11021,9310],{"className":11022},[562,668],[559,11024,2421],{"className":11025},[562,571],[559,11027,708],{"className":11028},[562,668],[559,11030,3808],{"className":11031},[562,571],[559,11033,9310],{"className":11034},[562,668],[559,11036,2421],{"className":11037},[562,571],[559,11039,708],{"className":11040},[562,668],[559,11042,3808],{"className":11043},[562,571],[559,11045,9310],{"className":11046},[562,668],[559,11048,2421],{"className":11049},[562,571],[559,11051,708],{"className":11052},[562,668],[559,11054,3808],{"className":11055},[562,571],[559,11057,9310],{"className":11058},[562,668],[566,11060],{},[559,11062,9375],{"className":11063},[562,1001],[559,11065,11067],{"className":11066},[562,668],"1.0000000000000002",[22,11069,11070],{},"Any operation which produces the special quantities “infinity” or “not a number”\nwill cause a runtime error.",[22,11072,11073],{},[281,11074,11075],{},"Scientific notation",[22,11077,11078],{},"Very large or very small floating point numbers are displayed by NetLogo using\n“scientific notation”. Examples:",[553,11080,11081],{},[556,11082,11083,573,11086,11090,11092,573,11095,11099,11101,573,11104,11108,11110,573,11113],{},[559,11084,1050],{"className":11085},[562,944],[559,11087,11089],{"className":11088},[562,668],"0.000000000001",[566,11091],{},[559,11093,9375],{"className":11094},[562,1001],[559,11096,11098],{"className":11097},[562,668],"1.0E-12",[566,11100],{},[559,11102,1050],{"className":11103},[562,944],[559,11105,11107],{"className":11106},[562,668],"50000000000000000000",[566,11109],{},[559,11111,9375],{"className":11112},[562,1001],[559,11114,11116],{"className":11115},[562,668],"5.0E19",[22,11118,11119],{},"Numbers in scientific notation are distinguished by the presence of the letter E\n(for “exponent”). It means “times ten to the power of”, so for example, 1.0E-12\nmeans 1.0 times 10 to the -12 power:",[553,11121,11122],{},[556,11123,11124,573,11127,573,11131,573,11134,573,11137,573,11140,11144,11146,573,11149],{},[559,11125,1050],{"className":11126},[562,944],[559,11128,11130],{"className":11129},[562,668],"1.0",[559,11132,5418],{"className":11133},[562,571],[559,11135,1287],{"className":11136},[562,668],[559,11138,5504],{"className":11139},[562,571],[559,11141,11143],{"className":11142},[562,668],"-12",[566,11145],{},[559,11147,9375],{"className":11148},[562,1001],[559,11150,11098],{"className":11151},[562,668],[22,11153,11154],{},"You can also use scientific notation yourself in NetLogo code:",[553,11156,11157],{},[556,11158,11159,573,11162,11166,11168,573,11171,11175,11177,573,11180,11184,11186,573,11189,11193,11195,573,11198,11202,11204,573,11207,11210,11212,573,11215,11219,11221,573,11224,11227,11229,573,11232,11236,11238,573,11241,11245,11247,573,11250,11254,11256,573,11259],{},[559,11160,1050],{"className":11161},[562,944],[559,11163,11165],{"className":11164},[562,668],"3.0E6",[566,11167],{},[559,11169,9375],{"className":11170},[562,1001],[559,11172,11174],{"className":11173},[562,668],"3000000",[566,11176],{},[559,11178,1050],{"className":11179},[562,944],[559,11181,11183],{"className":11182},[562,668],"8.123456789E6",[566,11185],{},[559,11187,9375],{"className":11188},[562,1001],[559,11190,11192],{"className":11191},[562,668],"8123456.789",[566,11194],{},[559,11196,1050],{"className":11197},[562,944],[559,11199,11201],{"className":11200},[562,668],"8.123456789E7",[566,11203],{},[559,11205,9375],{"className":11206},[562,1001],[559,11208,11201],{"className":11209},[562,668],[566,11211],{},[559,11213,1050],{"className":11214},[562,944],[559,11216,11218],{"className":11217},[562,668],"3.0E16",[566,11220],{},[559,11222,9375],{"className":11223},[562,1001],[559,11225,11218],{"className":11226},[562,668],[566,11228],{},[559,11230,1050],{"className":11231},[562,944],[559,11233,11235],{"className":11234},[562,668],"8.0E-3",[566,11237],{},[559,11239,9375],{"className":11240},[562,1001],[559,11242,11244],{"className":11243},[562,668],"0.0080",[566,11246],{},[559,11248,1050],{"className":11249},[562,944],[559,11251,11253],{"className":11252},[562,668],"8.0E-4",[566,11255],{},[559,11257,9375],{"className":11258},[562,1001],[559,11260,11253],{"className":11261},[562,668],[22,11263,11264],{},"These examples show that numbers with fractional parts are displayed using\nscientific notation if the exponent is less than -3 or greater than 6. Numbers\noutside of NetLogo’s integer range of -9007199254740992 to 9007199254740992\n(+/-2^53) are also always shown in scientific notation:",[553,11266,11267],{},[556,11268,11269,573,11272,573,11275,573,11278,11281,11283,573,11286],{},[559,11270,1050],{"className":11271},[562,944],[559,11273,4283],{"className":11274},[562,668],[559,11276,5504],{"className":11277},[562,571],[559,11279,10834],{"className":11280},[562,668],[566,11282],{},[559,11284,9375],{"className":11285},[562,1001],[559,11287,11289],{"className":11288},[562,668],"1.15292150460684698E18",[22,11291,11292],{},"When entering a number, the letter E may be either upper or lowercase. When\nprinting a number, NetLogo always uses an uppercase E:",[553,11294,11295],{},[556,11296,11297,573,11300,11304,11306,573,11309],{},[559,11298,1050],{"className":11299},[562,944],[559,11301,11303],{"className":11302},[562,668],"4.5e20",[566,11305],{},[559,11307,9375],{"className":11308},[562,1001],[559,11310,11312],{"className":11311},[562,668],"4.5E20",[22,11314,11315],{},[281,11316,11317],{},"Floating point accuracy",[22,11319,11320],{},"Because numbers in NetLogo are subject to the limitations of how floating point\nnumbers are represented in binary, you may get answers that are slightly\ninaccurate. For example:",[553,11322,11323],{},[556,11324,11325,573,11328,573,11332,573,11335,573,11338,573,11341,11344,11346,573,11349,11353,11355,573,11358,573,11362,11365,11367,573,11370],{},[559,11326,1050],{"className":11327},[562,944],[559,11329,11331],{"className":11330},[562,668],"0.1",[559,11333,2421],{"className":11334},[562,571],[559,11336,11331],{"className":11337},[562,668],[559,11339,2421],{"className":11340},[562,571],[559,11342,11331],{"className":11343},[562,668],[566,11345],{},[559,11347,9375],{"className":11348},[562,1001],[559,11350,11352],{"className":11351},[562,668],"0.30000000000000004",[566,11354],{},[559,11356,1050],{"className":11357},[562,944],[559,11359,11361],{"className":11360},[562,571],"cos",[559,11363,4296],{"className":11364},[562,668],[566,11366],{},[559,11368,9375],{"className":11369},[562,1001],[559,11371,11373],{"className":11372},[562,668],"6.123233995736766E-17",[22,11375,11376],{},"This is an inherent issue with floating point arithmetic; it occurs in all\nprogramming languages that use floating point numbers.",[22,11378,11379],{},"If you are dealing with fixed precision quantities, for example dollars and\ncents, a common technique is to use only integers (cents) internally, then\ndivide by 100 to get a result in dollars for display.",[22,11381,11382,11383,11400,11401,301],{},"If you must use floating point numbers, then in some situations you may need to\nreplace a straightforward equality test such as ",[556,11384,11385,573,11388,573,11391,573,11394,951,11397,958],{},[559,11386,1615],{"className":11387},[562,944],[559,11389,5702],{"className":11390},[562,1001],[559,11392,614],{"className":11393},[562,571],[559,11395,708],{"className":11396},[562,668],[559,11398,1629],{"className":11399},[562,1001]," with a test\nthat tolerates slight imprecision, for example\n",[556,11402,11403,573,11406,774,11409,573,11412,573,11415,769,11418,573,11421,951,11425,958],{},[559,11404,1615],{"className":11405},[562,944],[559,11407,6441],{"className":11408},[562,571],[559,11410,5702],{"className":11411},[562,1001],[559,11413,3920],{"className":11414},[562,571],[559,11416,708],{"className":11417},[562,668],[559,11419,5524],{"className":11420},[562,571],[559,11422,11424],{"className":11423},[562,668],"0.0001",[559,11426,1629],{"className":11427},[562,1001],[22,11429,11430,11431,11439],{},"Also, the ",[319,11432,11434],{"displayText":11433,"permalink":11433},"precision",[16,11435,11433],{"href":11436,"rel":11437,"className":11438,"dataDisplayText":11433,"target":330,"title":11433},"/dictionary#precision",[327],[329]," primitive is handy for rounding off numbers for display\npurposes. NetLogo monitors round the numbers they display to a configurable\nnumber of decimal places, too.",[270,11441,11444],{"id":11442,"className":11443},"random-numbers",[14],[16,11445,242],{"className":11446,"href":241},[19],[22,11448,11449],{},"The random numbers used by NetLogo are what is called “pseudo-random”. (This is\ntypical in computer programming.) That means they appear random, but are in fact\ngenerated by a deterministic process. “Deterministic” means that you get the\nsame results every time, if you start with the same random “seed”. We’ll explain\nin a minute what we mean by “seed”.",[22,11451,11452],{},"In the context of scientific modeling, pseudo-random numbers are actually\ndesirable. That’s because it’s important that a scientific experiment be\nreproducible — so anyone can try it themselves and get the same result that you\ngot. Since NetLogo uses pseudo-random numbers, the “experiments” that you do\nwith it can be reproduced by others.",[22,11454,11455,11456,11464],{},"Here’s how it works. NetLogo’s random number generator can be started with a\ncertain seed value, which must be an integer in the range -2147483648\nto 2147483647. Once the generator has been “seeded” with the ",[319,11457,11459],{"displayText":11458,"permalink":11458},"random-seed",[16,11460,11458],{"href":11461,"rel":11462,"className":11463,"dataDisplayText":11458,"target":330,"title":11458},"/dictionary#random-seed",[327],[329],"\ncommand, it always generates the same sequence of random numbers from then on.\nFor example, if you run these commands:",[553,11466,11467],{},[556,11468,11469,573,11472,11476,11478,573,11481,573,11484,11487,11489,573,11492,573,11495,11498,11500,573,11503,573,11506],{},[559,11470,11458],{"className":11471},[562,944],[559,11473,11475],{"className":11474},[562,668],"137",[566,11477],{},[559,11479,1050],{"className":11480},[562,944],[559,11482,1790],{"className":11483},[562,571],[559,11485,4036],{"className":11486},[562,668],[566,11488],{},[559,11490,1050],{"className":11491},[562,944],[559,11493,1790],{"className":11494},[562,571],[559,11496,4036],{"className":11497},[562,668],[566,11499],{},[559,11501,1050],{"className":11502},[562,944],[559,11504,1790],{"className":11505},[562,571],[559,11507,4036],{"className":11508},[562,668],[22,11510,11511],{},"You will always get the numbers 79, 89, and 61 in that order.",[22,11513,11514],{},"Note, however, that you’re only guaranteed to get those same numbers if you’re\nusing the same version of NetLogo. Sometimes when we make a new version of\nNetLogo the random number generator changes. (Presently, we use a generator\nknown as the Mersenne Twister.)",[22,11516,11517,11518,11526,11527,11533],{},"To create a number suitable for seeding the random number generator, use the\n",[319,11519,11521],{"displayText":11520,"permalink":11520},"new-seed",[16,11522,11520],{"href":11523,"rel":11524,"className":11525,"dataDisplayText":11520,"target":330,"title":11520},"/dictionary#new-seed",[327],[329]," reporter. ",[319,11528,11529],{"displayText":11520,"permalink":11520},[16,11530,11520],{"href":11523,"rel":11531,"className":11532,"dataDisplayText":11520,"target":330,"title":11520},[327],[329]," creates a seed, evenly distributed over the\nspace of possible seeds, based on the current date and time. It never reports\nthe same seed twice in a row.",[1414,11535,11536],{},[22,11537,11538,11540],{},[281,11539,1420],{}," Random Seed Example",[22,11542,11543],{},"If you don’t set the random seed yourself, NetLogo sets it to a value based on\nthe current date and time. There is no way to find out what random seed it\nchose, so if you want your model run to be reproducible, you must set the random\nseed yourself ahead of time.",[22,11545,11546,11547,409,11553,11561,11562,11568,11569,11577],{},"The NetLogo primitives with “random” in their names (random, random-float, and\nso on) aren’t the only ones that use pseudo-random numbers. Many other\noperations also make random choices. For example, agentsets are always in random\norder, ",[319,11548,11549],{"displayText":911,"permalink":911},[16,11550,911],{"href":914,"rel":11551,"className":11552,"dataDisplayText":911,"target":330,"title":911},[327],[329],[319,11554,11556],{"displayText":11555,"permalink":11555},"n-of",[16,11557,11555],{"href":11558,"rel":11559,"className":11560,"dataDisplayText":11555,"target":330,"title":11555},"/dictionary#n-of",[327],[329]," choose agents randomly, the ",[319,11563,11564],{"displayText":929,"permalink":929},[16,11565,929],{"href":932,"rel":11566,"className":11567,"dataDisplayText":929,"target":330,"title":929},[327],[329]," command\ncreates turtles with random colors and headings, and the ",[319,11570,11572],{"displayText":11571,"permalink":11571},"downhill",[16,11573,11571],{"href":11574,"rel":11575,"className":11576,"dataDisplayText":11571,"target":330,"title":11571},"/dictionary#downhill",[327],[329]," reporter\nchooses a random patch when there’s a tie. All of these random choices are\ngoverned by the random seed as well, so model runs can be reproducible.",[22,11579,11580,11581,409,11587,11595,11596,290,11605,396,11612,1573,11619,301],{},"In addition to the uniformly distributed random integers and floating point\nnumbers generated by ",[319,11582,11583],{"displayText":1790,"permalink":1790},[16,11584,1790],{"href":3666,"rel":11585,"className":11586,"dataDisplayText":1790,"target":330,"title":1790},[327],[329],[319,11588,11590],{"displayText":11589,"permalink":11589},"random-float",[16,11591,11589],{"href":11592,"rel":11593,"className":11594,"dataDisplayText":11589,"target":330,"title":11589},"/dictionary#random-float",[327],[329],", NetLogo also offers\nseveral other random distributions. See the dictionary entries for\n",[319,11597,11600],{"displayText":11598,"permalink":11599},"random-normal","random-reporters",[16,11601,11598],{"href":11602,"rel":11603,"className":11604,"dataDisplayText":11598,"target":330,"title":11598},"/dictionary#random-reporters",[327],[329],[319,11606,11608],{"displayText":11607,"permalink":11599},"random-poisson",[16,11609,11607],{"href":11602,"rel":11610,"className":11611,"dataDisplayText":11607,"target":330,"title":11607},[327],[329],[319,11613,11615],{"displayText":11614,"permalink":11599},"random-exponential",[16,11616,11614],{"href":11602,"rel":11617,"className":11618,"dataDisplayText":11614,"target":330,"title":11614},[327],[329],[319,11620,11622],{"displayText":11621,"permalink":11599},"random-gamma",[16,11623,11621],{"href":11602,"rel":11624,"className":11625,"dataDisplayText":11621,"target":330,"title":11621},[327],[329],[34,11627,11630],{"id":11628,"className":11629},"auxiliary-generator",[14],[16,11631,11634],{"className":11632,"href":11633},[19],"#auxiliary-generator","Auxiliary generator",[22,11636,11637],{},"Code run by buttons or from the command center uses the main random number\ngenerator.",[22,11639,11640],{},"Code in monitors uses an auxiliary random generator, so even if a monitor does a\ncalculation that uses random numbers, the outcome of the model is not affected.\nThe same is true of code in sliders.",[34,11642,11645],{"id":11643,"className":11644},"local-randomness",[14],[16,11646,11649],{"className":11647,"href":11648},[19],"#local-randomness","Local randomness",[22,11651,11652,11653,11661],{},"You may want to explicitly specify that a section of code does not affect the\nstate of the main random generator, so the outcome of the model is not affected.\nThe ",[319,11654,11656],{"displayText":11655,"permalink":11655},"with-local-randomness",[16,11657,11655],{"href":11658,"rel":11659,"className":11660,"dataDisplayText":11655,"target":330,"title":11655},"/dictionary#with-local-randomness",[327],[329]," command is provided for this purpose. See its\nentry in the NetLogo Dictionary for more information.",[34,11663,11666],{"id":11664,"className":11665},"saving-a-random-seed-for-a-run",[14],[16,11667,11670],{"className":11668,"href":11669},[19],"#saving-a-random-seed-for-a-run","Saving a Random Seed for a Run",[22,11672,11673],{},"If you want to know what the random seed used by a “run” of a model was, you can\nadd some simple code to track it. Then if an interesting behavior emerges or an\nintermittent error condition occurs, you have a way to reproduce the run by\ngrabbing the seed and re-using it.",[22,11675,11676,11677,11680,11681,11687,11688,11694,11695,11697,11698,11704],{},"Add a ",[556,11678,11679],{},"starting-seed"," global variable, then use ",[319,11682,11683],{"displayText":11520,"permalink":11520},[16,11684,11520],{"href":11523,"rel":11685,"className":11686,"dataDisplayText":11520,"target":330,"title":11520},[327],[329]," to give it a value\nafter you use ",[319,11689,11690],{"displayText":1208,"permalink":1208},[16,11691,1208],{"href":3130,"rel":11692,"className":11693,"dataDisplayText":1208,"target":330,"title":1208},[327],[329]," in your ",[556,11696,1748],{}," procedure. Then give that value to\nthe ",[319,11699,11700],{"displayText":11458,"permalink":11458},[16,11701,11458],{"href":11461,"rel":11702,"className":11703,"dataDisplayText":11458,"target":330,"title":11458},[327],[329]," command so it will be used for the rest of the run.",[553,11706,11707],{},[556,11708,11709,606,11712,620,11715,11717,573,11722,11725,1751,11727,11730,1751,11732,573,11735,573,11738,11741,1751,11743,573,11746,11749,1751,11751,11755,11760,11762,573,11767,11770,1751,11772,11776],{},[559,11710,1191],{"className":11711},[562,1190],[559,11713,11679],{"className":11714},[562,1001],[566,11716],{},[559,11718,11720,1744],{"className":11719},[562,1190],[566,11721],{},[559,11723,1748],{"className":11724},[562,1001],[566,11726],{},[559,11728,1208],{"className":11729},[562,944],[566,11731],{},[559,11733,1230],{"className":11734},[562,944],[559,11736,11679],{"className":11737},[562,1001],[559,11739,11520],{"className":11740},[562,571],[566,11742],{},[559,11744,11458],{"className":11745},[562,944],[559,11747,11679],{"className":11748},[562,1001],[566,11750],{},[559,11752,11754],{"className":11753},[562,563],"; ... rest of normal setup code",[559,11756,11758,1825],{"className":11757},[562,1190],[566,11759],{},[566,11761],{},[559,11763,11765,1744],{"className":11764},[562,1190],[566,11766],{},[559,11768,3515],{"className":11769},[562,1001],[566,11771],{},[559,11773,11775],{"className":11774},[562,563],"; ... the rest of normal model code will use the random seed set in `setup`",[559,11777,11779,1825],{"className":11778},[562,1190],[566,11780],{},[22,11782,11783,11784,11786],{},"You can then add a monitor for the ",[556,11785,11679],{}," global or simply output it to\nthe command center whenever you want to know its value. If you are using\nBehaviorSpace to run experiments, you can also include it in the output to be\nable to later reproduce runs that it generates.",[262,11788,11791],{"id":11789,"className":11790},"plotting",[14],[16,11792,248],{"className":11793,"href":247},[19],[22,11795,11796],{},"NetLogo’s plotting features let you create plots to help you understand what’s\ngoing on in your model.",[22,11798,11799,11800,11804],{},"Most plots can be created by creating and editing plot widgets in the Interface\ntab, as described in its ",[16,11801,11803],{"href":11802},"/interfacetab#plots","Plots Section",". However it is\npossible to control plots from procedures, although you need to create them in\nthe Interface tab first.",[34,11806,11809],{"id":11807,"className":11808},"plotting-points",[14],[16,11810,11813],{"className":11811,"href":11812},[19],"#plotting-points","Plotting points",[22,11815,11816,11817,409,11820,301],{},"The two basic commands for actually plotting things are ",[556,11818,11819],{},"plot",[556,11821,11822],{},"plotxy",[22,11824,4833,11825,11827],{},[556,11826,11819],{}," you need only specify the y value you want plotted. The x value will\nautomatically be 0 for the first point you plot, 1 for the second, and so on.\n(That’s if the plot pen’s “interval” is the default value of 1; you can change\nthe interval.)",[22,11829,1376,11830,11832],{},[556,11831,11819],{}," command is especially handy when you want your model to plot a new\npoint at every time step. Example:",[553,11834,11835],{},[556,11836,11837,573,11840,573,11843],{},[559,11838,11819],{"className":11839},[562,944],[559,11841,894],{"className":11842},[562,571],[559,11844,289],{"className":11845},[562,571],[22,11847,11848,11849,11851,11852,11855],{},"If you need to specify both the x and y values of the point you want plotted,\nthen use ",[556,11850,11822],{}," instead. This example assumes that a global variable called\n",[556,11853,11854],{},"time"," exists:",[553,11857,11858],{},[556,11859,11860,573,11863,573,11866],{},[559,11861,11822],{"className":11862},[562,944],[559,11864,11854],{"className":11865},[562,1001],[559,11867,11869],{"className":11868},[562,1001],"count-turtles",[34,11871,11874],{"id":11872,"className":11873},"plot-commands",[14],[16,11875,11878],{"className":11876,"href":11877},[19],"#plot-commands","Plot commands",[22,11880,11881,11882,530,11884,11886],{},"Each plot and its pens have setup and update code fields that may contain\ncommands (usually containing ",[556,11883,11819],{},[556,11885,11822],{},"). These commands are run\nautomatically triggered by other commands in NetLogo.",[22,11888,11889,11890,11892,11893,11896,11897,11899],{},"Plot setup commands and pen setup commands are run when the either ",[556,11891,1819],{},"\nor ",[556,11894,11895],{},"setup-plots"," commands are run. If the ",[556,11898,6684],{}," command is run in the body of\nthe plot setup commands then the pen setup commands will not run.",[22,11901,11902,11903,290,11905,530,11907,11896,11910,11912],{},"Plot update commands and pen update commands are run when the either\n",[556,11904,1819],{},[556,11906,3577],{},[556,11908,11909],{},"update-plots",[556,11911,6684],{}," command\nis run in the body of the plot update commands then the pen update commands will\nnot run.",[22,11914,11915],{},"Here are the four commands that trigger plotting explained in more detail.",[44,11917,11918,11923,11931,11939],{},[47,11919,11920,11922],{},[556,11921,11895],{}," executes commands for one plot at a time. For each plot, the\nplot’s setup commands are executed. If the stop command is not encountered\nwhile running those commands, then each of the plot’s pens will have their\nsetup code executed.",[47,11924,11925,11927,11928,11930],{},[556,11926,11909],{}," is very similar to ",[556,11929,11895],{},". For each plot, the plot’s\nupdate commands are executed. If the stop command is not encountered while\nrunning those commands, then each of the plot’s pens will have their update\ncode executed.",[47,11932,11933,11935,11936,11938],{},[556,11934,3577],{}," is exactly the same as ",[556,11937,11909],{}," except that the tick counter is\nincremented before the plot commands are executed.",[47,11940,11941,11943,11944,11946,11947,301],{},[556,11942,1819],{}," first resets the tick counter to 0, and then does the equivalent\nof ",[556,11945,11895],{}," followed by ",[556,11948,11909],{},[22,11950,11951,11952,409,11954,11956],{},"A typical model will use ",[556,11953,1819],{},[556,11955,3577],{}," like so:",[553,11958,11959],{},[556,11960,11961,573,11964,11967,1751,11969,11972,1751,11974,11977,1751,11979,11982,11987,11989,573,11994,11997,1751,11999,12002,1751,12004,12007],{},[559,11962,1744],{"className":11963},[562,1190],[559,11965,1748],{"className":11966},[562,1001],[566,11968],{},[559,11970,1208],{"className":11971},[562,944],[566,11973],{},[559,11975,1629],{"className":11976},[562,1001],[566,11978],{},[559,11980,1819],{"className":11981},[562,944],[559,11983,11985,1825],{"className":11984},[562,1190],[566,11986],{},[566,11988],{},[559,11990,11992,1744],{"className":11991},[562,1190],[566,11993],{},[559,11995,3515],{"className":11996},[562,1001],[566,11998],{},[559,12000,1629],{"className":12001},[562,1001],[566,12003],{},[559,12005,3577],{"className":12006},[562,944],[559,12008,12010,1825],{"className":12009},[562,1190],[566,12011],{},[22,12013,12014,12015,409,12017,12019,12020,12022,12023,12025,12026,12028],{},"Note that in this example we plot from both the ",[556,12016,1748],{},[556,12018,3515],{}," procedures\n(because ",[556,12021,1819],{}," runs plot setup and plot update commands). We do this\nbecause we want our plot to include the initial state of the system at the end\nof ",[556,12024,1748],{},". We plot at the end of the ",[556,12027,3515],{}," procedure, not the beginning, because\nwe want the plot always to be up to date after the go button stops.",[22,12030,12031,12032,409,12034,12036,12037,12039,12040,12048,12049,301],{},"Models that don’t use ticks but still want to do plotting will instead use\n",[556,12033,11895],{},[556,12035,11909],{},". In the previous code, replace ",[556,12038,1819],{},"\nwith ",[556,12041,12042,573,12045],{},[559,12043,11895],{"className":12044},[562,944],[559,12046,11909],{"className":12047},[562,944]," and replace tick with ",[556,12050,11909],{},[1414,12052,12053],{},[22,12054,12055],{},"Code Example: Plotting Example",[34,12057,12060],{"id":12058,"className":12059},"other-kinds-of-plots",[14],[16,12061,12064],{"className":12062,"href":12063},[19],"#other-kinds-of-plots","Other kinds of plots",[22,12066,12067],{},"By default, NetLogo plot pens plot in line mode, so that the points you plot are\nconnected by a line.",[22,12069,12070,12071,12074,12075,409,12077,12079,12080,12083],{},"If you want to move the pen without plotting, you can use the ",[556,12072,12073],{},"plot-pen-up","\ncommand. After this command is issued, the ",[556,12076,11819],{},[556,12078,11822],{}," commands move the\npen but do not actually draw anything. Once the pen is where you want it, use\n",[556,12081,12082],{},"plot-pen-down"," to put the pen back down.",[22,12085,12086],{},"If you want to plot individual points instead of lines, or you want to draw bars\ninstead of lines or points, you need to change the plot pen’s “mode”. Three\nmodes are available: line, bar, and point. Line is the default mode.",[22,12088,12089,12090,12093],{},"Normally, you change a pen’s mode by editing the plot. This changes the pen’s\ndefault mode. It’s also possible to change the pen’s mode temporarily using the\n",[556,12091,12092],{},"set-plot-pen-mode"," command. That command takes a number as input: 0 for line, 1\nfor bar, 2 for point.",[34,12095,12098],{"id":12096,"className":12097},"histograms",[14],[16,12099,12102],{"className":12100,"href":12101},[19],"#histograms","Histograms",[22,12104,12105],{},"A histogram is a special kind of plot that measures how frequently certain\nvalues, or values in certain ranges, occur in a collection of numbers that arise\nin your model.",[22,12107,12108],{},"For example, suppose the turtles in your model have an age variable. You could\ncreate a histogram of the distribution of ages among your turtles with the\nhistogram command, like this:",[553,12110,12111],{},[556,12112,12113,606,12116,830,12120,573,12123],{},[559,12114,1015],{"className":12115},[562,944],[559,12117,12119],{"className":12118},[562,1001],"age",[559,12121,834],{"className":12122},[562,571],[559,12124,289],{"className":12125},[562,571],[22,12127,12128],{},"The numbers you want to histogram don’t have to come from an agentset; they\ncould be any list of numbers.",[22,12130,12131],{},"Note that using the histogram command doesn’t automatically switch the current\nplot pen to bar mode. If you want bars, you have to set the plot pen to bar mode\nyourself. (As we said before, you can change a pen’s default mode by editing the\nplot in the Interface tab.)",[22,12133,12134,12135,3341],{},"Like other types of plots, histograms can be set to auto scale. However, auto\nscaled histograms do not automatically resize themselves horizontally like other\nplot types do. To set the range programmatically, you can use the\n",[556,12136,12137],{},"set-plot-x-range",[22,12139,12140,12141,12144,12145,12148],{},"The width of the bars in a histogram is controlled by the plot pen’s interval.\nYou can set a plot pen’s default interval by editing the plot in the Interface\ntab. You can also change the interval temporarily with the\n",[556,12142,12143],{},"set-plot-pen-interval"," command or the ",[556,12146,12147],{},"set-histogram-num-bars",". If you use the\nlatter command, NetLogo will set the interval appropriately so as to fit the\nspecified number of bars within the plot’s current x range.",[1414,12150,12151],{},[22,12152,12153],{},"Code Example: Histogram Example",[34,12155,12158],{"id":12156,"className":12157},"clearing-and-resetting",[14],[16,12159,12162],{"className":12160,"href":12161},[19],"#clearing-and-resetting","Clearing and resetting",[22,12164,12165,12166,12169,12170,12173,12174,12182],{},"You can clear the current plot with the ",[556,12167,12168],{},"clear-plot"," command, or clear every\nplot in your model with ",[556,12171,12172],{},"clear-all-plots",". The ",[556,12175,12176,573,12179],{},[559,12177,1208],{"className":12178},[562,944],[559,12180,944],{"className":12181},[562,1001]," also clears\nall plots, in addition to clearing everything else in your model.",[22,12184,12185,12186,301],{},"If you want to remove only the points that a particular pen has drawn, use\n",[556,12187,12188],{},"plot-pen-reset",[22,12190,12191,12192,290,12195,409,12197,12200],{},"When a whole plot is cleared, or when a pen is reset, that doesn’t just remove\nthe data that has been plotted. It also restores the plot or pen to its default\nsettings, as they were specified in the Interface tab when the plot was created\nor last edited. Therefore, the effects of such commands as\n",[556,12193,12194],{},"set-plot-background-color",[556,12196,12137],{},[556,12198,12199],{},"set-plot-pen-color"," are\nonly temporary.",[34,12202,12205],{"id":12203,"className":12204},"ranges-and-auto-scaling",[14],[16,12206,12209],{"className":12207,"href":12208},[19],"#ranges-and-auto-scaling","Ranges and auto scaling",[22,12211,12212],{},"The default x and y ranges for a plot are fixed numbers, but they can be changed\nat setup time or as the model runs.",[22,12214,12215,12216,409,12218,12221],{},"To change the ranges at any time, use ",[556,12217,12137],{},[556,12219,12220],{},"set-plot-y-range",".\nOr, you can let the ranges grow automatically. Either way, when the plot is\ncleared the ranges will return to their default values.",[22,12223,12224],{},"By default, all NetLogo plots have the auto scaling feature enabled. This means\nthat if the model tries to plot a point which is outside the current displayed\nrange, the range of the plot will grow along one or both axes so that the new\npoint is visible. Histogram plots, however, do not auto scale horizontally.",[22,12226,12227],{},"In the hope that the ranges won’t have to change every time a new point is\nadded, when the ranges grow they leave some extra room: 25% if growing\nhorizontally, 10% if growing vertically.",[22,12229,12230],{},"If you want to turn off this feature, edit the plot and uncheck the “Auto\nScale?” checkbox. At present, it is not possible to enable or disable this\nfeature only on one axis; it always applies to both axes.",[34,12232,12235],{"id":12233,"className":12234},"using-a-legend",[14],[16,12236,12239],{"className":12237,"href":12238},[19],"#using-a-legend","Using a Legend",[22,12241,12242],{},"You can show the legend of a plot by checking the “Show legend” checkbox in the\nedit dialog. If you don’t want a particular pen to show up in the legend you can\nuncheck the “Show in Legend” checkbox for that pen also in the advanced plot pen\nsettings (the advanced plot pen settings can be opened by clicking the pencil\nbutton for that pen in the plot pens table in the plot edit dialog).",[34,12244,12247],{"id":12245,"className":12246},"temporary-plot-pens",[14],[16,12248,12251],{"className":12249,"href":12250},[19],"#temporary-plot-pens","Temporary plot pens",[22,12253,12254,12255,290,12257,2574,12259,12261],{},"Most plots can get along with a fixed number of pens. But some plots have more\ncomplex needs; they may need to have the number of pens vary depending on\nconditions. In such cases, you can make “temporary” plot pens from code and then\nplot with them. These pens are called “temporary” because they vanish when the\nplot is cleared (by the ",[556,12256,12168],{},[556,12258,12172],{},[556,12260,1208],{},"\ncommands).",[22,12263,12264,12265,12268],{},"To create a temporary plot pen, use the ",[556,12266,12267],{},"create-temporary-plot-pen"," command.\nTypically, this would be done in the Code tab, but it is also possible to use\nthis command from plot setup or plot update code (in the edit dialog). By\ndefault, the new pen is down, is black in color, has an interval of 1, and plots\nin line mode. Commands are available to change all of these settings; see the\nPlotting section of the NetLogo Dictionary.",[22,12270,12271,12272,4885,12275,12278],{},"Before you can use the pen, you’ll have to use the use the ",[556,12273,12274],{},"set-current-plot",[556,12276,12277],{},"set-current-plot-pen"," commands. These are explained in the next section.",[34,12280,12283],{"id":12281,"className":12282},"set-current-plot-and-set-current-plot-pen",[14],[16,12284,12287],{"className":12285,"href":12286},[19],"#set-current-plot-and-set-current-plot-pen","set-current-plot and set-current-plot-pen",[22,12289,12290,12291,12293,12294,3279],{},"Before NetLogo 5, it was not possible to put plot commands in the plot itself.\nAll of the plot code was written in the Code tab with the rest of the code. For\nbackwards compatibility, and for temporary plot pens, this is still supported.\nModels in previous versions of NetLogo (and those using temporary plot pens)\nhave to explicitly state which plot is the current plot with the\n",[556,12292,12274],{}," command and which pen is the current pen with the\n",[556,12295,12277],{},[22,12297,12298,12299,12301],{},"To set the current plot use the ",[556,12300,12274],{}," command with the name of the\nplot enclosed in double quotes, like this:",[553,12303,12304],{},[556,12305,12306,573,12309],{},[559,12307,12274],{"className":12308},[562,944],[559,12310,12312],{"className":12311},[562,2994],"\"Distance vs. Time\"",[22,12314,12315,12316,12318],{},"The name of the plot must be exactly as you typed it when you created the plot.\nNote that later if you change the name of the plot, you’ll also have to update\nthe ",[556,12317,12274],{}," calls in your model to use the new name. (Copy and paste\ncan be helpful here.)",[22,12320,12321,12322,12324],{},"For a plot with multiple pens, you can manually specify which pen you want to\nplot with. If you don’t specify a pen, plotting will take place with the first\npen in the plot. To plot with a different pen, the ",[556,12323,12277],{},"\ncommand was used with the name of the pen enclosed in double quotes, like this:",[553,12326,12327],{},[556,12328,12329,573,12332],{},[559,12330,12277],{"className":12331},[562,944],[559,12333,12335],{"className":12334},[562,2994],"\"distance\"",[22,12337,12338,12339,12350],{},"Once the current pen is set, then commands like ",[556,12340,12341,573,12344,573,12347],{},[559,12342,11819],{"className":12343},[562,944],[559,12345,894],{"className":12346},[562,571],[559,12348,289],{"className":12349},[562,571]," can be\nexecuted for that pen.",[22,12352,12353,12354,12357],{},"Older models with plots usually had their own ",[556,12355,12356],{},"do-plotting"," procedure that\nlooked something like this:",[553,12359,12360],{},[556,12361,12362,573,12365,12368,1751,12370,573,12373,12377,1751,12379,573,12382,12386,1751,12388,573,12391,573,12394,12397,1751,12399,573,12402,12406,1751,12408,573,12411,573,12414,12417,12419,1751,12421,573,12424,12428,1751,12430,12433],{},[559,12363,1744],{"className":12364},[562,1190],[559,12366,12356],{"className":12367},[562,1001],[566,12369],{},[559,12371,12274],{"className":12372},[562,944],[559,12374,12376],{"className":12375},[562,2994],"\"populations\"",[566,12378],{},[559,12380,12277],{"className":12381},[562,944],[559,12383,12385],{"className":12384},[562,2994],"\"sheep\"",[566,12387],{},[559,12389,11819],{"className":12390},[562,944],[559,12392,894],{"className":12393},[562,571],[559,12395,1434],{"className":12396},[562,1001],[566,12398],{},[559,12400,12277],{"className":12401},[562,944],[559,12403,12405],{"className":12404},[562,2994],"\"wolves\"",[566,12407],{},[559,12409,11819],{"className":12410},[562,944],[559,12412,894],{"className":12413},[562,571],[559,12415,1437],{"className":12416},[562,1001],[566,12418],{},[566,12420],{},[559,12422,12274],{"className":12423},[562,944],[559,12425,12427],{"className":12426},[562,2994],"\"next plot\"",[566,12429],{},[559,12431,1629],{"className":12432},[562,1001],[559,12434,12436,1825],{"className":12435},[562,1190],[566,12437],{},[22,12439,12440],{},"Once again, this is no longer necessary in NetLogo 5, unless you are using\ntemporary plot pens.",[34,12442,12445],{"id":12443,"className":12444},"conclusion",[14],[16,12446,12449],{"className":12447,"href":12448},[19],"#conclusion","Conclusion",[22,12451,12452],{},"Not every aspect of NetLogo’s plotting system has been explained here. See the\nPlotting section of the NetLogo Dictionary for information on additional\ncommands and reporters related to plotting.",[22,12454,12455],{},"Many of the Sample Models in the Models Library illustrate various advanced\nplotting techniques. Also check out the following code examples:",[1414,12457,12458],{},[22,12459,12460],{},"Code Examples: Plot Axis Example, Plot Smoothing Example, Rolling Plot Example",[262,12462,12464],{"id":610,"className":12463},[14],[16,12465,254],{"className":12466,"href":253},[19],[22,12468,12469,12470],{},"NetLogo represents colors in different ways. A color can be number in the range\n0 to 140, with the exception of 140 itself. Below is a chart showing the range\nof such NetLogo colors. ",[2749,12471],{"alt":12472,"className":12473,"src":12474,"width":12475,"height":12476,"style":12477},"programming/colors.png",[2753],"/_content/images/programming/colors.png",510,450,{"aspectRatio":12478},"510/450",[22,12480,12481],{},"The chart shows that:",[44,12483,12484,12487,12490,12493,12496,12499],{},[47,12485,12486],{},"Some of the colors have names. (You can use these names in your code.)",[47,12488,12489],{},"Every named color except black and white has a number ending in 5.",[47,12491,12492],{},"On either side of each named color are darker and lighter shades of the color.",[47,12494,12495],{},"0 is pure black. 9.9 is pure white.",[47,12497,12498],{},"10, 20, and so on are all so dark they are very nearly black.",[47,12500,12501],{},"19.9, 29.9 and so on are all so light they are very nearly white.",[1414,12503,12504],{},[22,12505,12506,12508],{},[281,12507,1420],{}," The color chart was made in NetLogo with the Color Chart\nExample model.",[22,12510,12511,12512,12518,12519,12525,12526,3341],{},"If you use a number outside the 0 to 140 range, NetLogo will repeatedly add or\nsubtract 140 from the number until it is in the 0 to 140 range. For example, 25\nis orange, so 165, 305, 445, and so on are orange too, and so are -115, -255,\n-395, etc. This calculation is done automatically whenever you set the turtle\nvariable ",[319,12513,12514],{"displayText":610,"permalink":610},[16,12515,610],{"href":2189,"rel":12516,"className":12517,"dataDisplayText":610,"target":330,"title":610},[327],[329]," or the patch variable ",[319,12520,12521],{"displayText":794,"permalink":794},[16,12522,794],{"href":2197,"rel":12523,"className":12524,"dataDisplayText":794,"target":330,"title":794},[327],[329],". Should you need to perform\nthis calculation in some other context, use the ",[319,12527,12529],{"displayText":12528,"permalink":12528},"wrap-color",[16,12530,12528],{"href":12531,"rel":12532,"className":12533,"dataDisplayText":12528,"target":330,"title":12528},"/dictionary#wrap-color",[327],[329],[22,12535,12536],{},"If you want a color that’s not on the chart, more exist between the integers.\nFor example, 26.5 is a shade of orange halfway between 26 and 27. This doesn’t\nmean you can make any color in NetLogo; the NetLogo color space is only a subset\nof all possible colors. It contains only a fixed set of discrete hues (one hue\nper row of the chart). Starting from one of those hues, you can either decrease\nits brightness (darken it) or decrease its saturation (lighten it), but you\ncannot decrease both brightness and saturation. Also, only the first digit after\nthe decimal point is significant. Thus, color values are rounded down to the\nnext 0.1, so for example, there’s no visible difference between 26.5 and 26.52\nor 26.58.",[22,12538,12539],{},[281,12540,12541],{},"Color primitives",[22,12543,12544],{},"There are a few primitives that are helpful for working with colors.",[22,12546,12547,12548,3341],{},"We have already mentioned the ",[319,12549,12550],{"displayText":12528,"permalink":12528},[16,12551,12528],{"href":12531,"rel":12552,"className":12553,"dataDisplayText":12528,"target":330,"title":12528},[327],[329],[22,12555,1376,12556,12564],{},[319,12557,12559],{"displayText":12558,"permalink":12558},"scale-color",[16,12560,12558],{"href":12561,"rel":12562,"className":12563,"dataDisplayText":12558,"target":330,"title":12558},"/dictionary#scale-color",[327],[329]," primitive is useful for converting numeric data into colors.",[22,12566,12567,12575,12576,12589],{},[319,12568,12570],{"displayText":12569,"permalink":12569},"shade-of?",[16,12571,12569],{"href":12572,"rel":12573,"className":12574,"dataDisplayText":12569,"target":330,"title":12569},"/dictionary#shade-of",[327],[329]," will tell you if two colors are both “shades” of the same basic\nhue. For example, ",[556,12577,12578,573,12581,573,12585],{},[559,12579,12569],{"className":12580},[562,571],[559,12582,12584],{"className":12583},[562,618],"orange",[559,12586,12588],{"className":12587},[562,668],"27"," is true, because 27 is a lighter shade\nof orange.",[22,12591,12592,12593,12596],{},"See the ",[16,12594,610],{"href":12595},"dictionary#color","\nsection of the NetLogo Dictionary for a full list of color commands.",[1414,12598,12599],{},[22,12600,12601,12603],{},[281,12602,1420],{}," Scale-color Example demonstrates the scale-color reporter.",[22,12605,12606],{},[281,12607,12608],{},"RGB and RGBA Colors",[22,12610,12611,12612,12618,12619,12625],{},"NetLogo also represents colors as RGB (red/green/blue) lists and RGBA\n(red/green/blue/alpha) lists. When using RGB colors the full range of colors is\navailable to you. RGBA colors allow all the colors that RGB allows and you can\nalso vary the transparency of a color. RGB and RGBA lists are made up of three\nor four integers, respectively, between 0 and 255. You can set any color\nvariables in NetLogo (",[319,12613,12614],{"displayText":610,"permalink":610},[16,12615,610],{"href":2189,"rel":12616,"className":12617,"dataDisplayText":610,"target":330,"title":610},[327],[329]," for turtles and links and ",[319,12620,12621],{"displayText":794,"permalink":794},[16,12622,794],{"href":2197,"rel":12623,"className":12624,"dataDisplayText":794,"target":330,"title":794},[327],[329]," for\npatches) to an RGB list and that agent will be rendered appropriately. So you\ncan set the color of patch 0 0 to pure red using the following code:",[553,12627,12628],{},[556,12629,12630,573,12633,606,12636,573,12640,573,12643,620],{},[559,12631,1230],{"className":12632},[562,944],[559,12634,794],{"className":12635},[562,571],[559,12637,12639],{"className":12638},[562,668],"255",[559,12641,669],{"className":12642},[562,668],[559,12644,669],{"className":12645},[562,668],[22,12647,12648,12649,12652],{},"Turtles, links, and labels can all contain RGBA lists as their color variables.\nPatches only use the alpha value of an RGBA ",[556,12650,12651],{},"pcolors"," in NetLogo 3D, it’s\nignored in 2D NetLogo. You can set the color of a turtle to be approximately\nhalf transparent pure red with the following code:",[553,12654,12655],{},[556,12656,12657,573,12660,606,12663,573,12666,573,12669,573,12672,620],{},[559,12658,1230],{"className":12659},[562,944],[559,12661,610],{"className":12662},[562,571],[559,12664,12639],{"className":12665},[562,668],[559,12667,669],{"className":12668},[562,668],[559,12670,669],{"className":12671},[562,668],[559,12673,12675],{"className":12674},[562,668],"125",[22,12677,12678],{},"Note that decimal values will be rounded towards 0 before the range is checked.\nAn error will be thrown if a value is outside the range 0-255 after this\nrounding.",[22,12680,12681,12682,409,12690,12698,12699,12707,12708,12716],{},"You can convert from a NetLogo color to RGB or HSB (hue/saturation/brightness)\nusing ",[319,12683,12685],{"displayText":12684,"permalink":12684},"extract-hsb",[16,12686,12684],{"href":12687,"rel":12688,"className":12689,"dataDisplayText":12684,"target":330,"title":12684},"/dictionary#extract-hsb",[327],[329],[319,12691,12693],{"displayText":12692,"permalink":12692},"extract-rgb",[16,12694,12692],{"href":12695,"rel":12696,"className":12697,"dataDisplayText":12692,"target":330,"title":12692},"/dictionary#extract-rgb",[327],[329],". You can use ",[319,12700,12702],{"displayText":12701,"permalink":12701},"rgb",[16,12703,12701],{"href":12704,"rel":12705,"className":12706,"dataDisplayText":12701,"target":330,"title":12701},"/dictionary#rgb",[327],[329]," to generate rgb\nlists and ",[319,12709,12711],{"displayText":12710,"permalink":12710},"hsb",[16,12712,12710],{"href":12713,"rel":12714,"className":12715,"dataDisplayText":12710,"target":330,"title":12710},"/dictionary#hsb",[327],[329]," to convert from an HSB color to RGB.",[22,12718,12719,12720,4885,12728,12736],{},"Since many colors are missing from the NetLogo color space, ",[319,12721,12723],{"displayText":12722,"permalink":12722},"approximate-hsb",[16,12724,12722],{"href":12725,"rel":12726,"className":12727,"dataDisplayText":12722,"target":330,"title":12722},"/dictionary#approximate-hsb",[327],[329],[319,12729,12731],{"displayText":12730,"permalink":12730},"approximate-rgb",[16,12732,12730],{"href":12733,"rel":12734,"className":12735,"dataDisplayText":12730,"target":330,"title":12730},"/dictionary#approximate-rgb",[327],[329]," often can’t give you the exact color you ask for, but\nthey try to come as close as possible.",[22,12738,12739],{},"Example:",[553,12741,12742],{},[556,12743,12744,573,12747,573,12751,573,12754,573,12757,573,12760,573,12763,12767,12769,573,12772,573,12775,573,12778],{},[559,12745,2456],{"className":12746},[562,944],[559,12748,12750],{"className":12749},[562,1001],"my-color",[559,12752,12730],{"className":12753},[562,571],[559,12755,669],{"className":12756},[562,668],[559,12758,669],{"className":12759},[562,668],[559,12761,12639],{"className":12762},[562,668],[559,12764,12766],{"className":12765},[562,563],";; my-color is now 104.7",[566,12768],{},[559,12770,1050],{"className":12771},[562,944],[559,12773,12692],{"className":12774},[562,571],[559,12776,12750],{"className":12777},[562,1001],[559,12779,12781],{"className":12780},[562,563],";; shows [48 88 161] which is pretty far from [0 0 255], the color we started with",[22,12783,12784],{},"This is an approximation, but it is still near NetLogo blue which is 105.",[22,12786,12787],{},"Using RGBA colors, the user has more options when it comes to an agent’s color.",[22,12789,12790],{},"Example: you can change any turtle from its existing NetLogo color to a sixty\npercent transparent version of that color using:",[553,12792,12793],{},[556,12794,12795,573,12798,573,12801,606,12804,573,12807,573,12810,573,12813,573,12817,573,12820,620],{},[559,12796,128],{"className":12797},[562,944],[559,12799,911],{"className":12800},[562,571],[559,12802,289],{"className":12803},[562,571],[559,12805,1230],{"className":12806},[562,944],[559,12808,610],{"className":12809},[562,571],[559,12811,9138],{"className":12812},[562,571],[559,12814,12816],{"className":12815},[562,668],"102",[559,12818,12692],{"className":12819},[562,571],[559,12821,610],{"className":12822},[562,571],[22,12824,12825],{},"Note: because 255 is fully opaque and sixty percent transparent is equal to\nforty percent opaque, the correct alpha value is 255 * .4 = 102. See the\npalette extension section below for an alternate implementation.",[1414,12827,12828],{},[22,12829,12830,12832],{},[281,12831,2831],{}," HSB and RGB Example (lets you experiment with the HSB and\nRGB color systems), Transparency Example",[22,12834,12835],{},[281,12836,12837],{},"Palette Extension",[22,12839,12840],{},"The palette extension offers primitives that give the user more control over\ncolors. It allows for direct manipulation of RGBA and HSB components without the\nrequiring list manipulations.",[22,12842,12843],{},"Example: changing the transparency of any turtle to sixty percent transparent\nwith the palette extension:",[553,12845,12846],{},[556,12847,12848,606,12851,620,12855,12857,573,12860,573,12863,606,12866,573,12870,620],{},[559,12849,5202],{"className":12850},[562,1190],[559,12852,12854],{"className":12853},[562,1001],"palette",[566,12856],{},[559,12858,128],{"className":12859},[562,944],[559,12861,911],{"className":12862},[562,571],[559,12864,289],{"className":12865},[562,571],[559,12867,12869],{"className":12868},[562,1001],"palette:set-transparency",[559,12871,10834],{"className":12872},[562,668],[22,12874,12875],{},"The extension offers similar commands for Red, Green, Blue, Alpha, Hue,\nSaturation, and Brightness.",[22,12877,12592,12878,12881],{},[16,12879,12880],{"href":12854},"documentation"," of the palette extension for more\ninformation.",[1414,12883,12884],{},[22,12885,12886,12888],{},[281,12887,2831],{}," Palette Example, Color Bubbles, Color Painting, Color\nReveal",[22,12890,12891],{},[281,12892,12893],{},"Color Picker dialog",[22,12895,1376,12896,12900],{},[16,12897,12899],{"href":12898},"colorpicker","Color Picker"," dialog helps you experiment with and choose\ncolors. Open it by choosing Color Picker on the Tools Menu.",[262,12902,12905],{"id":12903,"className":12904},"movies",[14],[16,12906,260],{"className":12907,"href":259},[19],[22,12909,12910],{},"This section describes how to capture an “.mp4” movie of a NetLogo model.",[22,12912,12913,12914,12920],{},"First, use the ",[16,12915,12917],{"href":12916},"vid#start-recorder",[556,12918,12919],{},"vid:start-recorder"," command to\nstart the video recorder.",[22,12922,12923,12924,6332,12930,12936],{},"To add a frame to your movie, use either\n",[16,12925,12927],{"href":12926},"vid#record-view",[556,12928,12929],{},"vid:record-view",[16,12931,12933],{"href":12932},"vid#record-interface",[556,12934,12935],{},"vid:record-interface",", depending on whether\nyou want the movie to show just the current view, or the entire Interface tab.\nIn a single movie, the resolution will be one of the following:",[44,12938,12939,12957,12968],{},[47,12940,12941,12942,573,12944,12956],{},"The resolution specified in the call to ",[556,12943,12919],{},[467,12945,12946],{},[556,12947,12948,573,12952],{},[559,12949,12951],{"className":12950},[562,1001],"width",[559,12953,12955],{"className":12954},[562,1001],"height","\nif you specified the resolution. These are optional parameters.",[47,12958,12959,12960,12962,12963,12965,12966],{},"The resolution of the view if you did not specify a resolution in the call to\n",[556,12961,12919],{}," and call ",[556,12964,12929],{}," before calling\n",[556,12967,12935],{},[47,12969,12970,12971,12962,12973,12965,12975],{},"The resolution of the interface if you did not specify a resolution in the\ncall to ",[556,12972,12919],{},[556,12974,12935],{},[556,12976,12929],{},[22,12978,12979],{},"Note that if the resolution of a recorded image doesn’t match the resolution of\nthe recording it will be scaled to fit which can result in images which look\nblurry or out-of-focus.",[22,12981,12982,12983,12989,12990,12993],{},"When you’re done adding frames, use\n",[16,12984,12986],{"href":12985},"vid#save-recording",[556,12987,12988],{},"vid:save-recording",". The filename you provide\nshould end with ",[556,12991,12992],{},".mp4",", the extension for MP4-encoded movies (playable in\nQuickTime and other programs).",[553,12995,12996],{},[556,12997,12998,13002,606,13007,620,13011,13013,13015,13019,13021,13023,13026,13028,13031,13033,573,13036,13040,13042,573,13045,13048,6210,13050,13053,1751,13055,958,13058,13060,573,13063],{},[559,12999,13001],{"className":13000},[562,563],";; export a 30 frame movie of the view",[559,13003,13005,5202],{"className":13004},[562,1190],[566,13006],{},[559,13008,13010],{"className":13009},[562,1001],"vid",[566,13012],{},[566,13014],{},[559,13016,13018],{"className":13017},[562,563],";...",[566,13020],{},[566,13022],{},[559,13024,1748],{"className":13025},[562,1001],[566,13027],{},[559,13029,12919],{"className":13030},[562,1001],[566,13032],{},[559,13034,12929],{"className":13035},[562,1001],[559,13037,13039],{"className":13038},[562,563],";; show the initial state",[566,13041],{},[559,13043,3784],{"className":13044},[562,944],[559,13046,8948],{"className":13047},[562,668],[566,13049],{},[559,13051,3515],{"className":13052},[562,1001],[566,13054],{},[559,13056,12929],{"className":13057},[562,1001],[566,13059],{},[559,13061,12988],{"className":13062},[562,1001],[559,13064,13066],{"className":13065},[562,2994],"\"out.mp4\"",[22,13068,13069],{},"A movie will play back at 25 frames per second. To make the movie playback\nfaster or slower, consider using a video postprocessing tool.",[22,13071,13072,13073,13079],{},"To check whether or not you are recording, call\n",[16,13074,13076],{"href":13075},"vid#recorder-status",[556,13077,13078],{},"vid:recorder-status",", which reports a string\nthat describes the state of the current recorder.",[22,13081,13082,13083,301],{},"To throw away the movie currently being recorded, call\n",[16,13084,13086],{"href":13085},"vid#reset-recorder",[556,13087,13088],{},"vid:reset-recorder",[1414,13090,13091],{},[22,13092,13093,13095],{},[281,13094,1420],{}," Movie Example",[22,13097,13098,13099,13101,13102,331,13104,301],{},"Movies generated when running headless, or by background runs in a parallel\nBehaviorSpace experiment may use only ",[556,13100,12929],{}," primitive. Movies\ngenerated in NetLogo GUI may also use ",[556,13103,12935],{},[16,13105,13107],{"href":13106},"vid#record-source",[556,13108,13109],{},"vid:record-source",[22,13111,13112,13113,13118],{},"NetLogo movies are exported as H.264-encoded MP4 files. To play an MP4 movie,\nyou can use ",[16,13114,13117],{"href":13115,"rel":13116},"http://www.videolan.org/vlc/index",[10295],"the VLC Player",", a free\ndownload from the VideoLAN organization.",[22,13120,13121],{},"Movies can take up a lot of disk space. You will probably want to compress your\nmovies with third-party software. The software may give you a choice of\ndifferent kinds of compression. Some kinds of compression are lossless, while\nothers are lossy. “Lossy” means that in order to make the files smaller, some of\nthe detail in the movie is lost. Depending on the nature of your model, you may\nwant to avoid using lossy compression, for example if the view contains fine\npixel-level detail.",{"title":13123,"searchDepth":13124,"depth":13125,"links":13126},"",5,3,[13127,13129,13146,13176,13189,13190,13198,13199,13200,13208,13220,13221],{"id":36,"depth":13128,"text":42},4,{"id":264,"depth":13130,"text":52,"children":13131},2,[13132,13133,13137,13140,13141,13142,13143,13144,13145],{"id":272,"depth":13125,"text":60},{"id":455,"depth":13125,"text":66,"children":13134},[13135,13136],{"id":1160,"depth":13128,"text":1166},{"id":1403,"depth":13128,"text":1409},{"id":1424,"depth":13125,"text":72,"children":13138},[13139],{"id":1835,"depth":13128,"text":1841},{"id":2159,"depth":13125,"text":78},{"id":296,"depth":13125,"text":84},{"id":2835,"depth":13125,"text":90},{"id":3005,"depth":13125,"text":96},{"id":3253,"depth":13125,"text":102},{"id":3351,"depth":13125,"text":108},{"id":3395,"depth":13130,"text":114,"children":13147},[13148,13149,13150,13151,13162,13163,13164],{"id":3402,"depth":13125,"text":122},{"id":128,"depth":13125,"text":128},{"id":134,"depth":13125,"text":134},{"id":5096,"depth":13125,"text":140,"children":13152},[13153,13154,13155,13156,13157,13158,13159,13160,13161],{"id":5103,"depth":13128,"text":5109},{"id":5135,"depth":13128,"text":5141},{"id":5147,"depth":13128,"text":5153},{"id":5221,"depth":13128,"text":5227},{"id":5251,"depth":13128,"text":5257},{"id":5263,"depth":13128,"text":5269},{"id":5275,"depth":13128,"text":5281},{"id":5355,"depth":13128,"text":5361},{"id":5663,"depth":13128,"text":5669},{"id":5961,"depth":13125,"text":146},{"id":6051,"depth":13125,"text":152},{"id":6165,"depth":13125,"text":158,"children":13165},[13166,13167,13168,13169,13170,13171,13172,13173,13174,13175],{"id":6184,"depth":13128,"text":6190},{"id":6352,"depth":13128,"text":6358},{"id":6391,"depth":13128,"text":6397},{"id":6408,"depth":13128,"text":6414},{"id":6661,"depth":13128,"text":6667},{"id":6673,"depth":13128,"text":6679},{"id":6690,"depth":13128,"text":6696},{"id":6702,"depth":13128,"text":6708},{"id":6877,"depth":13128,"text":6882},{"id":7071,"depth":13128,"text":7077},{"id":307,"depth":13130,"text":164,"children":13177},[13178,13182,13188],{"id":7093,"depth":13125,"text":172,"children":13179},[13180,13181],{"id":7153,"depth":13128,"text":7159},{"id":7247,"depth":13128,"text":7253},{"id":7274,"depth":13125,"text":178,"children":13183},[13184,13185,13186,13187],{"id":7305,"depth":13128,"text":7311},{"id":7344,"depth":13128,"text":7350},{"id":7407,"depth":13128,"text":7413},{"id":7446,"depth":13128,"text":7452},{"id":7474,"depth":13125,"text":184},{"id":7863,"depth":13130,"text":190},{"id":7955,"depth":13130,"text":196,"children":13191},[13192,13197],{"id":5782,"depth":13125,"text":204,"children":13193},[13194,13195,13196],{"id":8168,"depth":13128,"text":8174},{"id":8329,"depth":13128,"text":8335},{"id":8392,"depth":13128,"text":8398},{"id":8407,"depth":13125,"text":210},{"id":8777,"depth":13130,"text":216},{"id":10300,"depth":13130,"text":222},{"id":10755,"depth":13130,"text":228,"children":13201},[13202,13203],{"id":10762,"depth":13125,"text":236},{"id":11442,"depth":13125,"text":242,"children":13204},[13205,13206,13207],{"id":11628,"depth":13128,"text":11634},{"id":11643,"depth":13128,"text":11649},{"id":11664,"depth":13128,"text":11670},{"id":11789,"depth":13130,"text":248,"children":13209},[13210,13211,13212,13213,13214,13215,13216,13217,13218,13219],{"id":11807,"depth":13128,"text":11813},{"id":11872,"depth":13128,"text":11878},{"id":12058,"depth":13128,"text":12064},{"id":12096,"depth":13128,"text":12102},{"id":12156,"depth":13128,"text":12162},{"id":12203,"depth":13128,"text":12209},{"id":12233,"depth":13128,"text":12239},{"id":12245,"depth":13128,"text":12251},{"id":12281,"depth":13128,"text":12287},{"id":12443,"depth":13128,"text":12449},{"id":610,"depth":13130,"text":254},{"id":12903,"depth":13130,"text":260},"Comprehensive guide to the NetLogo programming language, covering syntax, commands, reporters, and programming concepts.","md",{"source":13225,"metadataOutputPath":13226,"projectConfig":13227,"language":13234,"inheritFrom":13243,"output":13242,"version":13228,"keywords":13244,"tags":13248,"icon":13249,"assetsRoot":13250},"autogen/programming.md","content/programming.metadata.yaml",{"version":13228,"projectRoot":301,"scanRoot":13229,"outputRoot":13230,"defaults":13231,"engine":13237,"partials":13238,"dedupeIdenticalDiskWrites":13242},"7.0.4","autogen","content",{"inheritFrom":13232,"language":13234,"output":13235,"extension":13223,"title":13236,"version":13228},[13233],0,"en",false,"NetLogo User Manual","handlebars",{"directoryPaths":13239,"extensions":13240},[301],[13241,13223],"mustache",true,[13233],[114,13245,13246,13247],"Language Reference","Coding","NetLogo",[114,13245,13246],"i-lucide-code","/home/runner/work/Helio/Helio/apps/docs/autogen","/programming",{"title":5,"description":13222},"kaMskvmXmNPsmkVmPuSniTeaf4L5Ffo6mAXwO8dulq4",[13255,13260],{"title":13256,"path":13257,"stem":13258,"description":13259},"Profiler Extension Dictionary: stop","/profiler/stop","profiler/stop","Documentation for the stop primitive.",{"title":13261,"path":13262,"stem":13263,"description":13264},"Python Extension","/py","py","Documentation for the Python extension.",1777657788733]