agent-based-modeling - 尝试根据它们的坐标在补丁上设置不同的颜色
问题描述
我希望我的补丁根据它们的坐标具有不同的属性和颜色。我的最终目标是用灰色表示肠壁,用粉红色表示 lumus,所以我使用 for 循环在 userPatch 中实现它
def i=0
for(i;i<=32;i++) {
i++
if(distance(patch(i,32))==0) {
Gutwall()}
else {
Gutlummus() }
if(i<=32) {
continue
}
}}
但它似乎只为 i=0 执行 if 语句
解决方案
You wouldn't need to iterate through the patches since the UserPatch represents each individual patch. You would just need to check that the patch is the target patch. It might also help to familiarize yourself with Groovy syntax, e.g., for for loops: https://groovy-lang.org/semantics.html#_looping_structures
推荐阅读
- sql-server - SQLLocalDb 无法识别但连接到 SSMS
- scala - 如何使用单个隐式参数调用 object.apply?
- kubernetes - 无法让 kubernetes 上的 traefik 在家庭实验室中使用外部 IP
- mysql - 如何删除mysql查询中的所有特殊字符
- swift - 如何在 Swift 中从 xml 中获取数据
- c# - Json 反序列化失败
- powershell - 如何从 PowerShell 命令中获取输出的第一个字
- node.js - 收到弃用警告,并建议使用我在 MongoDB/Mongoose 中使用的内容
- bash - 如果搜索文件时 elif 不起作用
- angular - 我们如何在 keydown 事件中识别角色的位置?