【发布时间】:2014-06-09 23:06:31
【问题描述】:
我目前正在使用 IFS 构造 scheme 在 NetLogo 中创建征费 C 曲线的图形表示。我发现了两个函数,它们描述了如何迭代地映射两只海龟的位置,并且应该在数千次迭代后产生所需的曲线。到目前为止,这是我的代码:
;;;;;; some useful complex operations
; to take re(z) of a complex number a + bi inputed as the list of coordinates [a b]
to-report re [z]
report first z
end
; to take im(z)
to-report im [z]
report last z
end
; to multiply two complex numbers
to-report complex_mul [z1 z2]
report list (re z1 * re z2 - im z1 * im z2)
(re z1 * im z2 + im z1 * re z2)
end
; to add complex numbers
to-report complex_add [z1 z2]
report list (re z1 + re z2)
(im z1 + im z2)
end
; to dilate complex numbers by a scalar fraction
to-report complex/real [z1 real]
report list (re z1 / real)
(im z1 / real)
end
; to initialize
to setup
ca
setup-turtles
reset-ticks
end
; create 2 turtles located at the initial set of points {0, 1}
to setup-turtles
crt 2
ask turtle 0 [ setxy 0 0]
ask turtle 1 [ setxy 1 0]
ask turtles [ pd]
end
; to create the first function to transform the turtle's location
to-report nextz_1 [z]
report complex/real (complex_mul [1 -1] z) 2
end
; to create the second function to transform the turtle's location
to-report nextz_2 [z]
report complex_add [1 0]
(complex/real (complex_mul [1 1]
(complex_add z [-1 0]))
2)
end
; finally we are creating the Levy Curve
to levy
ask turtles [ run one-of (list task setxy re (nextz_1 [xcor ycor]) im (nextz_1 [xcor ycor])
task setxy re (nextz_2 [xcor ycor]) im (nextz_2 [xcor ycor])
)
]
end
但是,我在调用 re (nextz_1 [xcor ycor]) 等的“征税”代码块中收到一条错误消息,说 NetLogo 期望一个常数值代替 xcor 和 ycor。
我该如何解决这个问题?
【问题讨论】: