Advertisement
Guest User

Untitled

a guest
May 26th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. Acció travessa1part(e/s arbre1:Arbre; ent idJugador: nat; participants: CjtJugadors e/s pilaFinalistes: Pila; e/s e: Estadístiques;)
  2. {Pre: -}
  3. var s: sala
  4. s:=arrel(arbre1);
  5. si no desintegrat(idJugador,participants) -->
  6. si es_buit(fill_esq(arbre1)) i es_buit(fill_dre(arbre1)) i no s.ocupada -->
  7. si clausObrenPany(idJugador,s.panyEsq,participants) -->
  8. s.ocupada:=true;
  9. pilaFinalistes:=demanar_torn(idJugador,pilaFinalistes)
  10. desaSalaFinal(idJugador,s.id,e);
  11. [] desintegra(idJugador,participants);
  12. fsi
  13. [] s.contEsq >= s.contDre i s.contEsq != 0
  14. si clausObrenPany(idJugador,s.panyEsq,participants) -->
  15. travessa1part(fill_esq,idJugador,participants,pilaFinalistes,e);
  16. si no desintegrat(idJugador,participants) -->
  17. s.contEsq := s.contEsq - 1;
  18. fsi
  19. [] clausObrenPany(idJugador,s.panyDre,participants) i s.contDre != 0 -->
  20. travessa1part(fill_dre,idJugador,participants,pilaFinalistes,e);
  21. si no desintegrat(idJugador,participants) -->
  22. s.contDre := s.contDre - 1;
  23. fsi
  24. [] desintegra(idJugador,participants);
  25. fsi
  26. [] s.contDre > s.contEsq -->
  27. si clausObrenPany(idJugador,s.panyDre,participants) -->
  28. travessa1part(fill_esq,idJugador,participants,pilaFinalistes,e);
  29. si no desintegrat(idJugador,participants) -->
  30. s.contDre := s.contDre -1;
  31. fsi
  32. [] clausObrenPany(idJugador,s.panyDre,participants) i s.contEsq != 0 -->
  33. travessa1part(fill_dre,idJugador,participants,pilaFinalistes,e);
  34. si no desintegrat(idJugador,participants) -->
  35. s.contDre := s.contDre - 1;
  36. fsi
  37. [] desintegra(idJugador,participants);
  38. fsi
  39. fsi
  40.  
  41. funció travessa2part(e/s arbre2:Arbre; ent participants: CjtJugadors; e/s e2: Estadístiques) ret idJugador: enter
  42. var s: sala2
  43. s:=arrel(arbre2);
  44. si es_buit(fill_esq(arbre2)) i es_buit(fill_dre(arbre2)) i s.ocupada -->
  45. si clausObrenPany(s.idJugador,s.pany,participants) -->
  46. idJugador :=s.idJugador;
  47. [] idJugador := -1;
  48. fsi
  49. fsi
  50. [] es_buit(fill_dre(arbre2)) -->
  51. idJugador := travessa2part(fill_esq(arbre1),participants,e2);
  52. si idJugador != -1 -->
  53. si no clausObrenPany(idJugador,s.pany,participants) -->
  54. idJugador :=-1;
  55. fsi
  56. fsi
  57. [] es_buit(fill_esq(arbre2))-->
  58. idJugador := travessa2part(fill_dre(arbre1),participants,e2);
  59. si idJugador != -1 -->
  60. si no clausObrenPany(idJugador,s.pany,participants) -->
  61. idJugador:=-1;
  62. fsi
  63. fsi
  64. [] -->
  65. var jugadorDre,jugadorEsq: enter
  66. jugadorEsq:= travessa2part(fill_esq(arbre2),participants,e2);
  67. jugadorDre:= travessa2part(fill_dre(arbre2),participants,e2);
  68. si jugadorEsq != -1 -->
  69. si jugadorDre != -1 -->
  70. idJugador = lluita(jugadorDre,jugadorEsq,participants)
  71. si idJugador = jugadorDre -->
  72. desaCombat(idJugador,jugadorEsq,e2);
  73. [] desaCombat(idJugador,jugadorDre,e2);
  74. fsi
  75. si no clausObrenPany(idJugador,s.pany,participants) -->
  76. idJugador:=-1;
  77. fsi
  78. [] idJugador:=jugadorEsq;
  79. si no clausObrenPany(idJugador,s.pany,participants) -->
  80. idJugador:=-1;
  81. fsi
  82. fsi
  83. [] idJugador:=jugadorDre
  84. si no clausObrenPany(idJugador,s.pany,participants) -->
  85. idJugador:=-1;
  86. fsi
  87. fsi
  88. fsi
  89.  
  90. acció inicialitzar2part(e/s arbre2:Arbre;jugadors:vector nat de mida[1..J],ent e2:Estadístiques)
  91. s:=arrel(arbre2)
  92. si es_buit(fill_esq(arbre2)) i es_buit(fill_dre(arbre2)) -->
  93. s.ocupada := false;
  94. var i:nat
  95. per i=0 fins i=J-1 fer
  96. si s.id = consultaSalaFinal(jugadors[i],e2) -->
  97. s.idJugador := jugadors[i]
  98. s.ocupada := true
  99. fsi
  100. fper
  101. [] es_buit(fill_dre) -->
  102. inicialitzar2part(fill_esq(arbre1),jugadors,e2)
  103. [] es_buit(fill_esq) -->
  104. inicialitzar2part(fill_dre(arbre1),jugadors,e2)
  105. [] -->
  106. inicialitzar2part(fill_esq(arbre1),jugadors,e2)
  107. inicialitzar2part(fill_dre(arbre1),jugadors,e2)
  108. fsi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement