-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
270 lines (254 loc) · 11.3 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
package MainPackage;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import java.util.Scanner;
import general.MainGame;
import general.ParamConfiguration;
import general.Population;
import general.Tool;
public class Main {
public static int iterator;
public static String nameForThisRunsOutputRoot;
public static void main (String[] args) throws Exception {
nameForThisRunsOutputRoot = produceNameForThisSimulationDirectory();
for (iterator=0;iterator<1;iterator++) { // for multiple runs of the simulation, that may differ
System.out.println(iterator); // in some of their parameters.
mmain(args);
}
}
public static void mmain(String[] args) throws Exception {
ParamConfiguration conf = new ParamConfiguration(nameForThisRunsOutputRoot);
Tool.toolcounter = 0;
Population.populationIDCount = 0;
conf.externalLoopIterator = iterator;
if (iterator<1) {
//conf.probOfCombinationAttempt = 0.1;
//conf.probOfCombinationSpurringAMainAxisTool = 0;
} else {
//conf.probOfCombinationAttempt = 0.5;
//conf.probOfCombinationSpurringAMainAxisTool = 0.1;
}
// if (iterator<2) {
// conf.associateEachCombinationWithBothItsFathers = false;
// } else {
// conf.associateEachCombinationWithBothItsFathers = true;
// }
// if (iterator<10) {
// conf.probOfToolBeingUsefulInEnvironment = 0.2;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<20) {
// conf.probOfToolBeingUsefulInEnvironment = 0.4;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<30) {
// conf.probOfToolBeingUsefulInEnvironment = 0.6;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<40) {
// conf.probOfToolBeingUsefulInEnvironment = 0.8;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<50) {
// conf.probOfToolBeingUsefulInEnvironment = 0.2;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<60) {
// conf.probOfToolBeingUsefulInEnvironment = 0.4;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<70) {
// conf.probOfToolBeingUsefulInEnvironment = 0.6;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<80) {
// conf.probOfToolBeingUsefulInEnvironment = 0.8;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<90) {
// conf.probOfToolBeingUsefulInEnvironment = 0.2;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<100) {
// conf.probOfToolBeingUsefulInEnvironment = 0.4;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<110) {
// conf.probOfToolBeingUsefulInEnvironment = 0.6;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<120) {
// conf.probOfToolBeingUsefulInEnvironment = 0.8;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<130) {
// conf.probOfToolBeingUsefulInEnvironment = 0.2;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<140) {
// conf.probOfToolBeingUsefulInEnvironment = 0.4;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<150) {
// conf.probOfToolBeingUsefulInEnvironment = 0.6;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<160) {
// conf.probOfToolBeingUsefulInEnvironment = 0.8;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<170) {
// conf.probOfToolBeingUsefulInEnvironment = 0.0009;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<180) {
// conf.probOfToolBeingUsefulInEnvironment = 0.009;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<190) {
// conf.probOfToolBeingUsefulInEnvironment = 0.09;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<200) {
// conf.probOfToolBeingUsefulInEnvironment = 0.9;
// conf.environmentSwitchProbability = 0.00001;
// } else if (iterator<210) {
// conf.probOfToolBeingUsefulInEnvironment = 0.0009;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<220) {
// conf.probOfToolBeingUsefulInEnvironment = 0.009;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<230) {
// conf.probOfToolBeingUsefulInEnvironment = 0.09;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<240) {
// conf.probOfToolBeingUsefulInEnvironment = 0.9;
// conf.environmentSwitchProbability = 0.0001;
// } else if (iterator<250) {
// conf.probOfToolBeingUsefulInEnvironment = 0.0009;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<260) {
// conf.probOfToolBeingUsefulInEnvironment = 0.009;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<270) {
// conf.probOfToolBeingUsefulInEnvironment = 0.09;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<280) {
// conf.probOfToolBeingUsefulInEnvironment = 0.9;
// conf.environmentSwitchProbability = 0.001;
// } else if (iterator<290) {
// conf.probOfToolBeingUsefulInEnvironment = 0.0009;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<300) {
// conf.probOfToolBeingUsefulInEnvironment = 0.009;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<310) {
// conf.probOfToolBeingUsefulInEnvironment = 0.09;
// conf.environmentSwitchProbability = 0.01;
// } else if (iterator<320) {
// conf.probOfToolBeingUsefulInEnvironment = 0.9;
// conf.environmentSwitchProbability = 0.01;
// }
// if (iterator<20) {
// conf.popsubdivision2[0] = 0.6; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.4; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<40) {
// conf.popsizes = new int[] {80};
// conf.popsubdivision2[0] = 0.7; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.3; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<60) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 0.8; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.2; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<80) {
// conf.popsizes = new int[] {80};
// conf.popsubdivision2[0] = 0.9; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.1; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<100) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 1.0; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.0; //{0.0,1.0,0.0,0.0,0.0};
// }
// if (iterator<1) {
// conf.popsizes[0] = 5;
// conf.probOfLossOfToolThatIsntUsefulInCurrentEnv = 0.05;
// } else if (iterator<2) {
// conf.popsizes[0] = 1000;
// conf.probOfLossOfToolThatIsntUsefulInCurrentEnv = 0.05;
// } else if (iterator<12) {
// conf.popsizes[0] = 1000;
// conf.probOfLossOfToolThatIsntUsefulInCurrentEnv = 0.05;
// } else if (iterator<16) {
// conf.popsizes[0] = 1000;
// conf.probOfLossOfToolThatIsntUsefulInCurrentEnv = 0.5;
// }
// if (iterator<20) {
// conf.popsubdivision2[0] = 0.6; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.4; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<40) {
// conf.popsizes = new int[] {80};
// conf.popsubdivision2[0] = 0.7; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.3; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<60) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 0.8; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.2; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<40) {
// conf.popsizes = new int[] {80};
// conf.popsubdivision2[0] = 0.9; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.1; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<60) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 1.0; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.0; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<140) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 0.2; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.8; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<160) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 0.4; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.6; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<180) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 0.6; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.4; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<200) {
// conf.popsizes = new int[] {100};
// conf.popsubdivision2[0] = 0.8; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.2; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<220) {
// conf.popsizes = new int[] {120};
// conf.popsubdivision2[0] = 0.0; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 1.0; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<240) {
// conf.popsizes = new int[] {120};
// conf.popsubdivision2[0] = 0.2; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.8; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<260) {
// conf.popsizes = new int[] {120};
// conf.popsubdivision2[0] = 0.4; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.6; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<280) {
// conf.popsizes = new int[] {120};
// conf.popsubdivision2[0] = 0.6; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.4; //{0.0,1.0,0.0,0.0,0.0};
// } else if (iterator<300) {
// conf.popsizes = new int[] {120};
// conf.popsubdivision2[0] = 0.8; //{0.0,1.0,0.0,0.0,0.0};
// conf.popsubdivision2[1] = 0.2; //{0.0,1.0,0.0,0.0,0.0};
// }
conf.copy_all_data_regarding_this_run();
conf.OpenFilesForOuputPrinting();
MainGame world_realization = new MainGame(conf);
world_realization.run();
// debug:
System.out.println("num of combination tools created:" + conf.debugCombCounter);
System.out.println("and accepted: " + conf. debugCombCounter_chosenOnes);
//System.out.println("which is (fraction): " + conf.debugCombCounter_chosenOnes/conf.debugCombCounter);
//double factorofToolsThatWErentLostBecauseOfTechnicalIssue = conf.lostToolsThatWereLostBeforeHavingAChanceToBeLost/conf.lostToolsCounter;
System.out.println("lost traits: " + conf.lostToolsCounter);
System.out.println("Traits meant to be lost that were not: " + conf.lostToolsThatWereLostBeforeHavingAChanceToBeLost);
//System.out.println("factor of tools that should have been lost and werent: " + factorofToolsThatWErentLostBecauseOfTechnicalIssue);
// close output file/s :
conf.outLossRateReverseChange.close(); conf.writerOfLossRateReverseChange.close();
}
public static String produceNameForThisSimulationDirectory() {
// I'd like to have all the output of a certain run in one directory, that won't be overrun by the
// next run, so:
Date date = Calendar.getInstance().getTime();
String mytime = date.toString();
System.out.println(mytime);
mytime = mytime.replaceAll("^.+? ",""); mytime=mytime.replaceAll("GMT+.+","");
mytime = mytime.replaceAll(" ","");mytime = mytime.replaceAll(":","");
//mytime = mytime.substring(0,mytime.length()-2); //this throws away the seconds.
mytime = mytime.split("PDT", 2)[0];
// to here - preparing name of run
return mytime;
}
}
//Scanner sc = new Scanner(System.in);while(!sc.nextLine().equals("")); //wait for "enter"