设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8185|回复: 2

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

[复制链接]
发表于 2008-6-3 17:42:03 | 显示全部楼层 |阅读模式
10仿真币
我想请问各位大大高手帮我解决我的问题
" J) |+ _& m; J+ j我先简述一下我所要做的模型,我的模型里,整体有两种人,政府与民众。 9 O1 B+ [  |0 N! W" D
那政府里又分为四种策略的人faithfuls ,trigger-punishments ,trigger-punishments , mixeds , u( h5 d& L& [
那政府要与民众互动,选择合作与不合作,政府合作和民众合作可得分(energy)
- z9 |# p# }( t7 C. r/ d3 p, H,相对的不合作也有得分但当我要开始写规则的时候,却发现程式无法照我的意思去跑,想请问各位高手能帮我看看是哪里出问题了吗?# k# R3 h+ ?- W
breed [peoples people]
7 b! W  I4 K' M" _6 f' bbreed [faithfuls faithful]
4 i, b- Z! F; Cbreed [trigger-punishments trigger-punishment]- p/ P8 W6 [) \
breed [tit-for-tats tit-for-tat]
; T9 n2 M, Y  H% |) }. V  {breed [mixeds mixed]   
2 f" ]1 @1 s% [. R7 Sturtles-own [cooperate?  energy]
4 w+ C4 r7 _7 s6 b) H3 T. m9 L) R1 N6 @4 m" x
to setup
* r; ~& A, T4 f2 [$ oset-default-shape turtles "person"; x3 ^' r- ~+ R" ]1 T
  clear-all               ! ^4 S& o9 i* y3 D; r& e
  setup-peoples  ; B: q+ R7 {3 B* b: _2 w; c
  setup-goverments2 c2 {5 @5 L/ f' T- G1 f
ask faithfuls  [ set energy 0 ] * o- {6 g  ]. U# w. B
ask trigger-punishments  [set energy 0 ]. L. }4 @' u8 A0 A
ask tit-for-tats  [set energy 0 ]
" N. P% X5 h) d# b) iask mixeds  [set energy 0 ]
8 \! E3 ?( N) P' R0 S/ task peoples  [set energy 0 ]; Q' x+ p6 g; m# f
end8 p$ o/ [6 ^1 ^0 z* c4 M) f

5 d4 z+ q/ X1 p& x( H, ^/ U, o. L# Fto setup-peoples5 P) f: j7 N* R! S3 h0 U" f

0 I2 c8 k5 u: F' c" C- Dask patches with [-1 < pxcor and pxcor < 20 and pycor = 0]
& z. C% x. K) B; h" a[sprout-peoples 1 [ set color blue set heading 0 ]! E6 g' {) @& H- Z3 j! L% K
' |0 B" J/ [# y  Y& y4 I
]. a4 E. D5 @: V8 T+ k* h* I
end; J% c% x9 K3 C
' M. ?8 P; @/ T! U
to  setup-goverments* L2 ^, x3 Z& q6 Y
create-faithfuls  5 [set color red set heading 180]   ?! c& Q' W/ ~4 M2 E
create-trigger-punishments  5 [set color green set heading 180]5 K5 o4 O' A$ J
create-tit-for-tats  5 [set color white set heading 180]8 A; D& V+ e6 x$ |* }
create-mixeds  5 [set color pink set heading 180]
! t+ G* u- M' `; Iask turtles with [ color != blue ] [while [any? other turtles-here] [setxy random 20 1]
0 [) p6 @, t6 r% |5 A* Y]
6 D2 j, M! E, z" W. I! tend
4 F* A/ N. L; n& s  l' n' s; ?* _, |4 y
to go
5 }5 u- m  Q+ u- A: j& Cask  peoples [ set cooperate? random 2]
. `7 l8 o0 @2 Z2 s  k( C  ask  faithfuls [  set cooperate? random 2] ! ]5 a7 n, Y* x& \3 z0 @0 P% I
  ask  trigger-punishments [ set cooperate? random 2]1 Y, f& [2 Y) ~1 z! _$ B; s
  ask  tit-for-tats [ set cooperate? random 2]
, {: g" q  i( Q7 P8 i( s3 P& q* ~  ask  mixeds [ set cooperate? random 2]
. g/ V1 P! Z8 G$ a, {4 o  
. N4 J6 D' l% L5 j8 R  ask faithfuls [ ' b* t$ }2 A+ x  m3 i5 R5 }- c
  if ( cooperate? = [cooperate?] of peoples-on patch-ahead 1 ) - p2 Z9 W1 [: ]- S; }* ^: G
   [  set energy  energy + 8
7 P0 G. P7 `. y4 i      ask peoples-on patch-ahead 1 [ set energy  energy + 2] ]" F2 ?2 g: N4 v0 u2 a
      ]         就是这里出问题了无法照我的意思去跑
5 k# \4 p5 }  W& U% L- s  ifelse (show-energy?)1 d0 w* z* [+ N0 b6 R& {
    [ ask turtles [ set label (energy) ] ]! f0 e5 U" V6 }% q: C. K
    [ ask turtles [ set label "" ] ]! L8 B0 A9 y5 r7 g6 \
  end
$ M) t# ^- Q: r& N$ v, r% z希望大家能帮我解决一下不然我没办法继续写下去
) e) e" L7 G- `+ Z# H) H  V0 x5 t9 H) Y" j  ^" f
[ 本帖最后由 h64914110 于 2008-6-4 10:51 编辑 ]

最佳答案

查看完整内容

为什么不考虑用patches设定政府,假设政府不能够移动,民众可以通过用脚投票选择政府。这样也许可以解决你说的问题。
发表于 2008-6-3 17:42:04 | 显示全部楼层
为什么不考虑用patches设定政府,假设政府不能够移动,民众可以通过用脚投票选择政府。这样也许可以解决你说的问题。
 楼主| 发表于 2008-6-4 11:57:22 | 显示全部楼层
简单点说好了模型固定分为上下两排,上为政府下为民众
! J( G2 i  B+ I0 q5 k& [每一个政府类的人对应一个民众! |0 Z" ~$ t! B: M. j
上下两两对应  但我现在问题就是  我不知道turtles是否有互相对应到
. ?  D+ ^- l1 J! [那如果没对应到    要让turtles互相对应的语法又该怎么写?
9 N: N+ z. J2 O3 t7 F- @4 u我是新手  麻烦大家帮帮忙  传短讯给我也可以  谢谢
, T4 d) z* }4 l2 f: \" D$ n8 U9 o' C% s5 j0 l
[ 本帖最后由 h64914110 于 2008-6-4 11:58 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-10-30 11:14 , Processed in 0.015195 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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