Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 20.89 KB | None | 0 0
  1. %====INFORMATION====%
  2. % LFSAB1402 Projet 2016
  3. % Nomas : 07891500-38421500
  4. % Noms : (Tascon Gutierrez,Luis)-(Mawait,Maxime)
  5. %====MODULELINK====%
  6. declare
  7. [Projet]={Module.link ["Projet2016.ozf"]}
  8.  
  9. %====CODE====%
  10. local
  11.    MaxTime = 25        % nombre de frame a l'animation
  12.    MyFunction          % fonction principale
  13.    Primitive
  14.    FlattenList
  15.    AppendList
  16.    Value
  17.    PokeSearch
  18.    PokeBuild
  19.    Translate
  20.    PokeTranslate
  21.    Scale
  22.    Rotate
  23.    Map                 % map principale
  24.    Spawn
  25.    CheckMap
  26.    Extensions = opt(withExtendedFormula:true
  27.             withIfThenElse:true
  28.             withComparison:true
  29.             withTimeWindow:true
  30.             withCheckMapEasy:true
  31.             withCheckMapComplete:true) %toutes les extensions sont implementees.
  32.    Building = primitive(kind:building)
  33.    B = scale(rx:10.0 ry:10.0 [Building])
  34.  
  35.    fun{A Acc Max}
  36.       if Acc < Max then translate(dx:mult(sin(Acc) Acc) dy:mult(cos(Acc) Acc) [B])|{A Acc+1.0 Max}
  37.       else nil
  38.       end
  39.    end
  40.    
  41.    Ru = [translate(dx:250.0 dy:250.0 {A 0.0 400.0})] %Monde reel
  42.    Pu = [translate(dx: 250.0 dy: 250.0 1:[translate(dx:mult(sin(time) mult(5.0 time)) dy:mult(cos(time) mult(5.0 time)) [spawn(tmin:3 tmax:MaxTime [primitive(kind:pokemon)])])]) translate(dx: 300.0 dy: 100.0 [primitive(kind:pokestop)]) translate(dx:100.0 dy:300.0 1:[primitive(kind:arena)])] %Monde pokemon
  43. in
  44.    Map = map(ru:Ru pu:Pu) %Map envoyee
  45.  
  46.    fun{MyFunction Map}
  47.       %Fait plusieurs appels de fonctions imbriquees afin de retourner une liste de fonctions anonymes en fonction de Map recu.
  48.       case Map of map(ru: Ru pu: Pu) then
  49.      {AppendList {Build {Search {FlattenList Ru}}} {PokeBuild  {PokeSearch {FlattenList Pu}}}}
  50.       end
  51.    end
  52.  
  53.    
  54.    fun{Primitive K}
  55.       %C'est la fonction qui recois une string en argument et qui retourne un realitem ou un pokeitem en fonction de K.
  56.       case K of road then
  57.      realitem(kind: road p1: pt(x: 0.0 y: 0.0) p2: pt(x: 1.0 y: 0.0))
  58.       [] building then
  59.      realitem(kind: building p1: pt(x: 0.0 y: 0.0) p2: pt(x: 0.0 y: 1.0) p3: pt(x: 1.0 y: 1.0) p4: pt(x: 1.0 y: 0.0))
  60.       [] water then
  61.      realitem(kind: water p1: pt(x: 0.0 y: 0.0) p2: pt(x: 0.0 y: 1.0) p3: pt(x: 1.0 y: 1.0) p4: pt(x: 1.0 y: 0.0))
  62.       [] pokemon then
  63.      pokeitem(kind: pokemon position: pt(x: 0.0 y: 0.0))
  64.       [] pokestop then
  65.      pokeitem(kind: pokestop position: pt(x: 0.0 y: 0.0))
  66.       [] arena then
  67.      pokeitem(kind: arena position: pt(x: 0.0 y: 0.0))
  68.       end
  69.    end
  70.  
  71.  
  72.    fun{Translate D1 D2 L1}
  73.       %Cette fonction applique une translation a un pokeitem ou un realitem de D1 dans l'axe des x et de D2 dans l'axe des y.
  74.       %D'abord, on applique FlattenList sur L1 afin d'etre sur qu'on ai une liste simple et pas une liste de listes.
  75.       %Ensuite, on regarde le premier element de L1 et on applique une recursion sur le reste de la liste.
  76.       Dx = {Value D1}
  77.       Dy = {Value D2}
  78.       L = {FlattenList L1}
  79.    in
  80.       case L of nil then nil
  81.       [] H|T then
  82.      %Apres avoir fait le pattern matching, nous observons plusieurs cas:
  83.      case H
  84.      of primitive(kind:K) then %Si on a une primitive, on rappelle la fonction avec comme nouvel argument pour la liste l'item que va nous retourner {Primitive K}
  85.         {Translate D1 D2 [{Primitive K}]}|{Translate D1 D2 T}
  86.      [] realitem(kind:K p1: pt(x:X1 y:Y1) p2: pt(x:X2 y:Y2)) then %Si c'est un realitem a deux points (road) on applique la translation sur les 2points.
  87.         realitem(kind:K p1: pt(x:X1+Dx y:Y1+Dy) p2: pt(x:X2+Dx y:Y2+Dy))|{Translate D1 D2 T}
  88.      [] realitem(kind:K p1: pt(x:X1 y:Y1) p2: pt(x:X2 y:Y2) p3: pt(x:X3 y:Y3) p4: pt(x:X4 y:Y4)) then %Si c'est un realitem a 4 points (water & building), on applique la translation sur les 4 points.
  89.         realitem(kind:K p1: pt(x:X1+Dx y:Y1+Dy) p2: pt(x:X2+Dx y:Y2+Dy) p3: pt(x:X3+Dx y:Y3+Dy) p4: pt(x:X4+Dx y:Y4+Dy))|{Translate D1 D2 T}
  90.      [] translate(dx:A dy:B 1:Ru) then %Si on a deux translates imbriques, on appelle {Translate} dans {Translate} car on ne peut pas appliquer une translation sur un autre tuple que realitem.
  91.         {Translate D1 D2 {Translate A B Ru}}|{Translate D1 D2 T}
  92.      [] scale(rx:A ry:B 1:Ru) then %Si on a scale, on appelle {Scale} dans le {Translate}.
  93.         {Translate D1 D2 {Scale A B Ru}}|{Translate D1 D2 T}
  94.      [] rotate(angle:A 1:Ru) then %Si on a rotate, on appelle {Rotate} dans le {Translate}.
  95.         {Translate D1 D2 {Rotate A Ru}}|{Translate D1 D2 T}
  96.      end
  97.       end
  98.    end
  99.  
  100.    fun{Scale R1 R2 L1}
  101.       %Cette fonction applique un redimensionnement a un pokeitem ou un realitem de R1 dans l'axe des x et de R2 dans l'axe des y.
  102.       %D'abord, on applique FlattenList sur L1 afin d'etre sur qu'on ai une liste simple et pas une liste de listes.
  103.       %Ensuite, on regarde le premier element de L1 et on applique une recursion sur le reste de la liste.
  104.       Rx = {Value R1}
  105.       Ry = {Value R2}
  106.       L = {FlattenList L1}
  107.    in
  108.       case L of nil then nil
  109.       [] H|T then
  110.      case H of primitive(kind:K) then %Si on a une primitive, on appelle la fonction {Primitive} en recursion avec Scale afin de recevoir un realitem.
  111.         {Scale Rx Ry [{Primitive K}]}|{Scale R1 R2 T}
  112.      [] realitem(kind:K p1: pt(x:X1 y:Y1) p2: pt(x:X2 y:Y2)) then %Si on a un realitem a 2 points (road), on applique le dimensionnement aux 2 points.
  113.         realitem(kind:K p1: pt(x:X1*Rx y:Y1*Ry) p2: pt(x:X2*Rx y:Y2*Ry))|{Scale R1 R2 T}
  114.      [] realitem(kind:K p1: pt(x:X1 y:Y1) p2: pt(x:X2 y:Y2) p3: pt(x:X3 y:Y3) p4: pt(x:X4 y:Y4)) then %Si on a un realitem a 4 points (water & building), on applique le dimensionnement aux 4 points.
  115.         realitem(kind:K p1: pt(x:X1*Rx y:Y1*Ry) p2: pt(x:X2*Rx y:Y2*Ry) p3: pt(x:X3*Rx y:Y3*Ry) p4: pt(x:X4*Rx y:Y4*Ry))|{Scale R1 R2 T}
  116.      [] translate(dx: A dy: B 1:Ru) then %Si on a translate, on appelle {Transtlate} dans le {Scale}.
  117.         {Scale R1 R2 {Translate A B Ru}}|{Scale R1 R2 T}
  118.      [] scale(rx: A ry: B 1: Ru) then %Si on a deux scales imbriques, on appelle {Scale} dans {Scale} car on ne peut pas appliquer un dimensionnement sur un autre tuple que realitem.
  119.         {Scale R1 R2 {Scale A B Ru}}|{Scale R1 R2 T}
  120.      [] rotate(angle: A 1:Ru) then %Si on a rotate, on appelle {Rotate} dans le {Scale}.
  121.         {Scale R1 R2 {Rotate A Ru}}|{Scale R1 R2 T}
  122.      end
  123.       end
  124.    end
  125.  
  126.  
  127.    fun{Rotate A1 Ru1}
  128.       %Cette fonction applique une rotation a un pokeitem ou un realitem d'un angle qui vaut A1 en radian autour de (0;0).
  129.       %D'abord, on applique FlattenList sur L1 afin d'etre sur qu'on ai une liste simple et pas une liste de listes.
  130.       %Ensuite, on regarde le premier element de L1 et on applique une recursion sur le reste de la liste.
  131.       A = {Value A1}
  132.       Ru = {FlattenList Ru1}
  133.    in
  134.       case Ru of nil then nil
  135.       [] H|T then
  136.      case H of primitive(kind:K) then %Si on a une primitive, on appelle la fonction {Primitive} en recursion avec Rotate afin de recevoir un realitem.
  137.         {Rotate A [{Primitive K}]}|{Rotate A T}
  138.      [] translate(dx: Dx dy: Dy 1: L) then %Si on a translate, on appelle {Translate} dans le {Rotate}.
  139.         {Rotate A {Translate Dx Dy L}}|{Rotate A T}
  140.      [] rotate(angle: A2 1: L) then %Si on a deux rotates imbriques, on appelle {Rotate} dans {Rotate} car on ne peut pas appliquer un dimensionnement sur un autre tuple que realitem.
  141.         {Rotate A {Rotate A2 L}}|{Rotate A T}
  142.      [] scale(rx: Rx ry: Ry 1: L) then %Si on a Scale, on appelle {Scale} dans le {Rotate}.
  143.         {Rotate A {Scale Rx Ry L}}|{Rotate A T}
  144.      [] realitem(kind:K p1: pt(x:X1 y:Y1) p2: pt(x:X2 y:Y2)) then %Si on a un realitem a 2 points (road), on applique la rotation aux 2 points.
  145.         realitem(kind:K p1: pt(x: {Value plus(mult(X1 cos(A)) mult(Y1 sin(A)))} y: {Value plus(mult(neg(X1) sin(A)) mult(Y1 cos(A)))}) p2: pt(x: {Value plus(mult(X2 cos(A)) mult(Y2 sin(A)))} y: {Value plus(mult(neg(X2) sin(A)) mult(Y2 cos(A)))}))|{Rotate A T}
  146.      [] realitem(kind:K p1: pt(x:X1 y:Y1) p2: pt(x:X2 y:Y2) p3: pt(x:X3 y:Y3) p4: pt(x:X4 y:Y4)) then %Si on a un realitem a 4 points (water & building), on applique la rotation aux 4 points.
  147.         realitem(kind:K p1: pt(x: {Value plus(mult(X1 cos(A)) mult(Y1 sin(A)))} y: {Value plus(mult(neg(X1) sin(A)) mult(Y1 cos(A)))}) p2: pt(x: {Value plus(mult(X2 cos(A)) mult(Y2 sin(A)))} y: {Value plus(mult(neg(X2) sin(A)) mult(Y2 cos(A)))}) p3: pt(x: {Value plus(mult(X3 cos(A)) mult(Y3 sin(A)))} y: {Value plus(mult(neg(X3) sin(A)) mult(Y3 cos(A)))}) p4: pt(x: {Value plus(mult(X4 cos(A)) mult(Y4 sin(A)))} y: {Value plus(mult(neg(X4) sin(A)) mult(Y4 cos(A)))}))|{Rotate A T}
  148.      end
  149.       end
  150.    end
  151.  
  152.    fun{PokeTranslate Dx Dy L1}
  153.       %Cette fonction a le meme principe que Translate a l'exception de la transformation appliquee au point.
  154.       %Pour faire des transformations, a la place de faire directement les plus, on cree des tuples du type plus(A B).
  155.       %Ce tuple va rester la jusqu'a ce qu'on emballe l'item dans une fonction anonyme, a ce moment la, on va evaluer le tuple avec {Formula A Time}.
  156.       %De plus, on applique FlattenList sur L1 afin d'etre sur qu'on ai une liste simple et pas une liste de listes.
  157.       L = {FlattenList L1}
  158.    in
  159.       case L of nil then nil
  160.       [] H|T then
  161.      case H of primitive(kind: K) then%Si on a une primitive, on appelle la fonction {Primitive} en recursion avec PokeTranslate afin de recevoir un realitem.
  162.         {PokeTranslate Dx Dy [{Primitive K}]}|{PokeTranslate Dx Dy T}
  163.      [] pokeitem(kind: K position: pt(x: X y: Y)) then %Si on a un pokeitem, on met un tuple plus dans chacune des coordonnees du point indiquant le pokeitem.
  164.         pokeitem(kind: K position: pt(x: plus(X Dx) y: plus(Y Dy)))|{PokeTranslate Dx Dy T}
  165.      [] translate(dx: D1 dy: D2 1:Pu) then %Si on a translate, on appelle {PokeTranslate} en recursion avec {PokeTranslate}.
  166.         {PokeTranslate Dx Dy {PokeTranslate D1 D2 Pu}}|{PokeTranslate Dx Dy T}
  167.      [] spawn(tmin:Tmin tmax:Tmax Pu) then %Si on a Spawn, on appelle {PokeTranslate} dans le {Spawn}.
  168.         {Spawn Tmin Tmax  {PokeTranslate Dx Dy Pu}}|{PokeTranslate Dx Dy T}
  169.      end
  170.       end
  171.    end
  172.  
  173.    fun{Spawn Tmin Tmax L1}
  174.       %Cette fonction renvoie une liste de tuple spawn.
  175.       %Le tuple spawn est ensuite utilise une fois que l'emballage du tuple se fera dans {PokeBuild}.
  176.       %Ce tuple contient Tmin Tmax et le pokeitem a afficher.
  177.       %De plus, on applique FlattenList sur L1 afin d'etre sur qu'on ai une liste simple et pas une liste de listes.
  178.       L = {FlattenList L1}
  179.    in
  180.       case L
  181.       of H|T then
  182.      case H
  183.      of primitive(kind: K) then %Si on a une primitive, on rappelle {Spawn} avec  {Primitive} a l'interieur pour avoir un pokeitem a l'appel recursif
  184.         {Spawn Tmin Tmax [{Primitive K}]}|{Spawn Tmin Tmax T}
  185.      [] pokeitem(kind: K position: pt(x: X y: Y)) then %Si on a un pokeitem, on emballe le pokeitem dans le tuple spawn (+ appel recursif toujours).
  186.         spawn(tmin:Tmin tmax:Tmax 1:[pokeitem(kind: K position: pt(x:X y:Y))])|{Spawn Tmin Tmax T}
  187.      [] translate(dx: D1 dy: D2 1:Pu) then %Si on a translate, on emballe dans un tuple spawn mais on emballe une fonction qui retournera un pokeitem cad {PokeTranslate}.
  188.         spawn(tmin:Tmin tmax:Tmax 1:{PokeTranslate D1 D2 Pu})|{Spawn Tmin Tmax T}
  189.      [] spawn(tmin:A tmax:B 1:Pu) then %Si on a spawn, on appelle {Spawn} dans le tuple spawn.
  190.         spawn(tmin:Tmin tmax:Tmax 1:{Spawn A B Pu})|{Spawn Tmin Tmax T}
  191.      end
  192.       [] nil then nil
  193.       end
  194.    end
  195.  
  196.    fun{PokeSearch Pu}
  197.       %Cette fonction prends un PokeUniverse en argument et retourne une liste de pokeitem ou de spawn.
  198.       case Pu of nil then nil
  199.       [] H|T then
  200.      case H of primitive(kind: K) then %Si on a primitive, on appelle la fonction {Primitive} (+ recursion).
  201.         {Primitive K}|{PokeSearch T}
  202.      [] translate(dx: Dx dy: Dy 1: Pu2) then %Si on a translate, on appelle la fonction {PokeTranslate} (+ recursion).
  203.         {FlattenList {PokeTranslate Dx Dy Pu2}|{PokeSearch T}}
  204.      [] spawn(tmin:Tmin tmax:Tmax 1:Pu2) then %Si on a spawn, on appelle la fonction {Spawn} (+ recursion).
  205.         {FlattenList {Spawn Tmin Tmax Pu2}|{PokeSearch T}}
  206.      end
  207.       end
  208.    end
  209.  
  210.    fun{PokeBuild Pu1}
  211.       %Cette fonction retourne une liste de fonctions anonymes qui emballent un pokeitem.
  212.       %On utilise d'abord Flatten afin d'avoir un liste simple a parcourir.
  213.       Pu = {FlattenList Pu1}
  214.    in
  215.       case Pu of nil then nil
  216.       [] H|T then
  217.      case H of pokeitem(kind: K position: pt(x:X y:Y)) then %si on a un pokeitem, on ne fait qu'emballer le pokeitem dans la fonction et un appel recursif.
  218.         fun{$ Time}pokeitem(kind: K position: pt(x:{Formula X Time} y:{Formula Y Time}))end|{PokeBuild T}
  219.      [] spawn(tmin:Tmin tmax:Tmax 1:B) then %Si on a spawn, on doit retourner une fonction avec un if- then- else- end a l'interieur. Car en fonction du temps recu en argument, la fonction doit soit retourner le pokeitem a l'interieur de spawn (si conditions OK) soit empty (si conditions KO).
  220.         local X = {PokeBuild B} in
  221.            fun{$ Time}if({Float.toInt Time} >= Tmin andthen {Float.toInt Time} < Tmax)then {X.1 Time} else empty end end|{PokeBuild T}
  222.         end
  223.      [] nil then nil
  224.      end
  225.       end
  226.    end
  227.    
  228.    fun{Search Ru}
  229.       %Cette fonction prends un RealUniverse en argument et retourne une liste de realitem.
  230.       case Ru of nil then nil
  231.       [] H|T then
  232.      case H
  233.      of primitive(kind:K) then {Primitive K}|{Search T} %si primitive, appel de {Primitive} (+ appel recursif).
  234.      [] translate(dx:Dx dy:Dy 1:Ru2) then %si translate, appel de {Translate} (+ appel recursif).
  235.         {Translate Dx Dy Ru2}|{Search T}
  236.      [] rotate(angle:Angle 1:Ru2) then %si rotate, appel de {Rotate} (+ appel recursif).
  237.         {Rotate Angle Ru2}|{Search T}
  238.      [] scale(rx: Rx ry: Ry 1:Ru2) then %si scale, appel de {Scale} (+ appel recursif).
  239.         {Scale Rx Ry Ru2}|{Search T}
  240.      end
  241.       end
  242.    end
  243.  
  244.    fun{Build L1}
  245.       %Cette fonction retourne une liste de fonctions anonymes qui emballent un realitem.
  246.       %On utilise d'abord Flatten afin d'avoir un liste simple a parcourir.
  247.       L = {FlattenList L1}
  248.    in
  249.       case L of H|T then %On emballe le realitem dans une fonction anonyme qui prends Time en argument.
  250.      fun{$ Time} H end|{Build T}
  251.       else nil
  252.       end
  253.    end
  254.  
  255.    fun{Value V}
  256.       %Cette fonction va evaluer les tuples des realitems. Si on a un float, on renvoie le float, si c'est un tuple, on va appliquer l'operation et retourner un float.
  257.       if {Float.is V} then V
  258.       else case V
  259.        of plus(1:A 2:B) then {Value A} + {Value B}
  260.        [] minus(1:A 2:B) then {Value A} - {Value B}
  261.        [] mult(1:A 2:B) then {Value A} * {Value B}
  262.        [] 'div'(1:A 2:B) then {Value A} / {Value B}
  263.        [] cos(1:A) then {Float.cos {Value A}}
  264.        [] sin(1:A) then {Float.sin {Value A}}
  265.        [] tan(1:A) then {Float.tan {Value A}}
  266.        [] exp(1:A) then {Float.exp {Value A}}
  267.        [] log(1:A) then {Float.log {Value A}}
  268.        [] neg(1:A) then ~{Value A}
  269.        end
  270.       end
  271.    end
  272.  
  273.    fun{Formula F Time}
  274.       %Cette fonction part du meme principe que {Value V} mais en plus, elle prends Time en argument et peut s'en servir pour calculer.
  275.       if {Float.is F} then F
  276.       else
  277.      case F
  278.      of time then Time
  279.      [] plus(1:A 2:B) then {Formula A Time} + {Formula B Time}
  280.      [] minus(1:A 2:B) then {Formula A Time} - {Formula B Time}
  281.      [] mult(1:A 2:B) then {Formula A Time} * {Formula B Time}
  282.      [] 'div'(1:A 2:B) then {Formula A Time} / {Formula B Time}
  283.      [] cos(1:A) then {Float.cos {Formula A Time}}
  284.      [] sin(1:A) then {Float.sin {Formula A Time}}
  285.      [] tan(1:A) then {Float.tan {Formula A Time}}
  286.      [] exp(1:A) then {Float.exp {Formula A Time}}
  287.      [] log(1:A) then {Float.log {Formula A Time}}
  288.      [] neg(1:A) then ~{Formula A Time}
  289.      [] ite(1:A 2:B 3:C) then if {Formula A Time} == 0.0 then {Formula C Time} else {Formula B Time} end
  290.      [] eq(1:A 2:B) then if {Formula A Time} == {Formula B Time} then 1.0 else 0.0 end
  291.      [] ne(1:A 2:B) then if {Formula A Time} \= {Formula B Time} then 1.0 else 0.0 end
  292.      [] lt(1:A 2:B) then if {Formula A Time} < {Formula B Time} then 1.0 else 0.0 end
  293.      [] le(1:A 2:B) then if {Formula A Time} =< {Formula B Time} then 1.0 else 0.0 end
  294.      [] gt(1:A 2:B) then if {Formula A Time} > {Formula B Time} then 1.0 else 0.0 end
  295.      [] ge(1:A 2:B) then if {Formula A Time} >= {Formula B Time} then 1.0 else 0.0 end
  296.      end
  297.       end
  298.    end
  299.  
  300.    fun{AppendList X Y}
  301.       %Cette fonction joint les listes X et Y
  302.       case X of nil then Y
  303.       [] H|T then H|{AppendList T Y}
  304.       end
  305.    end
  306.  
  307.  
  308.    fun{FlattenList X}
  309.       %Cette fonction retourne une liste simple et prends en argument X qui peut etre une liste composee de listes.
  310.       fun{IsList L}
  311.      case L of nil then true
  312.      [] H|T then true
  313.      else false
  314.      end
  315.       end
  316.    in
  317.       case X of nil then nil
  318.       [] H|T then
  319.      if {IsList H} then {AppendList {FlattenList H}{FlattenList T}}
  320.      else H|{FlattenList T}
  321.      end
  322.       end
  323.    end
  324.  
  325.  
  326.    fun{CheckMap Map}
  327.       %Verifie que notre Map est correcte, revoie true si c'est le cas, false autrement.
  328.       fun{CheckVal Val}%Verifie que Value est correct, si oui, true, sinon, false.
  329.      if {Float.is Val} then true
  330.      else
  331.         case Val
  332.         of plus(A B) then ({CheckVal A} andthen {CheckVal B})
  333.         [] minus(A B) then ({CheckVal A} andthen {CheckVal B})
  334.         [] mult(A B) then ({CheckVal A} andthen {CheckVal B})
  335.         [] 'div'(A B) then ({CheckVal A} andthen {CheckVal B})
  336.         [] cos(A) then {CheckVal A}
  337.         [] sin(A) then {CheckVal A}
  338.         [] tan(A) then {CheckVal A}
  339.         [] exp(A) then {CheckVal A}
  340.         [] log(A) then {CheckVal A}
  341.         [] neg(A) then {CheckVal A}
  342.         else false
  343.         end
  344.      end
  345.       end
  346.       fun{CheckForm Form}%Verifie que Formula est correct, si oui, true, sinon, false.
  347.      if {Float.is Form} then true
  348.      else
  349.         case Form
  350.         of plus(A B) then ({CheckForm A} andthen {CheckForm B})
  351.         [] time then true
  352.         [] minus(A B) then ({CheckForm A} andthen {CheckForm B})
  353.         [] mult(A B) then ({CheckForm A} andthen {CheckForm B})
  354.         [] 'div'(A B) then ({CheckForm A} andthen {CheckForm B})
  355.         [] cos(A) then {CheckForm A}
  356.         [] sin(A) then {CheckForm A}
  357.         [] tan(A) then {CheckForm A}
  358.         [] exp(A) then {CheckForm A}
  359.         [] log(A) then {CheckForm A}
  360.         [] neg(A) then {CheckForm A}
  361.         [] ite(A B C) then ({CheckForm A} andthen {CheckForm B} andthen {CheckForm C})
  362.         [] eq(A B) then ({CheckForm A} andthen {CheckForm B})
  363.         [] ne(A B) then ({CheckForm A} andthen {CheckForm B})
  364.         [] lt(A B) then ({CheckForm A} andthen {CheckForm B})
  365.         [] le(A B) then ({CheckForm A} andthen {CheckForm B})
  366.         [] gt(A B) then ({CheckForm A} andthen {CheckForm B})
  367.         [] ge(A B) then ({CheckForm A} andthen {CheckForm B})
  368.         else false
  369.         end
  370.      end
  371.  
  372.       end
  373.       fun{CheckPrim Prim}%Verifie que primitive d'un realitem est correct, si oui, true, sinon, false.
  374.      case Prim
  375.      of road then true
  376.      [] building then true
  377.      [] water then true
  378.      else false
  379.      end
  380.       end
  381.       fun{CheckPrimPok Prim}%Verifie que primitive d'un pokeitem est correct, si oui, true, sinon, false.
  382.      case Prim
  383.      of pokemon then true
  384.      [] arena then true
  385.      [] pokestop then true
  386.      else false
  387.      end
  388.       end
  389.       fun{CheckTrans Dx Dy Ru}%Verifie que translate() dans le monde reel est correct, si oui, true, sinon, false.
  390.      ({CheckVal Dx} andthen {CheckVal Dy} andthen {CheckR Ru})
  391.       end
  392.       fun{CheckTransPok Dx Dy Pu}%Verifie que translate() dans le monde pokemon est correct, si oui, true, sinon, false.
  393.      ({CheckForm Dx} andthen {CheckForm Dy} andthen {CheckP Pu})
  394.       end
  395.       fun{CheckRot Angle Ru}%Verifie que rotate est correct, si oui, true, sinon, false.
  396.      ({CheckVal Angle} andthen {CheckR Ru})
  397.       end
  398.       fun{CheckScale Rx Ry Ru}%Verifie que scale est correct, si oui, true, sinon, false.
  399.      ({CheckVal Rx} andthen {CheckVal Ry} andthen {CheckR Ru})
  400.       end
  401.       fun{CheckSpa Tmin Tmax Pu}%Verifie que spawn est correct, si oui, true, sinon, false.
  402.      ({Int.is Tmin} andthen {Int.is Tmax} andthen {CheckP Pu})
  403.       end
  404.       fun{CheckR Ru}%Verifie qu'on a bien un realuniverse, si oui, true, sinon, false.
  405.      case Ru
  406.      of H|T then
  407.         case H
  408.         of primitive(kind:A) then ({CheckPrim A} andthen {CheckR T})
  409.         [] translate(dx:Dx dy:Dy 1:Ru1) then ({CheckTrans Dx Dy Ru1} andthen {CheckR T})
  410.         [] rotate(angle:Angle 1:Ru1) then ({CheckRot Angle Ru1} andthen {CheckR T})
  411.         [] scale(rx:Rx ry:Ry 1:Ru1) then ({CheckScale Rx Ry Ru1} andthen {CheckR T})
  412.         else false
  413.         end
  414.      [] nil then true
  415.      else false
  416.      end
  417.       end
  418.       fun{CheckP Pu}%Verifie qu'on a bien un realuniverse, si oui, true, sinon, false.
  419.      case Pu
  420.      of H|T then
  421.         case H
  422.         of primitive(kind:A) then ({CheckPrimPok A} andthen {CheckP T})
  423.         [] translate(dx:Dx dy:Dy 1:Pu1) then ({CheckTransPok Dx Dy Pu1} andthen {CheckP T})
  424.         [] spawn(tmin:Tmin tmax:Tmax 1:Pu1) then ({CheckSpa Tmin Tmax Pu1} andthen {CheckP T})
  425.         else false
  426.         end
  427.      [] nil then true
  428.      else false
  429.      end
  430.       end
  431.    in
  432.       case Map %On lance la verification de notre Map
  433.       of map(ru:Ru pu:Pu) then
  434.      ({CheckR Ru} andthen {CheckP Pu})
  435.       else false
  436.       end
  437.    end
  438.  
  439.    %On execute.
  440.    {Projet.run MyFunction Map MaxTime Extensions CheckMap}
  441. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement