Advertisement
Sax

Fishgame v0.2b

Sax
May 6th, 2014
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. gamemode = Input["Modo de juego (1-4)"]
  2. playernum = Input["Jugadores (4-8)"]
  3. poplimit = actualpop = Input["Población Inicial (20)"]
  4. regen = Input["Tasa de Regeneración (0.25)"]
  5.  
  6. rounds = 10;
  7. wait = Input["Pausa (seg)"]
  8. doublewait = Input["Pausa doble (seg)"]
  9.  
  10.  
  11. cumulativecatch = {};
  12. playerlist = Table[List[],{playernum}];
  13. globalcatch = {};
  14. popsofar = {};
  15. over = False;
  16.  
  17. Do[
  18. Print["Starts round ", round, "!"];
  19. Pause[doublewait];
  20. suma = {};
  21. Do[
  22. Print["Starts Player ", player, " turn!"];
  23. Pause[wait];
  24. catch = RandomInteger[{1,3}];
  25. (* Print[catch]; Debug *)
  26. popafterdraw = actualpop - catch;
  27. (* Print[popafterdraw]; *)
  28.  
  29. If[actualpop >= catch, (* Validate population before draw *)
  30. Print["Player ", player, " draws ", catch, " fish!"];
  31. Pause[wait];
  32. AppendTo[playerlist[[player]],catch];
  33. Print["Population is now ", popafterdraw];
  34. Pause[wait];
  35. actualpop = popafterdraw;
  36. If[popafterdraw <= 0,
  37. Print["Fish depleted after ", round, " rounds!"];
  38. AppendTo[suma,Last[playerlist[[player]]]];
  39. AppendTo[popsofar,0];
  40. Pause[wait];
  41. over = True;
  42. Break[]]
  43.  
  44. (* Begins false part of validator *)
  45. , Print["Population is less than the preferred method."];
  46. Pause[wait];
  47. catch = actualpop;
  48. Print["Fishing ", catch, " units instead."]
  49. Pause[wait];
  50. AppendTo[playerlist[[player]],catch];
  51. over = True;
  52. AppendTo[suma,Last[playerlist[[player]]]];
  53. AppendTo[popsofar,0];
  54. Break[]
  55. Print[playerlist[[player]]];
  56. ]
  57.  
  58. AppendTo[suma,Last[playerlist[[player]]]];
  59. ,{player,playernum}];
  60.  
  61. Print["Suma es", suma]
  62. AppendTo[globalcatch, Total[suma]];
  63. AppendTo[cumulativecatch, Total[globalcatch]];
  64. Print["global catch is ", globalcatch, " so far"]
  65. Print["cummulative catch is ",cumulativecatch, " so far"]
  66. Print["Over is ", over]
  67.  
  68. If[over == False,
  69. Print["Regenerating ", Floor[actualpop * (regen)], " fish!"];
  70. Pause[wait];
  71. actualpop = Floor[actualpop * (1 + regen)];
  72. Print["Population is now ", actualpop];
  73. Pause[wait];
  74. Print["-------"], Break[]];
  75.  
  76. (*If[Length[cumulativecatch < 1],
  77. Append[cumulativecatch,Total[globalcatch]],
  78. Append[cumulativecatch,Last[cumulativecatch]+Total[suma]]]; *)
  79.  
  80. suma=.
  81. AppendTo[popsofar,actualpop];
  82. ,{round,rounds}];
  83.  
  84. playerlist//MatrixForm
  85.  
  86. Print["Catch per turn: ", globalcatch];
  87. Print["Cumulative score: ", cumulativecatch];
  88. Print["Population each turn: ", popsofar]
  89. ListLinePlot[{globalcatch,popsofar}, PlotRange->Automatic, PlotLegends -> {"Global Catch", "Population"}]
  90. ListLinePlot[playerlist,Filling->Axis,PlotLegends->Automatic, PlotRange->{Automatic,{0,5}}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement