[英]Specifying resource sets in seize block based on agent variable
Agents being pushed through the model have a variable isMorning
which is set to false
, but is made true
if they are injected before a certain time.通过 model 推送的代理有一个设置为
false
的变量isMorning
,但如果它们在特定时间之前被注入,则会变为true
。 When the agents enter a seize block, I would like to add a condition that relies on if isMorning
is true
or not in order to pick a resource set.当代理进入占用块时,我想添加一个条件,该条件依赖于
isMorning
是否为true
,以便选择资源集。 I would like to know the proper syntax in using conditionals within the Resource sets parameter to choose between different resource sets, or if this must be done in another parameter.我想知道在资源集参数中使用条件来在不同资源集之间进行选择的正确语法,或者这是否必须在另一个参数中完成。
Best option is to create a new function eg getResoruceSet(boolean isMorning
and then return ResourcePool[][]
最好的选择是创建一个新的 function 例如
getResoruceSet(boolean isMorning
然后返回ResourcePool[][]
You can then use this function to replace the resource set parameter in the seize block然后,您可以使用这个 function 来替换占用块中的资源集参数
your code inside the function needs to create new arrays for ResorucePool
where the first dimension is the number of resources that needs to be seized and the second is the different sets.您在 function 中的代码需要为 ResorucePool 创建新的
ResorucePool
,其中第一个维度是需要占用的资源数量,第二个维度是不同的集合。
For example:例如:
if (isMorning) {
return new ResourcePool[][] {
{ resourcePool, resourcePool }
};
} else {
return new ResourcePool[][] {
{ resourcePool1},
{ resourcePool, resourcePool2, resourcePool2}
};
}
If it is morning you need to seize 2 units of resourcePool
.如果是早上,您需要占用 2 个单位的
resourcePool
。 If it is not morning you either need to seize 1 unit from resorucePool1
or 2 unit from resourcePool
and 2 from resorucePool2
如果不是早上,您需要从
resorucePool1
中获取 1 个单位,或者从resourcePool
中获取 2 个单位,从resorucePool2
中获取 2 个单位
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.