Advertisement
jonsmebye

Untitled

Oct 2nd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BEGIN
  2.     EXTERNAL CLASS demos ;
  3.     demos
  4.         BEGIN
  5.         ! comments start with "!" or " comment " and ends with ; ! even if ; ! is not on the same line ;
  6.         ! all variable names you choose are NOT casesensitive , meaning that NAVN is the same as navn is the same as Navn .... ;
  7.         ! here you define all you variables ;
  8.  
  9.         REAL lambdaN, lambda;
  10.         INTEGER M,V,S,T;
  11.         BOOLEAN variables_of_type_boolean ;
  12.  
  13.         ! define random varaible ;
  14.  
  15.         !REF ( rdist ) (e.g., " NEGEXP ") ;
  16.         !REF ( idist ) random_variates_of_type_integer (e.g. , " UNIFORM ") ;
  17.         !REF ( bdist ) random_variates_of_type_boolean (e.g. , " DRAW ");
  18.  
  19.         ! EXTRA : if two dimeninsional tables are needed , with 10+1 elements in each dimension ;
  20.         !REAL ARRAY realvaule_tab (0:10 ,0:10) ;
  21.         !REF ( rdist ) ARRAY rdist_tab (0:10 ,0:10) ;
  22.         REF ( res ) ARRAY grid( -6:6 , -5:5) ;
  23.  
  24.         ! same with waitq , condq , tally , etc ... ;
  25.         !REF ( tally ) stat ;
  26.         !REF ( waitq ) ;
  27.         !REF ( condq ) LQ;
  28.  
  29.         integer var1;
  30.         var1:=1;
  31.  
  32.         ! generate cars, east and north;
  33.         Entity class GeneratorEast;
  34.         begin
  35.             integer i;
  36.             i := 1;
  37.             loop:
  38.                 new car(edit("car",i)).schedule(now);
  39.                 hold(20);
  40.             i := i + 1;
  41.             repeat;
  42.         end***GeneratorEast***;
  43.  
  44.         Entity class GeneratorNorth;
  45.         begin
  46.             integer i;
  47.             i := 1;
  48.             loop:
  49.                 new car(edit("car",i)).schedule(now);
  50.                 hold(20);
  51.             i := i + 1;
  52.             repeat;
  53.         end***GeneratorNorth***;
  54.  
  55.         entity CLASS car();
  56.         BEGIN
  57.             boolean direction;
  58.             integer speed;
  59.             integer xpos, ypos;
  60.  
  61.             if var1 = 0 then
  62.                 direction = false
  63.             else
  64.                 direction = true;
  65.  
  66.             if direction = false then
  67.                 begin
  68.                     grid(0,-5).acquire(1);
  69.                     xpos := 0;
  70.                     ypos := -5;
  71.                 end
  72.  
  73.             else
  74.                 begin
  75.                     grid(-6,0).acquire(1);
  76.                     xpos := -6;
  77.                     ypos := 0;
  78.                 end;
  79.  
  80. loop:
  81.                 speed := 15/(4 +1);
  82.                 hold(20.0);
  83.  
  84.                 ! trafikk lys;
  85.  
  86.                 if direction then
  87.                     begin
  88.                         if xpos +1 := 0 then
  89.                             outtext("Lyskryss neste");
  90.                     end;
  91.                 if not direction then
  92.                     begin
  93.                         if ypos +1 := 0 then
  94.                             outtext("Lyskryss neste");
  95.                     end;
  96.                 if direction := false then
  97.                     begin
  98.                         ypos := ypos + 1;
  99.                         grid(xpos,ypos).acquire(1);
  100.                         grid(xpos,ypos-1).release(1);
  101.                     end
  102.                 else
  103.                     begin
  104.                     xpos := xpos + 1;
  105.                     grid(xpos,ypos).acquire(1);
  106.                     grid(xpos-1,ypos).release(1);
  107.                     end;
  108. stop;
  109.  
  110.         ! generate segment resources;
  111.         for i=-6 step 1 until 6 do
  112.             grid(i,0) :- new res(edit("grid",i),1);
  113.  
  114.         for i=-5 step 1 until 5 do
  115.             grid(0,i) :- new res(edit("grid",i),1);
  116.  
  117.        
  118.  
  119.     end;
  120. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement