Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gamemode = Input["Modo de juego (1-4)"]
- playernum = Input["Jugadores (4-8)"]
- poplimit = actualpop = Input["Población Inicial (20)"]
- regen = Input["Tasa de Regeneración (0.25)"]
- rounds = 10;
- wait = Input["Pausa (seg)"]
- doublewait = Input["Pausa doble (seg)"]
- cumulativecatch = {};
- playerlist = Table[List[],{playernum}];
- globalcatch = {};
- popsofar = {};
- over = False;
- Do[
- Print["Starts round ", round, "!"];
- Pause[doublewait];
- suma = {};
- Do[
- Print["Starts Player ", player, " turn!"];
- Pause[wait];
- 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!"];
- Pause[wait];
- AppendTo[playerlist[[player]],catch];
- Print["Population is now ", popafterdraw];
- Pause[wait];
- actualpop = popafterdraw;
- If[popafterdraw <= 0,
- Print["Fish depleted after ", round, " rounds!"];
- AppendTo[suma,Last[playerlist[[player]]]];
- AppendTo[popsofar,0];
- Pause[wait];
- over = True;
- Break[]]
- (* Begins false part of validator *)
- , Print["Population is less than the preferred method."];
- Pause[wait];
- catch = actualpop;
- Print["Fishing ", catch, " units instead."]
- Pause[wait];
- AppendTo[playerlist[[player]],catch];
- over = True;
- AppendTo[suma,Last[playerlist[[player]]]];
- AppendTo[popsofar,0];
- Break[]
- Print[playerlist[[player]]];
- ]
- AppendTo[suma,Last[playerlist[[player]]]];
- ,{player,playernum}];
- Print["Suma es", suma]
- AppendTo[globalcatch, Total[suma]];
- AppendTo[cumulativecatch, Total[globalcatch]];
- Print["global catch is ", globalcatch, " so far"]
- Print["cummulative catch is ",cumulativecatch, " so far"]
- Print["Over is ", over]
- If[over == False,
- Print["Regenerating ", Floor[actualpop * (regen)], " fish!"];
- Pause[wait];
- actualpop = Floor[actualpop * (1 + regen)];
- Print["Population is now ", actualpop];
- Pause[wait];
- Print["-------"], Break[]];
- (*If[Length[cumulativecatch < 1],
- Append[cumulativecatch,Total[globalcatch]],
- Append[cumulativecatch,Last[cumulativecatch]+Total[suma]]]; *)
- suma=.
- AppendTo[popsofar,actualpop];
- ,{round,rounds}];
- playerlist//MatrixForm
- Print["Catch per turn: ", globalcatch];
- Print["Cumulative score: ", cumulativecatch];
- Print["Population each turn: ", popsofar]
- ListLinePlot[{globalcatch,popsofar}, PlotRange->Automatic, PlotLegends -> {"Global Catch", "Population"}]
- ListLinePlot[playerlist,Filling->Axis,PlotLegends->Automatic, PlotRange->{Automatic,{0,5}}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement