2019年3月13日水曜日

Tasks changed for NetLogo 6.0

Anonymous procedures have also been used in NetLogo [1]. A small NetLogo 5.0 code below shows two ways to supply arguments when calling the setup procedure. The keyword task indicates that there is an anonymous procedure next to it. The first case simply gives one number, "inital-value".  However, in the second case we have given the executable code "randam 4". This means that this anonymous procedure consists of a single statement that generates a random number.

The procedure setup called in these two cases is common to both, as shown in the figure below. The arguments of task shown in the above figure are passed to the argument setup-task. That is, the code of the executable procedure is passed to setup as if it were a value. In setup, runresult gives us the execution results of the passed procedure. This allows us to configure the contents of setup very flexibly. Not only that, but it also seems to be a mechanism to improve the effective performance.

By the way, this task is no longer available in NetLogo 6.0 [2]. The task has been changed to arrow syntax as shown in the following figure. This is good because it is the same as Java or JavaScript Lambda Expressions.




References
[1] Uri Wilensky and William Rand, "An Intoroduction to Agent-Based Modeling"(chapter 8 : Advance Topics and Applications),The MIT Press 
[2] Transition Guide in https://ccl.northwestern.edu/netlogo/docs/

0 件のコメント:

コメントを投稿