设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8485|回复: 2

[求助] 代碼的问题需要求助..

[复制链接]
发表于 2008-6-3 17:42:03 | 显示全部楼层 |阅读模式
10仿真币
我想请问各位大大高手帮我解决我的问题, m3 J, s/ K) e5 o5 {& ]
我先简述一下我所要做的模型,我的模型里,整体有两种人,政府与民众。
( i8 A' t+ e! R% k  @- e那政府里又分为四种策略的人faithfuls ,trigger-punishments ,trigger-punishments , mixeds
' K( j' v1 }& P; M0 t; K那政府要与民众互动,选择合作与不合作,政府合作和民众合作可得分(energy) : T- H/ ?. a  r4 y2 f
,相对的不合作也有得分但当我要开始写规则的时候,却发现程式无法照我的意思去跑,想请问各位高手能帮我看看是哪里出问题了吗?
2 N9 b  X5 M' M* Mbreed [peoples people]
# j# B+ J1 D5 Tbreed [faithfuls faithful]
7 _8 ~4 g8 ?, tbreed [trigger-punishments trigger-punishment]
$ e6 e5 E; e4 m  ^: j- L' Y( Abreed [tit-for-tats tit-for-tat]
2 S9 b0 v* D0 I  |' A  v& T% I$ wbreed [mixeds mixed]   
/ c% U; @4 U6 x% ~9 ]turtles-own [cooperate?  energy]7 O8 M. Q* e( w* d& [4 H9 ^

+ G! a$ _. L) I  f3 T! `3 sto setup# @) M4 j) `2 ?" B8 ]: }' z
set-default-shape turtles "person"
/ K6 p: @1 G1 e* O. \  clear-all               , C: X4 H  r, B+ W: z
  setup-peoples  
: z2 d+ |+ D. Q' `' C8 P  setup-goverments/ _9 z; x$ \8 ?" Y, ^# M
ask faithfuls  [ set energy 0 ] ( g6 H% l2 e3 x) b3 J0 i
ask trigger-punishments  [set energy 0 ]
9 A* T( e% r7 P* mask tit-for-tats  [set energy 0 ]1 a6 q) N: C6 i+ F! A0 q
ask mixeds  [set energy 0 ]8 S! S" [, d; t
ask peoples  [set energy 0 ]' M8 B# N2 v) s& d# E
end1 P1 ?! Z5 t: m% [0 Q

; L3 q  y% z% h6 F, cto setup-peoples
" x! t' k& O* l5 g, Z2 T$ i7 G) S% Q7 G
ask patches with [-1 < pxcor and pxcor < 20 and pycor = 0]
5 N7 I0 W0 x" ]3 L& q/ ^8 U5 J[sprout-peoples 1 [ set color blue set heading 0 ]
! O: w* ]+ r7 \
- ?3 u8 m' v4 b# h# D  Q7 `3 h9 `]
$ ]6 s& X. {: C6 r, Send* k- C! _* f% x6 Y) A) i% ?

; q$ W* s* ~; wto  setup-goverments
0 z' H. p. ^* Z4 Icreate-faithfuls  5 [set color red set heading 180]
( Y6 x% y5 Y; d3 J2 G5 Y% w: Vcreate-trigger-punishments  5 [set color green set heading 180]6 Q7 a0 G, N9 X5 [
create-tit-for-tats  5 [set color white set heading 180]
1 O7 v) [( `: a' F; ]  }create-mixeds  5 [set color pink set heading 180]; ~  x$ @5 ^4 U9 }
ask turtles with [ color != blue ] [while [any? other turtles-here] [setxy random 20 1]
, c- w6 r4 k3 H. }; X* `]
6 v+ ?3 `( `1 d- H# m2 |7 O9 uend+ G; e+ A: Q) K
' _1 u1 y6 I0 M& @* O- R
to go- d9 y( N5 A# Z8 d4 p' G2 Q
ask  peoples [ set cooperate? random 2] 3 p/ W* }+ z) w# V0 i
  ask  faithfuls [  set cooperate? random 2] + y: y0 p, z8 |% y  f
  ask  trigger-punishments [ set cooperate? random 2]
- r* o" D6 Q8 W  ask  tit-for-tats [ set cooperate? random 2]! P) A, b6 Z. S$ @& N7 ?
  ask  mixeds [ set cooperate? random 2]8 U& u+ o! k* @  }/ A
  6 e& t0 M; M& C0 X9 x% l- W
  ask faithfuls [ 1 f9 D5 u$ B) F2 j( V
  if ( cooperate? = [cooperate?] of peoples-on patch-ahead 1 ) & n) f  Q7 B; P  E1 Y7 {- h
   [  set energy  energy + 8 # F! Q& V0 X! i% `* m( `$ `  H
      ask peoples-on patch-ahead 1 [ set energy  energy + 2] ]8 G8 y' _5 C& Q
      ]         就是这里出问题了无法照我的意思去跑9 e* g# Z: P! D! l
  ifelse (show-energy?)
  [2 e; U$ i& r8 {! e    [ ask turtles [ set label (energy) ] ]' T  l( ^8 }, x7 ]) R8 v( K1 g& V
    [ ask turtles [ set label "" ] ]
7 y. X* `* y, T* Z  end8 ~7 y* O9 H' I$ e( ^8 j! m2 R
希望大家能帮我解决一下不然我没办法继续写下去
6 v- T* W) Y8 B: D/ u; X& v' ?0 T$ ~- i
[ 本帖最后由 h64914110 于 2008-6-4 10:51 编辑 ]

最佳答案

查看完整内容

为什么不考虑用patches设定政府,假设政府不能够移动,民众可以通过用脚投票选择政府。这样也许可以解决你说的问题。
发表于 2008-6-3 17:42:04 | 显示全部楼层
为什么不考虑用patches设定政府,假设政府不能够移动,民众可以通过用脚投票选择政府。这样也许可以解决你说的问题。
 楼主| 发表于 2008-6-4 11:57:22 | 显示全部楼层
简单点说好了模型固定分为上下两排,上为政府下为民众
3 d* |* A; y/ T6 j' D9 @1 ?每一个政府类的人对应一个民众: T# s3 I; S& g( v; x: R
上下两两对应  但我现在问题就是  我不知道turtles是否有互相对应到
6 G( v% ~0 j7 u+ s# j7 ]; E) T2 O那如果没对应到    要让turtles互相对应的语法又该怎么写? 1 w) j% m# B0 O
我是新手  麻烦大家帮帮忙  传短讯给我也可以  谢谢
+ a+ M! j; |' J) t
- T* {+ g& Y+ s4 o- g8 \' U[ 本帖最后由 h64914110 于 2008-6-4 11:58 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2025-12-16 15:25 , Processed in 0.018025 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表