   #console.log "#### AP: #{JSON.stringify ap}"
   
   #Create the initial field. Put 2 patterns: p1 and p2 at initial time 
-  fld1 = Cells.copy p1
-  fld2 = Cells.copy p2
-  
-  Cells.offset fld1, ap.npos0[0], ap.npos0[1]
-  Cells.offset fld2, ap.npos1[0], ap.npos1[1]
-  
-  time1 = ap.npos0[2]
-  time2 = ap.npos1[2]
-
   #nwo promote them to the same time, using list evaluation
-  tmax = Math.max time1, time2
-  
-  evalToTime = (fld, t, tend) ->
-    if t > tend then throw new Error "assert: bad time"
-    while t < tend
-      fld = evaluateCellList rule, fld, mod2(t)
-      t += 1
-    return fld
-    
-  fld1 = evalToTime fld1, time1, tmax
-  fld2 = evalToTime fld2, time2, tmax
-  time = tmax
-
+  time = Math.max ap.npos0[2], ap.npos1[2]
+  fld1 = patternAtTime rule, p1, ap.npos0, time
+  fld2 = patternAtTime rule, p2, ap.npos1, time
+  
   #OK, collision prepared. Now simulate both spaceships separately and
   # together, waiting while interaction occurs
   timeGiveUp = params.tcoll + waitForCollision #when to stop waiting for some interaction

  collision.products = finishCollision rule, coll.field, coll.time
  return collision

simulateUntilCollision = (rule, fld1, fld2, time, timeGiveUp) ->
  fld  = fld1.concat fld2  
  while time < timeGiveUp

#    collision::bool true if collision
#    timeStart::int first generation, where interaction has started
#    products::[ ProductDesc ]  list of collision products (patterns with their positions and classification
doCollision = (rule, p1, v1, p2, v2, offset, initialSeparation = 30, collisionTreshold=20)->
  waitForCollision = v1[2] + v2[2] #sum of periods
  params = collisionParameters [0,0,0], v1, offset, v2  
  ap = approachParameters [0,0,0], v1, offset, v2, initialSeparation
  collision = {collision:false}
  if not ap.approach
    #console.log "#### No approach, nearest approach: #{params.dist}"
