 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
+: color-fraction ( particle -- particle fraction ) dup theta>> pi + 2 pi * / ;
+
+: set-good-color ( particle -- particle )
+  color-fraction dup 0 1 between?
+    [ good-colors at-fraction-of >>myc ]
+    [ drop ]
+  if ;
+
+: set-anti-color ( particle -- particle )
+  color-fraction dup 0 1 between?
+    [ anti-colors at-fraction-of >>mya ]
+    [ drop ]
+  if ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
 METHOD: collide { muon }
 
-  dim 2 / dup 2array     >>pos
-  2 32 [a,b] random      >>speed
-  0.0001 0.001 2random   >>speed-d
+  center               >>pos
+  2 32 [a,b] random    >>speed
+  0.0001 0.001 2random >>speed-d
 
   collision-theta>  -0.1 0.1 2random + >>theta
   0                                    >>theta-d
   0                                    >>theta-dd
 
-  [ dup theta-dd>> abs 0.001 < ]
-    [ -0.1 0.1 2random >>theta-dd ]
-    [ ]
-  while
-
-  dup theta>> pi         +
-  2 pi *                 /
-  good-colors length 1 - *
-  [ ] [ good-colors length >= ] [ 0 < ] tri or
-    [ drop ]
-    [
-      [ good-color >>myc ]
-      [ good-colors length swap - 1 - good-color >>mya ]
-      bi
-    ]
-  if
+  [ 0.001 theta-dd-small? ] [ -0.1 0.1 random-theta-dd ] [ ] while
+
+  set-good-color
+  set-anti-color
 
   drop ;
 


  dup vel>> move-by

  dup
    [ speed>> ] [ theta>> { sin cos } <arr> ] bi n*v
  >>vel

  [ ] [ theta>>   ] [ theta-d>>  ] tri + >>theta
  [ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d
  [ ] [ speed>>   ] [ speed-d>>  ] tri * >>speed

  ! 1000 random 997 >
  3/1000 chance
    [
      1.0     >>speed-d
      0.00001 >>theta-dd

      ! 100 random 70 >
      30/100 chance
        [
          dim 2 / dup 2array >>pos
          dup collide
        ]
      when
    ]
  when

  out-of-bounds?
    [ collide ]
    [ drop ]
  if ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



  [ ] [ vel>> ] bi move-by

  turn

  step-theta
  step-theta-d
  step-speed-mul

  1000 random 997 >
    [
      dup speed>> neg    >>speed
      2 over speed-d>> - >>speed-d
    ]
  when

  out-of-bounds? [ collide ] [ drop ] if ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

