gpt4 book ai didi

plot - 在特定的刻度数处开始绘图

转载 作者:行者123 更新时间:2023-12-04 15:36:17 26 4
gpt4 key购买 nike

对于我的模型,我想从疏散开始的那一刻起计算疏散海龟的数量。

我有一个计数器开始计算秒数和分钟数,直到每只乌龟都离开模型(已撤离)。

这是计数器的程序:

to setuptime
let minutes_string (word minutes)
let seconds_string (word seconds)
if seconds < 10 [ set seconds_string (word "0" seconds)]
if minutes < 10 [ set minutes_string (word "0" minutes)]
set current_time (word minutes_string ":" seconds_string)
end

现在我想绘制撤离海龟的数量,从撤离开始后开始。当我按下“生火”按钮时,疏散开始了。

所以在 y 轴上,我有撤离海龟的数量。在 x 轴上,我想要火灾开始后的疏散时间。

但是如何在疏散开始时让剧情开始呢?现在它只是在滴答声开始时才开始。

点火按钮的代码:

to startfire
set initial-attendees count turtles
if alarm [
ask patches with [pycor > -2 and pycor < 4 and (pxcor > 1 and pxcor < 4)] [set pcolor red]
ask patches with [pycor > -160 and pycor < -154 and (pxcor < 120 and pxcor > 117)] [set pcolor red]
ask patches with [pycor > -2 and pycor < 4 and (pxcor > -3 and pxcor < 0)] [set pcolor red]
ask patches with [pycor > -160 and pycor < -154 and (pxcor > -120 and pxcor < -117)] [set pcolor red]]
set alarm? true
end

情节的代码正是我要找的。我通过计算初始与会者 - 计数与会者来计算疏散海龟的数量。

最佳答案

我仍然不清楚时间与刻度等的关系。下面的代码是一个简单的完整模型,在几个刻度后开始绘制。它的做法是 plot-pen-up 在设置代码中,所以绘图笔什么都不做。一旦输入几个滴答声,plot-pen-down 开始绘图。

to setup
clear-all
create-turtles 20 [setxy random-xcor random-ycor]
plot-pen-up
reset-ticks
end

to go
ask n-of random 5 turtles [hatch 1 right 90]
ask n-of random 5 turtles [die]
ask turtles [forward 1]
if ticks = 5 [plot-pen-down]
tick
end

该图只有 plot count turtles 的绘图命令。

在您的情况下,如果您有多个绘图,您将需要更复杂的东西来说明哪些笔是向上的还是向下的。您可以将 plot-pen-down 命令作为启动消防代码的一部分。

关于plot - 在特定的刻度数处开始绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59649803/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com