|
|
我的模型,原意是使得每五个turtle成一个矩形,这些矩形随机散布在一定范围内。6 ]8 s% [3 G4 t' | Q9 H0 |# f
- u) ]/ K# ?9 r% W" J& m! K5 V3 w
但是运行结果所有的矩形重叠在一起,只显示一个矩形。请大家帮忙看看。
% c( k& I8 v' p
" n; d t: _, H6 c! mturtles-own [a b c d k f g h
% m4 w( @5 T3 v t x y ;; these are the leaf-turtle's offsets relative to center-turtle
2 H$ N) Q1 e5 u6 ^]
2 B, I, ]9 n8 o' o0 Fto new
8 T z. ?+ q) j ca( ?0 S9 y) z: V; \5 x) o
crt 5 * num_of_building8 r9 u) B0 X) a
ask turtles [ifelse (remainder who 5 = 0) [set color red][set color blue]]5 M9 Q1 r4 ~( U) }& u6 ]& |% F
scatter ;;keep center-turtle random positions
/ K$ ]% U6 k3 L" l unit_plan ;;make up the building plan9 w- e6 g! V7 x; I7 l3 m
end
2 T" a3 Q k) [9 x2 j6 Rto scatter1 J. _, f2 m; d$ T
ask turtles with [remainder who 5 = 0]' X! R# h K8 W. W4 W& u1 x. l4 ]
[
9 ~, G' r" `: bset xcor xcor - 6 + random-float 152 S0 M$ y) @9 h
set ycor ycor - 6 + random-float 15
0 i. V& A; M3 N3 D5 j3 y8 ?]
3 p9 ]# G4 g3 ?6 ~( B! {4 _end3 Z6 a6 c& M# |( f- j
to unit_plan ( h2 _% m, v, e4 [5 [7 `
ask turtles [) D `: N a( U3 ~; h8 o6 {/ Y
if (remainder who 5 = 1) [set a who
. B+ Y1 j$ A. T$ x$ a( L' i% K; q set x ( 0 - Wid / 2 )
) W2 ~6 ^/ t" @6 `+ O set y Dep / 2 ]
, o4 N: g. v' e% s9 L6 x: Z" _ set b int (a / 5) * 58 m$ l- R$ U: ]7 d( B% f/ N4 n
setxy ( xcor-of turtle b + x )! d& l x& ^/ R9 Q; I
( ycor-of turtle b + y )) j( Y. t& |% [! A
if (remainder who 5 = 2) [set c who/ W6 R: \) N, @5 Q
set x ( 0 - Wid / 2 ) % Q' ?6 ^( x8 h9 E s1 B
set y (0 - Dep / 2 ) ]# Z( P e. ^6 W7 [/ e/ O! t
set d int (c / 5) * 5
2 `, |8 @$ p# `& J: ]' O# S7 X setxy ( xcor-of turtle d + x )
+ [& K4 M; j; H# E9 e6 A) O (ycor-of turtle d + y )
# f, ^% O) P2 z - ^# D1 a9 l- r: ^; t2 B5 z
, S$ `! X/ x. l: K
if (remainder who 5 = 3) [set k who
: Y' ~# S+ X. ] set x( Wid / 2)
9 Z$ f1 Z( g/ x& t- @2 z set y (0 - Dep / 2 ) ]
1 k6 _' K# M3 L/ v# {$ I set f int (k / 5) * 52 J- L# |1 H% ]; g5 F
setxy ( xcor-of turtle f + x )" _6 u, X, x! ^6 T5 F" k
(ycor-of turtle f + y ) 6 J; G9 s' H$ P2 y& T
5 b- ^" ^) D: R* `' ?; D# s' T$ }
- J! e N( c# Y
if (remainder who 5 = 4) [set g who
h/ `5 G* R, L! P0 J2 L7 d1 m set x Wid / 2 ) `7 n; ^6 N2 |2 ?' S
set y Dep / 2 ]" w1 {$ r8 ?0 k: T0 a) f$ s
set h int (g / 5) * 5
( i: ~: S9 \. @) y setxy ( xcor-of turtle h + x )
) v g# B5 M! G3 N* R (ycor-of turtle h + y ) " P) J) d: _ N
8 v' L( D2 }. _" \; p8 G/ i% ]6 A9 i
' \9 I9 C+ R0 ], O ]
& q7 Z; k7 X. Mend, l8 ]& A1 Q& _/ T. |* \) [! A/ V; g
0 x3 D/ P6 Z6 k4 y! |- ~8 ~[ 本帖最后由 etamina 于 2008-4-10 16:41 编辑 ] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|