Agt_Init {
My.color = COLOR_YELLOW
My.speed = Rnd()
My.type = 0
My.good_count = 0
My.bad_count = 0
Turn(Rnd() * 360)
}
Agt_Step {
If Forward(My.speed) <> -1 Then
Turn(Rnd() * 360)
End If
MakeAllAgtSetAroundOwn(My.neighbor, 3, False)
Dim other As Object
Dim good_touch As Boolean
Dim bad_touch As Boolean
good_touch = False
bad_touch = False
If CountAgtSet(My.neighbor) > 0 Then
For Each other In My.neighbor
If other.type == 1 Then
good_touch = True
ElseIf other.type == 2 Then
bad_touch = True
End If
Next
My.touch = My.touch + 1 ⇐ここでエラーが出ている(他にもありそう)
My.color = RGB(255, 0, 0)
Else
My.color = RGB(255, 255, 0)
End If
If good_touch Then
My.good_count = My.good_count + 1
My.bad_count = 0
ElseIf bad_touch Then
My.bad_count = My.bad_count + 1
My.good_count = 0
End If
If My.good_count >= 3 Then
My.type = 1
My.color = RGB(0, 255, 0)
My.good_count = 0
My.bad_count = 0
ElseIf My.bad_count >= 5 Then
My.type = 2
My.color = RGB(0, 0, 0)
My.good_count = 0
My.bad_count = 0
End If
}
groundという空間に、Normal,Good,Badというエージェントがあり、これはNormalにおけるプロパティです。
変数は(Normalの中に)、color,speed(実数型),type,good_count,bad_count,neighbor(エージェント集合型),touchで整数型です。一応私自身のやりたい内容として、NormalがGoodと3回接触すればGoodに変化し、NormalがBadと
5回接触するとBadに変化するシュミレーションを作りたいです。
修正点分かる方または、改善点分かる方はコメントいただきたいです。
モデルファイルをダウンロードし、下の左から3つ目の「ファイルを追加」でアップロードしていただけますか?(もしくはモデルを公開して、URLを貼り付けてください)