//====================================================================/ // / // KK-Multi Agent Simulator for Java / // / //====================================================================/ Version = 1.0; //------------------------------------------------------- // Component Tree //------------------------------------------------------- UNIVERSE { Space 二次元空間(0,0),Square_2D(8, 8, !Loop, North, 1){ AgtType 赤カメ(0, 0)[0] { Dim X(0, 0) As Double = (0.0); Dim Y(0, 0) As Double = (0.0); Dim Layer(0, 0) As Integer = (0); Dim Direction(0, 0) As Double = (0.0); Dim 幸福度(0, 0) As Double = (0.0); } AgtType 青カメ(0, 0)[0] { Dim X(0, 0) As Double = (0.0); Dim Y(0, 0) As Double = (0.0); Dim Layer(0, 0) As Integer = (0); Dim Direction(0, 0) As Double = (0.0); Dim 幸福度(0, 0) As Double = (0.0); } } Dim カメの数(0, 0) As Integer = (0); Dim 満足水準(0, 0) As Double = (); Dim 幸福なカメ(0, 0) As Integer = (0); Dim 幸福度合計(0, 0) As Double = (0.0); } //------------------------------------------------------- // Agent Variable Initial Data //------------------------------------------------------- Initial_Value { UNIVERSE.カメの数 = 1(50); UNIVERSE.満足水準 = 1(0.4); } //------------------------------------------------------- // Agent Rule //------------------------------------------------------- #begin_rule UNIVERSE Univ_Init{ Dim i As Integer Dim カメの集合 As AgtSet For i = 0 To Universe.カメの数 / 2 - 1 AddAgt(カメの集合, CreateAgt(Universe.二次元空間.赤カメ)) AddAgt(カメの集合, CreateAgt(Universe.二次元空間.青カメ)) Next i RandomPutAgtSetCell(カメの集合, False) Universe.カメの数 = CountAgtSet(カメの集合) } Univ_Step_Begin{ If Universe.幸福なカメ == Universe.カメの数 Then ExitSimulation() End If Universe.幸福なカメ = 0 Universe.幸福度合計 = 0 } Univ_Step_End{ } Univ_Finish{ } #end_rule UNIVERSE //------------------------------------------------------- // Agent Rule //------------------------------------------------------- #begin_rule UNIVERSE.二次元空間.赤カメ Agt_Init{ Dim 周りの赤カメ As AgtSet Dim 赤カメ数 As Double Dim 周りのカメ As AgtSet Dim カメ合計 As Double MakeOneAgtSetAroundOwnCell( 周りの赤カメ, 1, Universe.二次元空間.赤カメ, false ) 赤カメ数 = CountAgtSet( 周りの赤カメ ) MakeAllAgtSetAroundOwnCell( 周りのカメ, 1, false ) カメ合計 = CountAgtSet( 周りのカメ ) If 赤カメ数 > 0 Then My.幸福度 = 赤カメ数 / カメ合計 Else My.幸福度 = 0 End If Universe.幸福度合計 = Universe.幸福度合計 + My.幸福度 If My.幸福度 >= Universe.満足水準 Then Universe.幸福なカメ = Universe.幸福なカメ + 1 End If } Agt_Step{ Dim 周りの赤カメ As AgtSet Dim 赤カメ数 As Double Dim 周りのカメ As AgtSet Dim カメ合計 As Double MakeOneAgtSetAroundOwnCell( 周りの赤カメ, 1, Universe.二次元空間.赤カメ, false ) 赤カメ数 = CountAgtSet( 周りの赤カメ ) MakeAllAgtSetAroundOwnCell( 周りのカメ, 1 , false) カメ合計 = CountAgtSet( 周りのカメ ) If 赤カメ数 > 0 Then My.幸福度 = 赤カメ数 / カメ合計 Else My.幸福度 = 0 End If Universe.幸福度合計 = Universe.幸福度合計 + My.幸福度 If My.幸福度 < Universe.満足水準 Then MoveToSpaceOwnCell( 3 ) Else Universe.幸福なカメ = Universe.幸福なカメ + 1 End If } #end_rule UNIVERSE.二次元空間.赤カメ //------------------------------------------------------- // Agent Rule //------------------------------------------------------- #begin_rule UNIVERSE.二次元空間.青カメ Agt_Init{ Dim 周りの青カメ As AgtSet Dim 青カメ数 As Double Dim 周りのカメ As AgtSet Dim カメ合計 As Double MakeOneAgtSetAroundOwnCell( 周りの青カメ, 1, Universe.二次元空間.青カメ, false ) 青カメ数 = CountAgtSet( 周りの青カメ ) MakeAllAgtSetAroundOwnCell( 周りのカメ, 1, false ) カメ合計 = CountAgtSet( 周りのカメ ) If 青カメ数 > 0 Then My.幸福度 = 青カメ数 / カメ合計 Else My.幸福度 = 0 End If Universe.幸福度合計 = Universe.幸福度合計 + My.幸福度 If my.幸福度 >= Universe.満足水準 Then Universe.幸福なカメ = Universe.幸福なカメ + 1 End If } Agt_Step{ Dim 周りの青カメ As AgtSet Dim 青カメ数 As Double Dim 周りのカメ As AgtSet Dim カメ合計 As Double MakeOneAgtSetAroundOwnCell( 周りの青カメ, 1, Universe.二次元空間.青カメ, false ) 青カメ数 = CountAgtSet( 周りの青カメ ) MakeAllAgtSetAroundOwnCell( 周りのカメ, 1, false ) カメ合計 = CountAgtSet( 周りのカメ ) If 青カメ数 > 0 Then My.幸福度 = 青カメ数 / カメ合計 Else My.幸福度 = 0 End If Universe.幸福度合計 = Universe.幸福度合計 + My.幸福度 If my.幸福度 < Universe.満足水準 Then MoveToSpaceOwnCell( 3 ) Else Universe.幸福なカメ = Universe.幸福なカメ + 1 End If } #end_rule UNIVERSE.二次元空間.青カメ //------------------------------------------------------- // Simulation Definition Division //------------------------------------------------------- Single_Simulation { Step_Max = 0; Time_Max = 0; End_Condition = ""; Exec_Wait = 0; Exec_Order = Random; Random_Seed = 0; Log_File = "", Fixed, Append, 0; Replay_Log_File = "", Fixed, Append, 0; Redraw_Timing = Step; Redraw_Interval = 1; Garbage_Interval = 0; } //------------------------------------------------------- // Simulation Loop Definition Division //------------------------------------------------------- Repeat_Simulation { Value_Change = None; Repeat_Max = 1; } //------------------------------------------------------- // 2 Dimension Map Display Definition Division //------------------------------------------------------- Map_Output { Map_Space_Name = "UNIVERSE.二次元空間"; Map_Name = "二次元空間"; Font_Name = "Dialog"; Font_Char_Set = 81; Font_Size = 12.0; Font_Style = 0; Font_Color = 0, 0, 0; Font_Background_Color = 255, 255, 255; Title = "二次元空間"; Axis_Label = "", ""; Draw_Range = 0, 0, 7, 7; Ruled_Line = Yes; Remarks = No; Legend_Pos = Top; Background_Color = 0, 0, 0; Background_Transparent = No; Target_Layer = 0; Coordinate_Display = No; Space_Kind = Square_2D; BG_Pict = No; BG_Type = 0; BG_Var_Name = ""; BG_File_Name = ""; Disable = No; Position_x = 263; Position_y = 8; Size_x = 500; Size_y = 300; Origin_Position = 1; Output { Map_Element_Name = "赤カメ"; Map_Element = Agent_Variable; Output_Expression = "UNIVERSE.二次元空間.赤カメ"; Draw_Line = No; Collection_Name = ""; Line_Type = 0; Line_Arrow = 0; Line_Width = 0; Line_Color = 0, 0, 0; Agent_Color = 255,0,0; Marker_Id = 1; Icon_Type = 0; Icon_Var_Name = ""; Icon_Transparent = No; Icon_Enlarg_Reduce = No; Icon_File_Name = ""; Num_Display = No; Num_Var_Name = ""; } Output { Map_Element_Name = "青カメ"; Map_Element = Agent_Variable; Output_Expression = "UNIVERSE.二次元空間.青カメ"; Draw_Line = No; Collection_Name = ""; Line_Type = 0; Line_Arrow = 0; Line_Width = 0; Line_Color = 0, 0, 0; Agent_Color = 0,0,255; Marker_Id = 1; Icon_Type = 0; Icon_Var_Name = ""; Icon_Transparent = No; Icon_Enlarg_Reduce = No; Icon_File_Name = ""; Num_Display = No; Num_Var_Name = ""; } } //------------------------------------------------------- // Numeric Data Window Output Definition Division //------------------------------------------------------- Numeric_Output { Numeric_Name = "数値出力"; Font_Name = "Dialog"; Font_Char_Set = 81; Font_Size = 12.0; Font_Style = 0; Font_Color = 0, 0, 0; Font_Background_Color = 255, 255, 255; Title = "数値出力"; Disable = No; Position_x = 354; Position_y = 311; Size_x = 500; Size_y = 300; Output { Output_Element_Name = "ステップ数"; Figures = 0; Format_Id = 0; Output_Expression = "GetCountStep()"; } Output { Output_Element_Name = "不幸なカメ"; Figures = 0; Format_Id = 0; Output_Expression = "Universe.カメの数 - Universe.幸福なカメ"; } Output { Output_Element_Name = "平均幸福度"; Figures = 2; Format_Id = 0; Output_Expression = "Universe.幸福度合計 / Universe.カメの数"; } } //------------------------------------------------------- // Time Graph Display Definition Division //------------------------------------------------------- Time_Graph { Graph_Name = "時系列グラフ"; Font_Name = "Dialog"; Font_Char_Set = 81; Font_Size = 12.0; Font_Style = 0; Font_Color = 0, 0, 0; Font_Background_Color = 255, 255, 255; Title = "不幸なカメの数"; Axis_Label = "", ""; Scale = 0, 0.0, 1000, 60.0, 10, 10.0; Remarks = No; Legend_Pos = Top; Background_Color = 0, 0, 0; Disable = No; Position_x = -151; Position_y = 311; Size_x = 500; Size_y = 300; Output { Graph_Element_Name = "不幸なカメの数"; Line_Color = 255, 0, 0; Line_Width = 1; Marker_Id = 0; Output_Expression = "Universe.カメの数 - Universe.幸福なカメ"; Expression_Value_Display = No; Effective_Fraction_Figures = 0; } } //------------------------------------------------------- // Control Panel Definition Division //------------------------------------------------------- Control_Panel { Display_Area = 826, 267, 152, 179; Panel_Item { Item_Type = Slider; Item_Name = "カメの数"; Display_Area = 0, 0, 0, 0; Font_Name = ""; Font_Char_Set = 0; Font_Size = 0.0; Font_Style = 0; Font_Color = 0, 0, 0; Font_Background_Color = 0, 0, 0; Var_Name = UNIVERSE.カメの数; Slider_Range_Max = 50; Slider_Value_Min = 10.0; Slider_Value_Step = 1.0; Slider_Value = "40"; } Panel_Item { Item_Type = Slider; Item_Name = "満足水準 "; Display_Area = 0, 0, 0, 0; Font_Name = ""; Font_Char_Set = 0; Font_Size = 0.0; Font_Style = 0; Font_Color = 0, 0, 0; Font_Background_Color = 0, 0, 0; Var_Name = UNIVERSE.満足水準; Slider_Range_Max = 10; Slider_Value_Min = 0.0; Slider_Value_Step = 0.1; Slider_Value = "4"; } } //------------------------------------------------------- // Space Initial Value Definition Divsion //------------------------------------------------------- Space_Initial { } //------------------------------------------------------- // Other Miscellaneous Data Definition Division //------------------------------------------------------- Others_Data { Indent = 4; Rule_Colored = Yes; Font_Name = "Dialog"; Font_Char_Set = 0; Font_Size = 12.0; Font_Style = 0; Font_Color = 0, 0, 0; Font_Background_Color = 0, 0, 0; Window_Hide_Run = 1; Debug_Position_x = 75; Debug_Position_y = 75; Debug_Size_x = 400; Debug_Size_y = 200; Console_Position_x = 2; Console_Position_y = 400; Console_Size_x = 600; Console_Size_y = 120; }