Advertisement
Sax

fishgame v0.1b

Sax
Apr 11th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. (* Fishgame v1.0b, Mathematica CoreLanguage *)
  2.  
  3. poplimit = actualpop = 20
  4. regen = 0.25 (* 25% population regeneration rate *)
  5. playernum = 4
  6. rounds = 10
  7.  
  8.  
  9. cumulativecatch = {}
  10. playerlist = Table[List[],{playernum}]
  11. globalcatch = {}
  12. over = False
  13.  
  14.  
  15. Do[
  16. Print["Starts round ", round, "!"];
  17. suma = {};
  18. Do[
  19. Print["Starts Player ", player, " turn!"];
  20. catch = RandomInteger[{1,3}];
  21. (* Print[catch]; Debug *)
  22. popafterdraw = actualpop - catch;
  23. (* Print[popafterdraw]; *)
  24.  
  25. If[actualpop >= catch, (* Validate population before draw *)
  26. Print["Player ", player, " draws ", catch, " fish!"];
  27. AppendTo[playerlist[[player]],catch];
  28. Print["Population is now ", popafterdraw];
  29. actualpop = popafterdraw;
  30. If[popafterdraw <= 0,
  31. Print["Fish depleted after ", round, " rounds!"];
  32. over = True
  33. Break[]]
  34.  
  35. (* Begins false part of validator *)
  36. , Print["Population is less than the preferred method."];
  37. catch = actualpop;
  38. Print["Fishing ", catch, " units instead."]
  39. AppendTo[playerlist[[player]],catch];
  40. over = True;
  41. Break[]
  42. Print[playerlist[[player]]];
  43. ]
  44.  
  45. AppendTo[suma,Last[playerlist[[player]]]]
  46. ,{player,playernum}];
  47. If[over == False,
  48. Print["Regenerating ", Floor[actualpop * (1 + regen)], " fish!"];
  49. actualpop = Floor[actualpop * (1 + regen)];
  50. Print["Population is now ", actualpop];
  51. Print["-------"];
  52. , AppendTo[globalcatch,Sum[i,suma]]];
  53.  
  54. If[Length[cumulativecatch < 1],
  55. AppendTo[cumulativecatch,Sum[i,suma]],
  56. AppendTo[cumulativecatch,Last[cumulativecatch]+Sum[i,suma]]];
  57. Print[globalcatch]
  58. Print[cumulativecatch]
  59. ,{round,rounds}];
  60.  
  61. Print[MatrixForm[playerlist]]
  62.  
  63. Print["Catch per turn: ", globalcatch]
  64. Print["Cumulative score: ", cumulativecatch]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement