Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %====CODE====%
- local % local 1
- MaxTime = 10 % nombre de frame à l'animation
- MyFunction
- Map
- CheckMap
- Extensions = opt(withExtendedFormula:false
- withIfThenElse:false
- withComparison:false
- withTimeWindow:false
- withCheckMapEasy:false
- withCheckMapComplete:false
- )
- in
- Map = map(ru:nil pu:primitive(kind:pokemon)|nil) %% TODO change the map here
- %Let's start by define some function that we will use during the program
- local %local 2
- fun {FlattenList L}
- case L
- of nil then nil
- [] nil|T then {FlattenList T}
- [] (H1|T1)|T then {FlattenList H1|T1|T}
- [] X|T then X | {FlattenList T}
- else L
- end
- end
- %%%%%%%%%%%%%%%%%%%%%%% Function for Real Universe %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %-----------------------------CheckValue----------------------------------------
- fun {CheckValue X }
- if {Float.is X} then X
- else
- case X of exp( W) then {Float.exp {CheckValue W} }
- [] log(W) then {Float.log {CheckValue W}}
- [] neg( W) then ~{CheckValue W }
- [] plus( W Z) then {CheckValue W} + {CheckValue Z}
- [] minus( W Z) then {CheckValue W}- {CheckValue Z}
- [] mult(W Z) then {CheckValue W}*{CheckValue Z}
- [] 'div'(W Z) then {CheckValue W}/{CheckValue Z}
- [] sin(W) then {Float.sin {CheckValue W}}
- [] cos(W) then {Float.cos {CheckValue W}}
- [] tan(W) then {Float.tan {CheckValue W}}
- [] exp(W) then {Float.exp {CheckValue W} }
- end % end of case X
- end % end of if {Float.is}
- end % end of CheckValue
- %------------------------RU-GiveMeThePointWithModification----------------
- fun{GiveMeThePointWithModifications List X Y}
- %This function return a point, and apply the modifications include in the List.
- case List of
- nil then pt(x:X y:Y)
- [] H|T then
- case H of
- transfo(1:Dx 2:Dy) then {GiveMeThePointWithModifications T {CheckValue plus(X Dx)} {CheckValue plus(Y Dy)}}% For a tranformation
- []scale(1:Rx 2:Ry) then {GiveMeThePointWithModifications T {CheckValue mult(X Rx)} {CheckValue mult(Y Ry)}}%For a scale
- []rot(1:A) then local C D in
- C= {CheckValue plus(mult(X cos(A)) mult(Y sin(A)))}
- D = {CheckValue minus(mult(Y cos(A)) mult(X sin(A)))}
- {GiveMeThePointWithModifications T C D} % For a rotate
- end%of local C D
- end%of case H
- end%of case List
- end% of {GiveMeThePointWithModifications List X Y}
- %--------------------------------------------------------------------------------
- %-------------------------------------------------------------------------------
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%% Function for Poke Universe %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %----------------------------CheckFormula---------------------------------------
- fun{CheckFormula Time X}
- if {Float.is X} then X
- else
- case X of
- time then Time % check
- [] plus( W Z) then {CheckFormula Time W}+ {CheckFormula Time Z} % ok
- [] minus( W Z) then {CheckFormula Time W}- {CheckFormula Time Z} % ok
- [] mult(W Z) then {CheckFormula Time W}*{CheckFormula Time Z} %ok
- [] 'div'(W Z) then {CheckFormula Time W}/{CheckFormula Time Z}%ok
- [] sin(W) then {Float.sin {CheckFormula Time W}}% ok
- [] cos(W) then {Float.cos {CheckFormula Time W}}%ok
- [] tan(W) then {Float.tan {CheckFormula Time W}}
- [] exp( W) then {Float.exp {CheckFormula Time W} }
- [] log( W ) then {Float.log {CheckFormula Time W}}%ok
- [] neg( W) then ~{CheckFormula Time W }
- [] ite(W Y Z)then if {CheckFormula Time W} == 0.0 then {CheckFormula Time Z}
- else {CheckFormula Time Y}
- end % end of if in the ite condition
- [] eq(W Z) then if {CheckFormula Time W} == {CheckFormula Time Z} then 0.0
- else 1.0
- end % end of if in the eq condition
- [] ne(W Z) then if {CheckFormula Time W} \= {CheckFormula Time Z} then 0.0
- else 1.0
- end % end of if in the ne coondition
- [] lt(W Z) then if {CheckFormula Time W} < {CheckFormula Time Z} then 0.0
- else 1.0
- end %end of if in the lt condition
- [] le(W Z) then if {CheckFormula Time W} =< {CheckFormula Time Z} then 0.0
- else 1.0
- end % end of if in the le condition
- [] gt(W Z) then if {CheckFormula Time W} > {CheckFormula Time Z} then 0.0
- else 1.0
- end % end of if in the gt condition
- [] ge(W Z) then if {CheckFormula Time W} >= {CheckFormula Time Z} then 0.0
- else 1.0
- end % end of if in the ge condition
- else nil %! A changer pour qu'il lance une erreur!
- end % end of case X
- end % end of if {Float.is X} then X
- end % end of CheckFormula
- %-------------------------------------------------------------------------------
- fun {DoTranslatePu Dx Dy List}
- case List of nil then nil
- []H|T then case H of primitive(kind:PokeUniversePOI) then fun {$ Time}
- pokeitem(kind:PokeUniversePOI position:pt(x:Dx y:Dy))
- end % end of fun {$ Time}
- |{DoTranslatePu Dx Dy T}
- []translate(dx:X dy:Y 1:PokeUniverse) then {DoTranslatePu {CheckFormula Time (plus(X Dx))}
- {CheckFormula Time (plus(Y Dy))} PokeUniverse}
- |{DoTranslatePu Dx Dy T}
- end % end of case H
- end % end of case List
- end % end of fun {DoTranslate Pu Dx Dy List}
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- fun {DoPu List}
- case List of nil then nil
- []H|T then case H of primitive(kind:PokeUniversePOI) then fun {$ Time }
- pokeitem(kind:PokeUniversePOI position:pt(x:0.0 y:0.0))
- end % end of fun {$ Time}
- | {DoPu T}
- []translate(dx:Dx dy:Dy 1:PokeUniverse) then {DoTranslatePu {CheckFormula Time Dx} {CheckFormula Time Dy} PokeUniverse}
- |{DoPu T}
- end % end of case H
- end % end of case List
- end % end of fun {DoPu List}
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- in
- {Browse {DoPu Map.pu} }
- end % end of fun{MyFunction Map}
- fun{CheckMap Map}
- false %% TODO complete here the function for the checking of the maps
- end
- {Projet.run MyFunction Map MaxTime Extensions CheckMap}
- end % end of local 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement