home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_41.arc / CHAOS.ARC / CHAOS.PRO < prev    next >
Text File  |  1988-03-18  |  8KB  |  283 lines

  1. nowarnings
  2.  
  3. include "tdoms.pro"
  4. include "tpreds.pro"
  5. include "linemenu.pro"
  6.  
  7. Database - graphics
  8.  
  9.   Determ driver(Integer,Integer,String)
  10.   Determ maxcolors(Integer)
  11.   Determ maxX(Integer)
  12.   Determ maxY(Integer)
  13.   Determ aspectCorr(Real)
  14.   Determ graphCoord(Integer,Integer)
  15.   Determ lineStyleDBA(Integer,Integer,Integer)
  16.   Determ textHeightDBA(Integer)
  17.  
  18.   Determ params(Real,Real,Real,Real,Real,Real,Real,Real,Real)
  19.  
  20. /* Initialize video and Global flags */
  21.  
  22. PREDICATES
  23.  
  24. GetDriverName(Integer,String)
  25. Initialize
  26. nondeterm KeepColor(Integer,Integer,Integer)
  27. ToGrapHic
  28. ToText
  29.  
  30. CLAUSES
  31.  
  32. Initialize:-
  33.     ToGraphic,
  34.       GetMaxColor(MaxColors),   assert(maxcolors(MaxColors)),
  35.       GetMaxX(MaxX),      assert(maxX(MaxX)),
  36.       GetMaxY(MaxY),      assert(maxY(MaxY)),
  37.       GetAspectRatio(Xasp,Yasp),
  38.       AspectRatio = Xasp/Yasp,  assert(aspectCorr(AspectRatio)).
  39.  
  40. ToGrapHic:-
  41.     /* Detect graphic equipment */
  42.     DetectGraph(G_Driver, G_Mode1),
  43.     KeepColor(G_Driver,G_Mode1,G_Mode),
  44.     GetDriverName(G_Driver,G_Name),
  45.     assert(driver(G_Driver,G_Mode,G_Name)),
  46.     InitGraph(G_Driver,G_Mode, _, _, bgi_Path),!.
  47.  
  48. ToText:-
  49.     closegraph().
  50.  
  51. KeepColor(1,_,0).
  52. KeepColor(_,Mode,Mode).
  53.  
  54. GetDriverName(0,"Detect").    GetDriverName(1,"CGA").
  55. GetDriverName(2,"MCGA").    GetDriverName(3,"EGA").
  56. GetDriverName(4,"EGA64").    GetDriverName(5,"EGAMono").
  57. GetDriverName(6,"Reserved").    GetDriverName(7,"HercMono").
  58. GetDriverName(8,"ATT400").    GetDriverName(9,"VGA").
  59. GetDriverName(10,"PC3270").
  60.  
  61. /* Main */
  62.  
  63. PREDICATES
  64.  
  65. Function(Real,Real,Real,Real,Real,Real,Real,Real,Real)
  66. Iterate(Real,Real,Real,Real,Real,Real,Real,Real,Real,Real)
  67. Iterate_Trace(Real,Real,Real,Real,Real,Real,Real,Real,Real,Real)
  68. Main
  69. Main_menu
  70. NextProcess(Integer)
  71. Process(Integer)
  72. Testwindow(Integer)
  73.  
  74. CLAUSES
  75.  
  76. Iterate(X,L,Count,I,XScale,YScale,Height,Width,YStart,XStart):-
  77.     Y =  X * (1-X),
  78.     Y1 = Y * L,
  79.     Row = Height - (((Y1 - YStart)/ YScale) * Height),
  80.     Col = (((Count - XStart)/ XScale)) * Width,
  81.     putpixel(Col,Row,7),    
  82.     Newcount = Count + I,
  83.     XEnd = XScale + XStart,
  84.     Newcount <= XEnd,
  85.     !,
  86.     Y > 0.1E-275,
  87.     Iterate(Y1,L,Newcount,I,XScale,YScale,Height,Width,YStart,XStart).
  88. Iterate(_,_,_,_,_,_,_,_,_,_).
  89.  
  90. Iterate_Trace(X,L,Count,I,XScale,YScale,Height,Width,YStart,XStart):-
  91.     Y =  X * (1-X),
  92.     Y1 = Y * L,
  93.     Row = Height - (((Y1 - YStart)/ YScale) * Height),
  94.     Col = (((Count - XStart)/ XScale)) * Width,
  95.     shiftwindow(3),
  96.     write("YStart: ",YStart),
  97.     write("X : ",Count," "),
  98.     write("Y : ",Y1," "),
  99.     write("Col : ",Col," "),
  100.     write("Row : ",Row," "),nl,
  101.     putpixel(Col,Row,7),    
  102.     Newcount = Count + I,
  103.     XEnd = XScale + XStart,
  104.     Newcount <= XEnd,
  105.     !,
  106.     Y > 0.1E-275,
  107.     Iterate_Trace(Y1,L,Newcount,I,XScale,YScale,Height,Width,YStart,XStart).
  108. Iterate_Trace(_,_,_,_,_,_,_,_,_,_).
  109.  
  110. Function(I,X,Height,Width,XScale,YScale,L,XStart,YStart):-
  111.     Y = L * X * (1 - X),
  112.         Row = Height - (((Y - YStart)/ YScale) * Height),
  113.         Col = (((X - XStart)/ XScale)) * Width,
  114.     NextXRel = X + I,
  115.     XEnd = XScale + XStart,
  116.     NextXRel <= XEnd,
  117.     putpixel(Col,Row,2),
  118.     !,function(I,NextXRel,Height,Width,XScale,YScale,L,XStart,YStart).
  119. function(_,_,_,_,_,_,_,_,_).
  120.     
  121. Main:-
  122.     makewindow(1,7,0,"",0,0,25,80),
  123.     makewindow(2,7,0,"",2,0,12,80),
  124.       makewindow(3,7,0,"",22,0,3,80),
  125.     makewindow(99,18,7,"",8,22,10,36), nl,
  126.       write("              CHAOS"),nl, 
  127.     write("      (a Quick Code Project)"),nl,nl,
  128.         write("      copyright (c) 1988 by"),nl,
  129.         write("      acquired intelligence"),nl,
  130.         write("   po box 2091; davis, ca 95617"),
  131.       Main_menu.
  132. Main_menu:-      
  133.   linemenu(0,18,0,["Parameters","Function","Iterate","Trace","Quit"],C),
  134.   testwindow(99),
  135.   Process(C), ToText, Testwindow(81), Main_menu.
  136.  
  137. Testwindow(N):-
  138.     existwindow(N),
  139.     !,shiftwindow(N),
  140.     removewindow.
  141. Testwindow(N).
  142.  
  143. Process(1):-
  144.     linemenu(1,103,0,["Show","Lambda","Step","XStart",
  145.                          "XEnd","YStart","YEnd"],C),
  146.     !,NextProcess(C), testwindow(81). 
  147. Process(1).
  148. Process(2):- 
  149.     Initialize,
  150.     ClearDevice,
  151.     SetColor(1),                   % Set current color to white
  152.     SetBkColor(0),               % Set background to black
  153.     maxX(MaxX), 
  154.     maxY(MaxY), R = MaxY - 50, 
  155.     SetViewPort(0,0,MaxX,R,1),       % Open port to upper screen 
  156.     GetViewSettings(Left,Top,Right,Bottom,_),
  157.     Rectangle(Left,Top,Right,Bottom),  % Draw Border
  158.       Height    = Bottom-Top,
  159.     Width  = Right - Left,
  160.     params(XStart,_,XScale,YStart,_,YScale,Seed,Lambda,Inc),
  161.     function(Inc,Seed,Height,Width,XScale,YScale,Lambda,XStart,YStart),
  162.     !,readchar(_). 
  163. Process(2). 
  164. Process(3):- 
  165.     Initialize,
  166.     SetColor(1),                   % Set current color to white
  167.     SetBkColor(0),               % Set background to black
  168.     maxX(MaxX), 
  169.     maxY(MaxY), R = MaxY - 50, 
  170.     SetViewPort(0,0,MaxX,R,1),       % Open port to upper screen 
  171.     GetViewSettings(Left,Top,Right,Bottom,_),
  172.     Rectangle(Left,Top,Right,Bottom),  % Draw Border
  173.       Height    = Bottom-Top,
  174.     Width  = Right - Left,
  175.     params(XStart,XEnd,XScale,YStart,_,YScale,Seed,Lambda,I),
  176.     iterate(Seed,Lambda,Seed,I,XScale,YScale,Height,Width,YStart,XStart),
  177.     !,readchar(_).
  178. Process(3). 
  179. Process(4):- 
  180.     Initialize,
  181.     SetColor(1),                   % Set current color to white
  182.     SetBkColor(0),               % Set background to black
  183.     maxX(MaxX), 
  184.     maxY(MaxY), R = MaxY - 50, 
  185.     SetViewPort(0,0,MaxX,R,1),       % Open port to upper screen 
  186.     GetViewSettings(Left,Top,Right,Bottom,_),
  187.     Rectangle(Left,Top,Right,Bottom),  % Draw Border
  188.       Height    = Bottom-Top,
  189.     Width  = Right - Left,
  190.     params(XStart,XEnd,XScale,YStart,_,YScale,Seed,Lambda,I),
  191.     Iterate_Trace(Seed,Lambda,Seed,I,XScale,YScale,Height,Width,YStart,XStart),
  192.     !,readchar(_).
  193. Process(4). 
  194.  
  195. Process(5):-
  196.     testwindow(81),
  197.     exit(1).    
  198.       
  199. NextProcess(1):-
  200.     shiftwindow(2),
  201.     params(A,B,C,D,E,F,G,H,I),nl,
  202.     !,write("XStart : ",A),nl,
  203.     write("XEnd   : ",B),nl,
  204.     write("XScale : ",C),nl,
  205.     write("YStart : ",D),nl,
  206.     write("YEnd   : ",E),nl,
  207.     write("YScale : ",F),nl,
  208.     write("Seed   : ",G),nl,
  209.     write("Lambda : ",H),nl,
  210.     write("Step   : ",I),nl.
  211. NextProcess(1).
  212.      
  213. NextProcess(2):-
  214.     shiftwindow(2),
  215.     write("Lambda : "), readreal(Lam), 
  216.     Lam <> 0,
  217.     params(A,B,C,D,E,F,G,H,I),
  218.     !,retract(params(A,B,C,D,E,F,G,H,I)),
  219.     asserta(params(A,B,C,D,E,F,G,Lam,I)).
  220. NextProcess(2):-
  221.     shiftwindow(2),
  222.     write("Invalid Lambda = 0"). 
  223.  
  224. NextProcess(3):-
  225.     shiftwindow(2),
  226.     write("Step : "), readreal(Inc),
  227.     Inc <> 0,
  228.     params(A,B,C,D,E,F,G,H,I),
  229.     !,retract(params(A,B,C,D,E,F,G,H,I)),
  230.     asserta(params(A,B,C,D,E,F,G,H,Inc)).
  231. NextProcess(3):-
  232.     shiftwindow(2),
  233.     write("Invalid Step = 0"). 
  234.  
  235. NextProcess(4):-
  236.     shiftwindow(2),
  237.     write("XStart : "), readreal(XS),
  238.     params(A,B,C,D,E,F,G,H,I),
  239.     !,XScale = B - XS,
  240.     XScale <> 0,
  241.     retract(params(A,B,C,D,E,F,G,H,I)),
  242.     asserta(params(XS,B,XScale,D,E,F,G,H,I)).
  243. NextProcess(4):-
  244.     shiftwindow(2),
  245.     write("Invalid X Scale = 0"). 
  246.  
  247. NextProcess(5):-
  248.     shiftwindow(2),
  249.     write("XEnd : "), readreal(XE),
  250.     params(A,B,C,D,E,F,G,H,I),
  251.     !,XScale = XE - A,
  252.     XScale <> 0,
  253.     retract(params(A,B,C,D,E,F,G,H,I)),
  254.     asserta(params(A,XE,XScale,D,E,F,G,H,I)).
  255. NextProcess(5):- 
  256.     shiftwindow(2),
  257.     write("Invalid X Scale = 0"). 
  258. NextProcess(6):-
  259.     shiftwindow(2),
  260.     write("YStart : "), readreal(YS),
  261.     params(A,B,C,D,E,F,G,H,I),
  262.     !,YScale = E - YS,
  263.     YScale <> 0,
  264.     retract(params(A,B,C,D,E,F,G,H,I)),
  265.     asserta(params(A,B,C,YS,E,YScale,G,H,I)).
  266. NextProcess(6):-
  267.     shiftwindow(2),
  268.     write("Invalid Y Scale = 0"). 
  269. NextProcess(7):-
  270.     shiftwindow(2),
  271.     write("YEnd : "), readreal(YE),
  272.     params(A,B,C,D,E,F,G,H,I),
  273.     !,YScale = YE - D,
  274.     YScale <> 0,
  275.     retract(params(A,B,C,D,E,F,G,H,I)),
  276.     asserta(params(A,B,C,D,YE,YScale,G,H,I)).
  277. NextProcess(7):-
  278.     shiftwindow(2),
  279.     write("Invalid Y Scale = 0"). 
  280.  
  281. GOAL  
  282.     assert(params(0,1,1,0,1,1,0.04,3.0,0.003)),
  283.     Main.