|
|
我的模型,原意是使得每五个turtle成一个矩形,这些矩形随机散布在一定范围内。
8 X8 S" L- {0 K, J: a6 G L7 K8 t# Q8 Z$ W
但是运行结果所有的矩形重叠在一起,只显示一个矩形。请大家帮忙看看。
4 F4 s3 I; J/ f0 D
1 L- {9 W. L' s, p4 `+ s6 Uturtles-own [a b c d k f g h4 {6 c( x; {7 @
x y ;; these are the leaf-turtle's offsets relative to center-turtle 2 s9 @% G) c& ^
]
8 E1 F: ~ X4 s8 z& d6 lto new
; `( d1 ] O6 ?* R ca
0 E% y* t0 n# }6 g& _4 H3 _ crt 5 * num_of_building
2 n" p; K9 F; U) m* ]3 w& _0 g- m ask turtles [ifelse (remainder who 5 = 0) [set color red][set color blue]] r* L, ?- F r+ H, }! X; a
scatter ;;keep center-turtle random positions ( }& r( Z% i9 h# h
unit_plan ;;make up the building plan4 ?8 D" @% y, o
end1 ~6 b9 X6 P+ f2 h- P# f& g
to scatter; F0 s: r. D, l7 a
ask turtles with [remainder who 5 = 0]9 z. A# }: o# g+ d$ h
[
- S$ I! U4 }: M6 K# r' Iset xcor xcor - 6 + random-float 15
: G, q/ Y* j& g0 @$ Vset ycor ycor - 6 + random-float 15
5 _7 }, N( m) {$ N* t' ]) Y] y8 P9 `) g7 P4 |" t; Z8 a Z
end
1 X7 Q6 D$ B [4 T. Wto unit_plan
% S5 S, q* [6 ?! S) N8 vask turtles [& p. }7 C W: k& m8 s d+ D
if (remainder who 5 = 1) [set a who % r9 g& T% u& X' i0 f( V" p
set x ( 0 - Wid / 2 )
8 ~$ z" `& W% @3 v* M! i set y Dep / 2 ]7 k4 o) j. a5 s$ V3 J0 G9 L2 G
set b int (a / 5) * 57 T* S, n- U1 G6 R) K
setxy ( xcor-of turtle b + x )2 v' x: B5 w9 m: K" d3 h3 s" l6 s
( ycor-of turtle b + y ): p" G/ T5 V; e D7 B
if (remainder who 5 = 2) [set c who
# }' M8 e& C) r( l0 S4 Z7 P set x ( 0 - Wid / 2 ) % R0 _6 W. r4 F
set y (0 - Dep / 2 ) ]3 J0 `; t! x4 k. X2 q3 V9 n
set d int (c / 5) * 53 _& [: D4 T$ t3 `
setxy ( xcor-of turtle d + x )/ A' @4 S2 W. L+ T9 m) M; o- e5 |
(ycor-of turtle d + y ) , R7 Z$ P) _) _- a
' Q' ]( ]7 I' H/ W, B1 S ( d1 y* \. P5 |
if (remainder who 5 = 3) [set k who
3 s- t, S3 X6 s$ `1 I$ R8 s set x( Wid / 2)
' N, Y) q$ W5 a9 \& ^: [ set y (0 - Dep / 2 ) ]
" E, `; ]1 z$ L( J9 ] set f int (k / 5) * 5) j& o* m" [1 B9 Y
setxy ( xcor-of turtle f + x )
0 m" V/ N( m% g W! c: n7 k (ycor-of turtle f + y )
# v1 _' p9 z x
. h9 a7 D6 ]& I+ ^$ y( X) F. T
; g/ S& j% X) |/ D( ~1 \if (remainder who 5 = 4) [set g who
; ], W1 `: W" i set x Wid / 2 ; x4 h% Y; ~* c5 {7 }. b
set y Dep / 2 ]6 M$ |) i; H( n9 P) A, X
set h int (g / 5) * 5
5 @# ~1 N2 t z4 A setxy ( xcor-of turtle h + x )
2 x' z Q7 ?, m1 G- ^ (ycor-of turtle h + y )
# g0 Y. C& N6 ]. [ : x8 \& k4 G1 I! [9 }
2 N/ Y1 R) r7 [. T% ~
]" ?, O, ^2 r7 }% q; Y
end( u. a# N2 N" H5 |+ Q# G# W- e7 f
6 D2 H( `* j# i* K5 \* c& N( r
[ 本帖最后由 etamina 于 2008-4-10 16:41 编辑 ] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|