首页 > 解决方案 > 尝试根据它们的坐标在补丁上设置不同的颜色

问题描述

我希望我的补丁根据它们的坐标具有不同的属性和颜色。我的最终目标是用灰色表示肠壁,用粉红色表示 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 语句

标签: agent-based-modelingrepast-simphony

解决方案


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


推荐阅读