设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8627|回复: 2

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

[复制链接]
发表于 2008-6-3 17:42:03 | 显示全部楼层 |阅读模式
10仿真币
我想请问各位大大高手帮我解决我的问题2 t$ k& ?; O0 n
我先简述一下我所要做的模型,我的模型里,整体有两种人,政府与民众。
! ^8 ?8 B; {; S$ z那政府里又分为四种策略的人faithfuls ,trigger-punishments ,trigger-punishments , mixeds
$ }, Q; P& I/ u) S9 ^% u那政府要与民众互动,选择合作与不合作,政府合作和民众合作可得分(energy)
2 a* w3 s. f  v' ?! {) l4 u,相对的不合作也有得分但当我要开始写规则的时候,却发现程式无法照我的意思去跑,想请问各位高手能帮我看看是哪里出问题了吗?2 [+ k% n# D) J4 Y
breed [peoples people]
1 U, G: E# h/ _6 hbreed [faithfuls faithful]
  i3 u8 G0 O' `! \; `* V) hbreed [trigger-punishments trigger-punishment]
. u1 g4 f2 m9 q& p; Xbreed [tit-for-tats tit-for-tat]4 }4 p! X( W6 C4 K
breed [mixeds mixed]    1 ~! m+ [! y2 k0 f" n% S
turtles-own [cooperate?  energy]
# e/ ]& S5 m1 U. X& p; r+ R- Z# D' f
to setup& w: C1 P, }9 Z( h$ {' I
set-default-shape turtles "person"
8 h( Y! E9 v2 a/ a$ W6 N) ^  clear-all               
  Z; u( Q. j1 j( w  setup-peoples  
* X( v( b$ h8 i( K  setup-goverments1 R2 e3 H# _/ O# X& ~8 f
ask faithfuls  [ set energy 0 ]
3 j; L/ {, f' R! ~7 B1 _ask trigger-punishments  [set energy 0 ]
& ~+ }6 Y; X0 `4 X, g1 t! K# A! c$ U7 bask tit-for-tats  [set energy 0 ]. t* V, b* ^- ]5 Y7 \7 e6 ]
ask mixeds  [set energy 0 ]
- D' c) Y4 M/ L4 aask peoples  [set energy 0 ]0 Q4 U* O; n" [  e* e2 `& X6 u' y" T
end7 a6 Q: e7 |% [; @+ k/ B5 M- @( u

; d7 [& P' I  hto setup-peoples: }2 e( k. ^+ S# s; N
8 x" F4 W" O5 _/ J  Y
ask patches with [-1 < pxcor and pxcor < 20 and pycor = 0]( w( J$ K7 m0 w9 M: ?" }7 m
[sprout-peoples 1 [ set color blue set heading 0 ]
) u5 B7 _$ u. l1 ?2 F4 z1 p/ W
# ^5 H4 i! g9 r5 E: m4 s+ v]3 r9 f; N( P6 l% \0 o
end/ k1 \0 |. g2 @1 V8 y2 l7 F
' F6 k; }2 ^  n% m; O) {4 \) Q
to  setup-goverments
4 f. n6 h) @9 x! ~1 \create-faithfuls  5 [set color red set heading 180] ! d& L7 J6 Z" q1 C
create-trigger-punishments  5 [set color green set heading 180]
% @6 r' E+ m% B" Ocreate-tit-for-tats  5 [set color white set heading 180]
0 T# u2 J/ w" y  Dcreate-mixeds  5 [set color pink set heading 180]
' T: I( O  \  mask turtles with [ color != blue ] [while [any? other turtles-here] [setxy random 20 1]
- P3 X; o2 E/ c9 |]- X2 G: Y1 Z! L5 F! o
end+ ?9 s, o: H" {. K2 b+ x. a
+ C% m+ ?4 c+ p
to go
5 k: v" i( |' R/ G7 K- Jask  peoples [ set cooperate? random 2]
& S# \" C4 n# A' C" }5 m7 B  ask  faithfuls [  set cooperate? random 2] 2 c6 y+ i4 f5 {6 ^  l  u2 b
  ask  trigger-punishments [ set cooperate? random 2]' U+ S$ `6 E/ x) ]" x
  ask  tit-for-tats [ set cooperate? random 2]6 K; y7 v4 m9 q9 r9 ?9 a. {; }
  ask  mixeds [ set cooperate? random 2]
2 M3 i: t, q. w  S) _* R# G. j  
, I# D* O+ F0 B# W  ask faithfuls [
* ^  v' s3 _- G6 S$ a; k  if ( cooperate? = [cooperate?] of peoples-on patch-ahead 1 )
( q& t" X; e6 x8 m! h   [  set energy  energy + 8
; F- d) H3 r  [( ?- F2 r. b      ask peoples-on patch-ahead 1 [ set energy  energy + 2] ]. |1 v5 e1 B' O8 U: V
      ]         就是这里出问题了无法照我的意思去跑  S; B: C  Q( q% f& t1 D/ r
  ifelse (show-energy?)
: E9 |0 G4 ^) i4 ^    [ ask turtles [ set label (energy) ] ]# p2 f. |# s; W
    [ ask turtles [ set label "" ] ]  P  y: `$ r) {0 ?
  end8 D) L" S( C" m1 L4 y; I
希望大家能帮我解决一下不然我没办法继续写下去
. G) `3 R8 n9 d$ m  Y3 Y* V8 g3 s. h3 J* |' t
[ 本帖最后由 h64914110 于 2008-6-4 10:51 编辑 ]

最佳答案

查看完整内容

为什么不考虑用patches设定政府,假设政府不能够移动,民众可以通过用脚投票选择政府。这样也许可以解决你说的问题。
发表于 2008-6-3 17:42:04 | 显示全部楼层
为什么不考虑用patches设定政府,假设政府不能够移动,民众可以通过用脚投票选择政府。这样也许可以解决你说的问题。
 楼主| 发表于 2008-6-4 11:57:22 | 显示全部楼层
简单点说好了模型固定分为上下两排,上为政府下为民众2 R' N9 W( X0 C7 f' V
每一个政府类的人对应一个民众1 f& p8 K- q: Q1 X# m2 b2 `
上下两两对应  但我现在问题就是  我不知道turtles是否有互相对应到* j4 O3 C- l& h6 c, y
那如果没对应到    要让turtles互相对应的语法又该怎么写?
8 ~7 N% N9 C, R& D- S/ T我是新手  麻烦大家帮帮忙  传短讯给我也可以  谢谢6 k1 w& {+ z8 _6 [) F2 D+ f  D" d4 A. K
# f0 a% U% M7 D: a
[ 本帖最后由 h64914110 于 2008-6-4 11:58 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-1-31 02:44 , Processed in 0.014365 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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