我正在創建一個我想經常重複使用的AnyLogic代理。在許多AnyLogic代理和組件中,有些空間可以輸入代碼,如「on receive」或「Action」或「function body」。當模型被構建時,這些被編譯到代理中。一般程序員如何做到這一點?如何在AnyLogic中使用「code」參數創建代理?
例如,假設我有這樣的代理(僞代碼,很明顯):
userButton7 is a Button
name = "Emergency Button"
color = Red
onPress = {
for each Person p in simulation
p.tryToEscapeBuilding()
}
這是可能的:
Button extends Agent
name : Parameter // A normal parameter for recording the button's name.
color : Parameter // A normal parameter for recording the button's color.
onPress : <code> // User-provided code that is executed when the button is pressed.
客戶端如下可能會使用它?
什麼是「自定義修飾符」?我之前從未聽過這個術語,關於AnyLogic。 – 2014-10-21 15:51:15
啊,有趣;我需要玩一玩。 (你仍然錯過抽象方法之類的東西,儘管你可以用一個超類方法(函數)來近似它,這會創建一個異常,並說它需要被覆蓋。)我很確定你不能影響字段(它不會讓你添加具有相同名稱的字段),儘管這通常不太有用。 – 2014-10-21 16:43:18
@monsieurRigsby,我不知道你是什麼意思的「陰影字段」,但你可以重寫:方法,參數,變量等在超類 – 2014-10-24 10:01:00