View difference between Paste ID: nb8FfhqV and UQr0Vyza
SHOW: | | - or go back to the newest paste.
1-
(* Fishgame v1.0b, Mathematica CoreLanguage *)
1+
gamemode = Input["Modo de juego (1-4)"]
2
playernum = Input["Jugadores (4-8)"]
3-
poplimit = actualpop = 20
3+
poplimit = actualpop = Input["Población Inicial (20)"]
4-
regen = 0.25 (* 25% population regeneration rate *)
4+
regen = Input["Tasa de Regeneración (0.25)"]
5-
playernum = 4
5+
6-
rounds = 10
6+
rounds = 10;
7
wait = Input["Pausa (seg)"]
8
doublewait = Input["Pausa doble (seg)"]
9-
cumulativecatch = {}
9+
10-
playerlist = Table[List[],{playernum}]
10+
11-
globalcatch = {}
11+
cumulativecatch = {};
12-
over = False
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-
				over = True
32+
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-
		AppendTo[suma,Last[playerlist[[player]]]]
45+
46
		Pause[wait];
47
		catch = actualpop;
48-
		Print["Regenerating ", Floor[actualpop * (1 + regen)], " fish!"];
48+
49
		Pause[wait];
50
		AppendTo[playerlist[[player]],catch];
51-
		Print["-------"];
51+
52-
		, AppendTo[globalcatch,Sum[i,suma]]];
52+
		AppendTo[suma,Last[playerlist[[player]]]];
53
		AppendTo[popsofar,0];
54-
	If[Length[cumulativecatch < 1],
54+
55-
		AppendTo[cumulativecatch,Sum[i,suma]],
55+
56-
		AppendTo[cumulativecatch,Last[cumulativecatch]+Sum[i,suma]]];
56+
57-
	Print[globalcatch]
57+
58-
	Print[cumulativecatch]
58+
		AppendTo[suma,Last[playerlist[[player]]]];
59
		,{player,playernum}];
60
61-
Print[MatrixForm[playerlist]]
61+
	Print["Suma es", suma]
62
	AppendTo[globalcatch, Total[suma]];
63-
Print["Catch per turn: ", globalcatch]
63+
	AppendTo[cumulativecatch, Total[globalcatch]];
64-
Print["Cumulative score: ", cumulativecatch]
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}}]