to four.bugs :t1 :t2 :t3 :t4 :d :times  my [:o1  ask :t1  pos ?] &
                                           [:o2  ask :t2  pos ?] &
                                           [:o3  ask :t3  pos ?] &
                                           [:o4  ask :t4  pos ?]
  repeat :times [towards :t1 :t2 :d :o1
                 towards :t2 :t3 :d :o2
                 towards :t3 :t4 :d :o3
                 towards :t4 :t1 :d :o4]
end

to towards :t1 :t2 :d :org  my [:pos  ask :t2  pos ?]
  ask :t1
  face :pos
  fd :d
  jump :org
end

to jump :org  my [:pos  pos ?]
  pos :org
  pos :pos
end

to hatchem
  ask :studs  turtle 0
  mapq @hatch [b1 b2 b3 b4]
  nothing
end

to position
  ask :b1  pen 0 pos [-300 -150] pen 1
  ask :b2  pen 0 pos [300 -150] pen 1
  ask :b3  pen 0 pos [300 150] pen 1
  ask :b4  pen 0 pos [-300 150] pen 1
end

to border
  ask :studs  pen 0 pos [-300 -150] pen 1
  e 600  n 300  w 600  s 300
end

to run.bugs :n
  cs
  position
  border
  ask :b1  ink 1 + rn 7
  ask :b2  ink 1 + rn 7
  ask :b3  ink 1 + rn 7
  ask :b4  ink 1 + rn 7
  four.bugs :b1 :b2 :b3 :b4 10 :n
  nothing
end

hatchem
erf "hatchem
