home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / 11CHAOS.ZIP / POINTP.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1989-02-05  |  1.5 KB  |  60 lines

  1. program points;
  2.  
  3. uses crt,graph,drivers;
  4.  
  5. var
  6.   xCor, yCor           : integer;
  7.   xMax, xMaxHalf, yMax : integer;
  8.   Gm,Gd                : integer;
  9.   pixel                : word;
  10.   seed                 : word;
  11.   width                : word;
  12.   Zero,One,Two         : Word;
  13.   Iterations           : LongInt;
  14.   ch                   : char;
  15.  
  16. begin
  17.   Gd := Detect;
  18.   InitGraph(Gd,Gm,'');
  19.   if graphresult <> grOK then Halt(1);
  20.   SetTextStyle(DefaultFont,HorizDir,1);
  21.   xMax     := GetMaxX;
  22.   xMaxHalf := GetMaxX div 2;
  23.   yMax     := GetMaxY;
  24.   pixel    := GetMaxColor;
  25.   Randomize;
  26.   yCor := Random(yMax);
  27.   Width := trunc(xMax * (yCor / yMax));
  28.   xCor := Random(Width) + (xMax - Width) div 2 ;
  29.   Iterations := 0; Zero := 0; One := 0; Two := 0;
  30.  
  31.   Repeat
  32.     PutPixel(xCor,yCor,Pixel);
  33.     Inc(Iterations);
  34.     Case Random(3) of
  35.       0 : Begin
  36.             xCor := xCor div 2;
  37.             yCor := yCor div 2;
  38.             Inc(Zero);
  39.           End;
  40.       1 : Begin
  41.             xCor := xCor + ((xMax - xCor) div 2);
  42.             yCor := yCor div 2;
  43.             Inc(One);
  44.           End;
  45.       2 : Begin
  46.             If xCor > xMaxHalf then
  47.               xCor := xCor - ((xCor - xMaxHalf) div 2)
  48.             Else
  49.               xCor := xCor + ((xMaxHalf - xCor) div 2);
  50.             yCor := yCor + ((yMax - yCor) div 2);
  51.             Inc(Two);
  52.           End;
  53.     End;
  54.   Until KeyPressed;
  55.   ch := readkey;
  56.  
  57.   CloseGraph;
  58.   Writeln('Iterations=',Iterations,' Zero=',Zero,' One=',One,' Two=',Two);
  59. End.
  60.