to T N_Body [ [[1 100][0 0][0 0]][[2 80][30 0][0 0]][[3 60][0 40][0 0]] ] end to T1 N_Body [ [[1 90000][0 0][0 0]][[2 100][30 0][0 5]][[3 50][0 40][-7 0]] ] end to N_Body :init_Turtles make "Time 0 hideturtle penup show :init_Turtles Time_Goes_By :Time :init_Turtles pendown end to Time_Goes_By :Time :State_of_Turtles if empty? :State_of_Turtles [ print "|The list, :State of Turtles is empty! | stop ] Show_Turtles :State_of_Turtles Time_Goes_By :Time + 1 Next_State :State_of_Turtles end to Show_Turtles :State_of_Turtles if empty? :State_of_Turtles [ stop ] clean show :State_of_Turtles print :Time Show_the_First [ ] :State_of_Turtles end to Show_the_First :Memo_of_Pos :Ttls local [First_Turtle FirPos FirV M_Heading] if empty? :Ttls [stop] make "First_Turtle first :Ttls home setcolor first first :First_Turtle make "FirPos item 2 :First_Turtle make "FirV item 3 :First_Turtle if ( distance :FirV ) > 0 [ seth towards :FirV ] setpos :FirPos if Neighbour? :Memo_of_Pos [ Dead stop ] pendown c [/* ここで亀さんをかいています。1匹しか使えない処理系用 */] back 1 left 90 forward 2 right 115 forward 5 right 130 forward 5 right 115 forward 4 penup setpos :FirPos pendown fill penup c [/* 亀さんをかく部分おしまい */---------------------------] Show_the_First lput :FirPos :Memo_of_Pos butfirst :Ttls end to Dead showturtle repeat 360 [ forward 1 right 1] make "State_of_Turtles [] end to Neighbour? :L if empty? :L [ output ( 0 = 1 ) ] if ( distance first :L ) < 5 [ output ( 1 = 1 ) ] output Neighbour? butfirst :L end to Next_State :State if ( count :State ) < 2 [ print "??? stop ] make "NewState :State output ConsEachOther :State butfirst :State end to ConsEachOther :a :b local [Ap L1 L2 Id1 Id2 i1 i2 M1 M2 p1 p2 x1 x2 y1 y2 V1 V2 R ] if ( count :a ) < 2 [ output :NewState ] if empty? :b [ make "Ap butfirst :a output ConsEachOther :Ap butfirst :Ap ] make "L1 first :a make "L2 first :b make "Id1 first :L1 make "Id2 first :L2 make "i1 first :Id1 make "i2 first :Id2 make "M1 item 2 :Id1 make "M2 item 2 :Id2 make "p1 item 2 :L1 make "p2 item 2 :L2 make "x1 first :p1 make "x2 first :p2 make "y1 item 2 :p1 make "y2 item 2 :p2 make "V1 item 3 :L1 make "V2 item 3 :L2 setpos :p1 make "R distance :p2 make "NewState Revice :NewState [ ] output ConsEachOther :a butfirst :b end to Revice :Before :After type "+ if empty? :Before [ output :After ] if ( first first first :Before ) = :i1 [ output Revice butfirst :Before lput Consider 1 :After ] if ( first first first :Before ) = :i2 [ output Revice butfirst :Before lput Consider -1 :After ] output Revice butfirst :Before lput first :Before :After end to Consider :Sw local [ D k ] make "k 5.0 * ( :Sw * ( :M1 + :M2 ) - ( :M1 - :M2 ) ) / ( :R * :R * :R ) make "D ( list :k * ( :x2 - :x1 ) :k * ( :y2 - :y1 ) ) if :Sw = 1 [ output ( list :Id1 VecSum :p1 :V1 VecSum :V1 :D ) ] if :Sw = -1 [output ( list :Id2 VecSum :p2 :V2 VecSum :V2 :D ) ] end to VecSum :a :b local [a1 a2 b1 b2] make "a1 first :a make "a2 item 2 :a make "b1 first :b make "b2 item 2 :b output (list :a1 + :b1 :a2 + :b2) end to c :Comment end