乌龟,斑块及其从一个斑块到下一个斑块的顺序移动 [英] Turtles, patches and their moving sequentially from one patch to the next
问题描述
Platfrom:NetLogo
Platfrom : NetLogo
- 问题
我要移动我的旗帜特定的3点
I want to move my flag specific 3 point
- A(-12 8)
- B(-5 12)
- C(6 4)
-在行驶此点时,能量/时间随机减小.
-While travelling this point plot energy/time randomly decrease.
-到达C标志时将消失.
-When reach C flag will die.
我之前曾问过,发现此解决方案适用于移动. (当乌龟到达2.点时,它不会停止)-LINES1-
I asked before and found this solution for moving. ( When turtle reached 2. point it will not stop ) - LINES1 -
breed [cities city]
breed [flag person]
flag-own [target]
to setup
clear-all
create-flag 1
[ set size 6
set shape "by"
setxy -5 3
set target patch -10 5
face target
]
< other commands >
end
to go
ask flag-on patch -10 5
[ set target patch <next place you want it to go>
face target
]
ask flag with [ shape = "by" ]
[ forward 1 ]
end
人们建议使用此代码来实现任何目标.
People suggest this code for towarding any target.
to go
ask people [
;; if at target, choose a new random target
if distance target = 0
[ set target one-of houses
face target ]
;; move towards target. once the distance is less than 1,
;; use move-to to land exactly on the target.
ifelse distance target < 1
[ move-to target ]
[ fd 1 ]
]
tick
end
在此代码中,他们将随机旅行,我不希望这样做.我无法在-LINES1-
In this code they will travel randomly and i dont want this. I cant implement this part at -LINES1-
我正在尝试用图片解释这一点.
I'm try to explain this with an image.
好吧,这是一个问题:我如何沿着这些点移动海龟并连接能量/时间或能量/距离的图形.
Well, this is the question : How can i move turtle along these points and connect the graph for energy/time or energy/distance.
CC:@Seth Tisue @JenB @yacc
CC : @Seth Tisue @JenB @yacc
-伙计们,我完成了我的社区计划援助中的运动部分.在此代码中,您的乌龟将移动特定点,并在到达最后一点时死亡.在旅行时,它正在绘制海龟的数量
-Guys i finished my movement part of my program aid of community. In this code your turtle will move specific point and it will die when it reach last point. While travel it is plotting the number of turtle
breed [cities city]
breed [flag person]
flag-own [target] ;;set features flag only
to setup
clear-all
reset-ticks
print "Setting up model."
set-default-shape cities "house" ;; set all cities shape by house
create-flag 1
[
set SIZE 2
set shape "turtle"
setxy -11 13
set target patch -3 12
face target
]
create-cities 1
[set color yellow set SIZE 2 setxy 8 2]
create-cities 1
[ set color yellow set SIZE 2 setxy -3 12]
create-cities 1
[ set color yellow set SIZE 2 setxy 3 3]
ask patch 3 3 [set pcolor red]
end
to go
ask flag-on patch -3 12 [
set target patch 8 2
face target
]
ask flag-on patch 8 2 [
set target patch 3 3
face target
]
ask flag-on patch 3 3 [
if distance target < 1 ;; check distance for last point
[die]]
ask flag with [ shape = "turtle" ]
[fd 1]
tick
end
推荐答案
您是否试图了解已经给出的答案?在setup
中,将-10 5
替换为要转到的第一个位置(即-12 8).然后相应地更新go
代码.
Have you tried to understand the answers you have already been given? In the setup
, replace -10 5
with the first place you want to go to (which is -12 8). Then update the go
code accordingly.
to go
ask flag-on patch -12 8
[ set target patch -5 12
face target
]
ask flag-on patch -5 12
[ set target patch 6 4
face target
]
ask flag with [ shape = "by" ]
[ forward 1 ]
end
这只是方向和发展方向.您需要尝试为精力和垂死之类编写一些代码.但是要逐渐做一些事情,使某些事情起作用,然后再添加下一部分.
This is just the direction and moving. You need to try and do some code for the energy and dying etc. But do things gradually, get something working and then add the next piece.
这篇关于乌龟,斑块及其从一个斑块到下一个斑块的顺序移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!