Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 6.31 KB | None | 0 0
  1. %====CODE====%
  2. local % local 1
  3.  
  4.    MaxTime = 10 % nombre de frame à l'animation
  5.    MyFunction
  6.    Map
  7.    CheckMap
  8.    Extensions = opt(withExtendedFormula:false
  9.             withIfThenElse:false
  10.             withComparison:false
  11.             withTimeWindow:false
  12.             withCheckMapEasy:false
  13.             withCheckMapComplete:false
  14.            )
  15. in
  16.    Map = map(ru:nil pu:primitive(kind:pokemon)|nil) %% TODO change the map here
  17.  
  18.  
  19. %Let's start by define some function that we will use during the program
  20.  
  21.    local %local 2
  22.  
  23.       fun {FlattenList L}
  24.      case L
  25.      of nil then nil
  26.      [] nil|T then {FlattenList T}
  27.      [] (H1|T1)|T then {FlattenList H1|T1|T}
  28.      [] X|T then X | {FlattenList T}
  29.      else L
  30.      end
  31.  
  32.       end
  33.  
  34. %%%%%%%%%%%%%%%%%%%%%%% Function for Real Universe %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. %-----------------------------CheckValue----------------------------------------
  36.       fun {CheckValue X }
  37.      if {Float.is X} then X
  38.      else
  39.         case X of exp( W) then {Float.exp {CheckValue W} }
  40.         [] log(W) then {Float.log {CheckValue W}}
  41.         [] neg( W) then ~{CheckValue W }
  42.         [] plus( W Z)  then {CheckValue W} + {CheckValue Z}
  43.         [] minus( W Z)  then {CheckValue W}- {CheckValue Z}
  44.         [] mult(W Z) then {CheckValue W}*{CheckValue Z}
  45.         [] 'div'(W Z) then {CheckValue W}/{CheckValue Z}
  46.         [] sin(W) then {Float.sin {CheckValue W}}
  47.         [] cos(W) then {Float.cos {CheckValue W}}
  48.         [] tan(W) then {Float.tan {CheckValue W}}
  49.         [] exp(W) then {Float.exp {CheckValue W} }
  50.         end % end of case X
  51.      end % end of if {Float.is}
  52.       end % end of CheckValue
  53.  
  54. %------------------------RU-GiveMeThePointWithModification----------------
  55.       fun{GiveMeThePointWithModifications List X Y}
  56.    %This function return a point, and apply the modifications include in the List.
  57.  
  58.      case List of
  59.         nil then pt(x:X y:Y)
  60.      [] H|T then
  61.         case H of
  62.            transfo(1:Dx 2:Dy) then {GiveMeThePointWithModifications T {CheckValue plus(X Dx)} {CheckValue plus(Y Dy)}}% For a tranformation
  63.         []scale(1:Rx 2:Ry) then {GiveMeThePointWithModifications T {CheckValue mult(X Rx)} {CheckValue mult(Y Ry)}}%For a scale
  64.         []rot(1:A) then local C D in
  65.                    C= {CheckValue plus(mult(X cos(A)) mult(Y sin(A)))}
  66.  
  67.                    D = {CheckValue minus(mult(Y cos(A)) mult(X sin(A)))}
  68.                    {GiveMeThePointWithModifications T C D} % For a rotate
  69.                 end%of local  C D
  70.         end%of case H
  71.  
  72.      end%of case List
  73.       end% of {GiveMeThePointWithModifications List X Y}
  74. %--------------------------------------------------------------------------------
  75.  
  76.  
  77. %-------------------------------------------------------------------------------
  78. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  79. %%%%%%%%%%%%%%%%%%%%%%% Function for Poke Universe %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80.  
  81. %----------------------------CheckFormula---------------------------------------
  82.       fun{CheckFormula Time  X}
  83.  
  84.      if {Float.is X} then X
  85.      else
  86.         case X of
  87.            time then Time % check
  88.         [] plus( W Z)  then {CheckFormula Time  W}+ {CheckFormula Time Z} % ok
  89.         [] minus( W Z)  then {CheckFormula Time  W}- {CheckFormula Time Z} % ok
  90.         [] mult(W Z) then {CheckFormula Time W}*{CheckFormula Time Z} %ok
  91.         [] 'div'(W Z) then {CheckFormula Time W}/{CheckFormula Time Z}%ok
  92.         [] sin(W) then {Float.sin {CheckFormula Time  W}}% ok
  93.         [] cos(W) then {Float.cos {CheckFormula Time W}}%ok
  94.         [] tan(W) then {Float.tan {CheckFormula Time W}}
  95.         [] exp( W) then {Float.exp {CheckFormula Time  W} }
  96.         [] log( W ) then {Float.log {CheckFormula Time  W}}%ok
  97.         [] neg( W) then ~{CheckFormula Time  W }
  98.  
  99.         [] ite(W Y Z)then if {CheckFormula Time  W} == 0.0 then {CheckFormula Time Z}
  100.                   else {CheckFormula  Time   Y}
  101.                   end % end of if in the ite condition
  102.         [] eq(W Z) then if {CheckFormula  Time  W} == {CheckFormula  Time  Z} then 0.0
  103.                 else 1.0
  104.                 end  % end of if in the eq condition
  105.         [] ne(W Z) then if  {CheckFormula  Time   W} \= {CheckFormula  Time   Z} then 0.0
  106.                 else 1.0
  107.                 end % end of if in the ne coondition
  108.  
  109.         [] lt(W Z) then if {CheckFormula  Time   W} < {CheckFormula  Time   Z} then 0.0
  110.                 else 1.0
  111.                 end %end of if in the lt condition
  112.         [] le(W Z) then if {CheckFormula  Time   W} =< {CheckFormula  Time   Z} then 0.0
  113.                 else 1.0
  114.                 end % end of if in the le condition
  115.         [] gt(W Z) then if {CheckFormula  Time   W} > {CheckFormula  Time   Z} then 0.0
  116.                 else 1.0
  117.                 end % end of if in the gt condition
  118.         [] ge(W Z) then if {CheckFormula  Time   W} >= {CheckFormula  Time   Z} then 0.0
  119.                 else 1.0
  120.                 end % end of if in the ge condition
  121.         else nil %! A changer pour qu'il lance une erreur!
  122.         end % end of case X
  123.      end % end of if {Float.is X} then X
  124.       end % end of CheckFormula
  125.  
  126. %-------------------------------------------------------------------------------
  127.  
  128.  
  129.       fun {DoTranslatePu Dx Dy List}
  130.  
  131.      case List of nil then nil
  132.      []H|T then case H of primitive(kind:PokeUniversePOI)  then fun {$ Time}
  133.                                        pokeitem(kind:PokeUniversePOI position:pt(x:Dx y:Dy))
  134.                                     end % end of fun {$ Time}
  135.                |{DoTranslatePu Dx Dy T}
  136.  
  137.             []translate(dx:X dy:Y 1:PokeUniverse) then {DoTranslatePu {CheckFormula Time (plus(X Dx))}
  138.                                 {CheckFormula Time (plus(Y Dy))} PokeUniverse}
  139.                |{DoTranslatePu Dx Dy T}
  140.             end % end of case H
  141.      end % end of case List
  142.  
  143.  
  144.       end % end of fun {DoTranslate Pu Dx Dy List}
  145.  
  146. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  147.  
  148.       fun {DoPu List}
  149.  
  150.      case List of nil then nil
  151.      []H|T then case H of primitive(kind:PokeUniversePOI) then fun {$ Time }
  152.                                      pokeitem(kind:PokeUniversePOI position:pt(x:0.0 y:0.0))
  153.                                   end % end of fun {$ Time}
  154.                | {DoPu T}
  155.  
  156.             []translate(dx:Dx dy:Dy 1:PokeUniverse) then {DoTranslatePu {CheckFormula Time Dx} {CheckFormula Time Dy} PokeUniverse}
  157.                |{DoPu T}
  158.  
  159.  
  160.             end % end of case H
  161.  
  162.      end % end of case List
  163.  
  164.       end % end of fun {DoPu List}
  165.  
  166. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  167.    in
  168.  
  169.       {Browse {DoPu Map.pu} }
  170.      
  171.  
  172.    end % end of fun{MyFunction Map}
  173.  
  174.    fun{CheckMap Map}
  175.       false %% TODO complete here the function for the checking of the maps
  176.    end
  177.  
  178.    {Projet.run MyFunction Map MaxTime Extensions CheckMap}
  179. end % end of local 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement