//====================================================================/ // / // KK-Multi Agent Simulator for Java / // / //====================================================================/ Version = 1.0; //------------------------------------------------------- // Component Tree //------------------------------------------------------- UNIVERSE { Space mundo(0,0),Square_2D(10, 10, Loop, North, 1){ AgtType hombre(0, 0)[100] { 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 cultura(0, 0) As String = (""); Dim iro(0, 0) As Integer = (0); } } Dim numero(0, 0) As Integer = (0); } //------------------------------------------------------- // Agent Variable Initial Data //------------------------------------------------------- Initial_Value { } //------------------------------------------------------- // Agent Rule //------------------------------------------------------- #begin_rule UNIVERSE Univ_Init{ } Univ_Step_Begin{ } Univ_Step_End{ dim set as agtset dim hito as agt dim s as string dim i as integer //初期化します s= "" //全体の集合を作ります makeagtsetspace(set, universe.mundo) for each hito in set //sの中に人の文化の先頭3桁が無ければ、それを追加します if InStr(1, s, left(hito.cultura, 3)) == 0 then s = s & hito.cultura end if next hito //今ある文化は println(s)で全部です。 //一つあたり3桁プラス1桁(スペース)取っているので、4で割れば文化の数が出てきます。 universe.numero = len(s)/4 } Univ_Finish{ } #end_rule UNIVERSE //------------------------------------------------------- // Agent Rule //------------------------------------------------------- #begin_rule UNIVERSE.MUNDO.HOMBRE Agt_Init{ my.X = my.id mod 10 my.Y = my.id \ 10 //文化を3桁で表し、その後ろにスペースを一つ付けます。 my.cultura = cstr(cint(rnd()*10)) & cstr(cint(rnd()*10)) & cstr(cint(rnd()*10)) &" " } Agt_Step{ dim mawari as agtset dim kazu as integer dim aite as agt dim r as double makeallagtsetaroundown(mawari, 1, false) kazu = countagtset(mawari) aite = getagt(mawari, cint(kazu*rnd())) if StrComp(my.cultura, aite.cultura) <> 0 then //相手の3つの桁のうちどれかを受け入れる r = rnd()*3 if r <1 then // my.cultura = left(my.cultura, 1) & mid(my.cultura, 2, 1) & right(my.cultura , 1) my.cultura = mid(aite.cultura, 1, 1) & mid(my.cultura, 2, 1) & mid(my.cultura, 3, 1)&" " elseif r <2 then my.cultura = mid(my.cultura, 1, 1) & mid(aite.cultura, 2, 1) & mid(my.cultura, 3, 1) &" " else my.cultura = mid(my.cultura, 1, 1) & mid(my.cultura, 2, 1) & mid(aite.cultura, 3, 1)&" " end if end if //RGB()で、一桁目×25、二桁目×25 という風にして色を付ける。 my.iro = RGB(cint(mid(my.cultura, 1, 1))*25, cint(mid(my.cultura, 2, 1))*25, cint(mid(my.cultura, 3, 1))*25) } #end_rule UNIVERSE.MUNDO.HOMBRE //------------------------------------------------------- // Simulation Definition Division //------------------------------------------------------- Single_Simulation { Step_Max = 0; Time_Max = 0; End_Condition = ""; Exec_Wait = 0; Exec_Order = Random; Exec_Order_Random_First_Step_Only = No; Random_Seed = 0; Log_File = "", Fixed, Append, 0; Replay_Log_File = "", Fixed, Append, 0; Redraw_Timing = Step; Redraw_Interval = 1; Garbage_Interval = 10; } //------------------------------------------------------- // Simulation Loop Definition Division //------------------------------------------------------- Repeat_Simulation { Value_Change = None; Repeat_Max = 1; } //------------------------------------------------------- // 2 Dimension Map Display Definition Division //------------------------------------------------------- Map_Output { Map_Space_Name = "Universe.mundo"; 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, 9, 9; Ruled_Line = No; Remarks = Yes; 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 = 80; Position_y = 1; Size_x = 1082; Size_y = 789; Origin_Position = 2; Output { Map_Element_Name = "ヒト"; Map_Element = Agent_Variable; Output_Expression = "UNIVERSE.mundo.hombre"; Draw_Line = No; Collection_Name = ""; Line_Type = 0; Line_Arrow = 0; Line_Width = 0; Line_Color = 0, 0, 0; Agent_Color = "UNIVERSE.mundo.hombre.iro"; Marker_Id = 1; Icon_Type = 0; Icon_Var_Name = ""; Icon_Transparent = No; Icon_Enlarg_Reduce = No; Icon_File_Name = ""; Num_Display = Yes; Num_Var_Name = "UNIVERSE.mundo.hombre.cultura"; } } //------------------------------------------------------- // 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, 100.0, 100, 10.0; Remarks = Yes; Legend_Pos = Top; Background_Color = 0, 0, 0; Disable = No; Position_x = 97; Position_y = 26; Size_x = 500; Size_y = 300; Output { Graph_Element_Name = "文化の数"; Line_Color = 255, 0, 0; Line_Width = 2; Marker_Id = 0; Output_Expression = "universe.numero"; Expression_Value_Display = No; Effective_Fraction_Figures = 0; } } //------------------------------------------------------- // Control Panel Definition Division //------------------------------------------------------- Control_Panel { Display_Area = 0, 0, 100, 100; } //------------------------------------------------------- // 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 = 18.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 = 140; Console_Size_x = 681; Console_Size_y = 380; }