netlogo

Pass a function as a parameter in Netlogo

两盒软妹~` 提交于 2021-01-27 13:20:33
问题 In many other programming languages, you can pass a function as an argument to another function and call it from within the function. Is there anyway to do this in Netlogo? Such as the following: ;; x,y,z are all ints to-report f [x y z] report x + y + z end ;; some-function is a function ;; x y and z are ints to-report g [some-function x y z] report (some-function x y z) + 2 end to go show g f 1 2 3 end This would be a nice feature. I'm trying to implement an abstract local search algorithm

Netlogo: “foreach” command with two lists

和自甴很熟 提交于 2020-08-10 19:32:36
问题 I have a complete directed graph with each link a weight of it's own. I've managed to select the max-out-link of every turtle. But, sometimes the max-out-link of two turtles are opposite of each other resulting in both links opposite of one another being selected. if this happens i want the link with the lower value to die. i have created the two lists with this: set max-end1 [[end1] of max-one-of my-out-links [trust]] of turtles set max-end2 [[end2] of max-one-of my-out-links [trust]] of

How to implement obstacle avoidance in Netlogo using the concept of two intersecting lines ( turtle heading vs wall made of patches)

非 Y 不嫁゛ 提交于 2020-06-23 09:53:29
问题 How can we convert the heading, of a Netlogo turtle, into a line equation (y = mx + c ) so that it can be compared to another line equation (eg that of patches representing a wall) ? I need to convert the heading of a turtle into a line equation. Then compare the heading line equation with the line equation of a wall (which will have either a fixed x or a fixed y – depending on whether the wall is vertical or horizontal) There is an interception lines example code in the library (that I don’t

Outcome of BehaviorSpace

守給你的承諾、 提交于 2020-05-30 10:51:05
问题 I am simulating a classroom to find the total energy consumption from appliances of a classroom. Now I want to run the simulation in BehaviorSpace so that I get the energy consumption by varying the number of students in the classroom. globals[ temp1 a s simulation-timer number-of-seats number-of-lights number-of-fans number-of-acs gap row col x-cor y-cor half half2 student-no t-light t-fan t-ac t-energy ] breed [seats seat] breeed [seat-teachers seat-teacher] breed [lights light] breed [fans

Outcome of BehaviorSpace

℡╲_俬逩灬. 提交于 2020-05-30 10:49:10
问题 I am simulating a classroom to find the total energy consumption from appliances of a classroom. Now I want to run the simulation in BehaviorSpace so that I get the energy consumption by varying the number of students in the classroom. globals[ temp1 a s simulation-timer number-of-seats number-of-lights number-of-fans number-of-acs gap row col x-cor y-cor half half2 student-no t-light t-fan t-ac t-energy ] breed [seats seat] breeed [seat-teachers seat-teacher] breed [lights light] breed [fans

Count number of occurrences in a list from same turtle

时光总嘲笑我的痴心妄想 提交于 2020-05-15 09:22:35
问题 I would like to know how to find the 'source' of an item in a list. The actions that I need to consider for this task are the following: 1) an item is added in a list created by a turtle; 2) as each turtle has its own list with items created by different turtles, I would like to set a counter that says how often this turtle has picked turtle A's item. APPROACH & CODE: This piece of code adds an item (local variable) called 'this_item' in the selected turtle's list: ask one-of turtles [ set

Generate rivers with random size and location

你说的曾经没有我的故事 提交于 2020-04-18 05:44:57
问题 I'm working on a smaller project and have one issue I can't find figure out any solutions for. I want to randomly generate rivers . My plan is to randomly generate a number of rivers with varying sizes and locations. Does anyone know how to generate rivers randomly? I have tried several things. I did manage to generate this, but I want it to be more like rivers (straight lines) and less 'clustered'. I used the following code to get the picture above. ; Generating random rivers. ca ask patches

Generate rivers with random size and location

て烟熏妆下的殇ゞ 提交于 2020-04-18 05:44:31
问题 I'm working on a smaller project and have one issue I can't find figure out any solutions for. I want to randomly generate rivers . My plan is to randomly generate a number of rivers with varying sizes and locations. Does anyone know how to generate rivers randomly? I have tried several things. I did manage to generate this, but I want it to be more like rivers (straight lines) and less 'clustered'. I used the following code to get the picture above. ; Generating random rivers. ca ask patches