routine INITIALIZE
   define PORT, I as an integer variable
   define DX, DY, POS, DIST, THETA as real variables

   reserve WORLDS(*,*) as 15 by 4

     '' read data from the "ports.dat" file  This routine will init graphics
   call READ.DATA

   create every DOCK(NO.OF.PORTS)
   for PORT = 1 to NO.OF.PORTS,
   do
      let U.DOCK(PORT) = PORT.NO.OF.BERTHS(PORT)
      activate a TUG given PORT now
      let DRTN.A(TUG) = 'V.TUG'
      let SEGPTY.A(TUG) = 1
      let TUG.LOCATION(TUG) = .IN.HARBOR
      let TUG.PORT(TUG) = PORT
      let PORT.TUG(PORT) = TUG
      let VXFORM.V = .PORT.TRANSFORMS + PORT-1
      display TUG with "rtug" at (PORT.X.ENTRANCE(PORT), PORT.Y.ENTRANCE(PORT))
   loop

   let DX = INIT.X2-INIT.X1        
   let DY = INIT.Y2-INIT.Y1
   let THETA = ARCTAN.F(DY, DX)
   let DIST = SQRT.F(DX * DX + DY * DY)

   let VXFORM.V = .OCEAN

     '' create all the tankers and position them at sea
   for I = 1 to NO.OF.TANKERS,
   do
      activate a SHIP now
      let SHIP.LOCATION(SHIP) = .AT.SEA
      let SEGPTY.A(SHIP) = 1
      let SHIP.SPEED(SHIP) = UNIFORM.F(400, 600, 3)   '' miles per day
      let SHIP.TYPE(SHIP) = "tanker"
 
      let POS = UNIFORM.F(0.0, DIST, 2)
      display SHIP with "tanker" at 
        (INIT.X1 + POS * COS.F(THETA), INIT.Y1 + POS * SIN.F(THETA))
   loop

     '' create all the freighter ships and position them at sea
   for I = 1 to NO.OF.FREIGHTERS,
   do
      activate a SHIP now
      let SHIP.LOCATION(SHIP) = .AT.SEA
      let SEGPTY.A(SHIP) = 1
      let SHIP.SPEED(SHIP) = UNIFORM.F(700, 900, 3)
      let SHIP.TYPE(SHIP) = "freighter"
 
      let POS = UNIFORM.F(0.0, DIST, 2)
      display SHIP with "freighter" at 
        (INIT.X1 + POS*COS.F(THETA), INIT.Y1 + POS*SIN.F(THETA))
   loop

   activate a FINAL.REPORT in RUN.LENGTH days
end   ''INITIALIZE
