Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Fishgame v1.0b, Mathematica CoreLanguage *)
- poplimit = actualpop = 20
- regen = 0.25 (* 25% population regeneration rate *)
- playernum = 4
- rounds = 10
- cumulativecatch = {}
- playerlist = Table[List[],{playernum}]
- globalcatch = {}
- over = False
- Do[
- Print["Starts round ", round, "!"];
- suma = {};
- Do[
- Print["Starts Player ", player, " turn!"];
- catch = RandomInteger[{1,3}];
- (* Print[catch]; Debug *)
- popafterdraw = actualpop - catch;
- (* Print[popafterdraw]; *)
- If[actualpop >= catch, (* Validate population before draw *)
- Print["Player ", player, " draws ", catch, " fish!"];
- AppendTo[playerlist[[player]],catch];
- Print["Population is now ", popafterdraw];
- actualpop = popafterdraw;
- If[popafterdraw <= 0,
- Print["Fish depleted after ", round, " rounds!"];
- over = True
- Break[]]
- (* Begins false part of validator *)
- , Print["Population is less than the preferred method."];
- catch = actualpop;
- Print["Fishing ", catch, " units instead."]
- AppendTo[playerlist[[player]],catch];
- over = True;
- Break[]
- Print[playerlist[[player]]];
- ]
- AppendTo[suma,Last[playerlist[[player]]]]
- ,{player,playernum}];
- If[over == False,
- Print["Regenerating ", Floor[actualpop * (1 + regen)], " fish!"];
- actualpop = Floor[actualpop * (1 + regen)];
- Print["Population is now ", actualpop];
- Print["-------"];
- , AppendTo[globalcatch,Sum[i,suma]]];
- If[Length[cumulativecatch < 1],
- AppendTo[cumulativecatch,Sum[i,suma]],
- AppendTo[cumulativecatch,Last[cumulativecatch]+Sum[i,suma]]];
- Print[globalcatch]
- Print[cumulativecatch]
- ,{round,rounds}];
- Print[MatrixForm[playerlist]]
- Print["Catch per turn: ", globalcatch]
- Print["Cumulative score: ", cumulativecatch]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement