@@ -90,7 +90,7 @@ public Node findBestMove() {
90
90
}
91
91
current .expand ();
92
92
for (final Node child : current .children ) {
93
- for (int simulate = 0 ; simulate < 1 ; simulate ++) {
93
+ for (int simulate = 0 ; simulate < 3 ; simulate ++) {
94
94
current .propagate (child .simulation ());
95
95
}
96
96
}
@@ -112,7 +112,7 @@ public Node findBestMove() {
112
112
113
113
public static long evaluate (final GameState gameState ) {
114
114
final Robot first = gameState .robots [gameState .player ];
115
- return (long ) (100 * first .score + (1 - gameState .rounds / 400 .0 ) * (10 * first .totalExpertise + first .totalMolecules ));
115
+ return (long ) (100 * first .score + (100 - gameState .rounds / 4 .0 ) * (10 * first .totalExpertise + first .totalMolecules ));
116
116
}
117
117
118
118
}
@@ -145,9 +145,8 @@ public Node getNextChild() {
145
145
double max = -1 ;
146
146
Node maxNode = null ;
147
147
for (final Node node : children ) {
148
- final long nodePlays = node .plays .longValue ();
149
- final double rawScore = (((double ) node .totalScore .longValue ()) / totalScore .longValue ()) - Math .sqrt (2 * Math .log (plays .longValue ()) / nodePlays );
150
- final double score = rawScore + node .gameState .bias / (nodePlays + 1 );
148
+ double raw = (double ) node .totalScore .longValue () / plays .longValue () - Math .sqrt (2 * Math .log (plays .longValue ()) / node .plays .longValue ());
149
+ final double score = raw + (1000 * node .gameState .bias / (node .plays .longValue () + 1 ));
151
150
if (score > max ) {
152
151
max = score ;
153
152
maxNode = node ;
@@ -181,7 +180,7 @@ public long simulation() {
181
180
} else {
182
181
Node now = this ;
183
182
int rounds = 0 ;
184
- while (rounds < 26 ) {
183
+ while (rounds < 18 ) {
185
184
expand ();
186
185
now = children .get (random .nextInt (children .size ()));
187
186
rounds += 2 ;
@@ -218,38 +217,38 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
218
217
}
219
218
if (currentBot .samplesLength < 3 ) {
220
219
if (9 <= currentBot .totalExpertise ) {
221
- gameStates .put (gameState .play (2 ), Action .CONNECT .name () + " " + 3 );
220
+ gameStates .put (gameState .play (2 ). setBias ( 10 ) , Action .CONNECT .name () + " " + 3 );
222
221
} else if (6 <= currentBot .totalExpertise ) {
223
- gameStates .put (gameState .play (1 ), Action .CONNECT .name () + " " + 2 );
222
+ gameStates .put (gameState .play (1 ). setBias ( 10 ) , Action .CONNECT .name () + " " + 2 );
224
223
} else if (2 <= currentBot .totalExpertise ) {
224
+ gameStates .put (gameState .play (1 ).setBias (10 ), Action .CONNECT .name () + " " + 2 );
225
225
gameStates .put (gameState .play (0 ).setBias (0.1 ), Action .CONNECT .name () + " " + 1 );
226
- gameStates .put (gameState .play (1 ), Action .CONNECT .name () + " " + 2 );
227
226
} else {
228
- gameStates .put (gameState .play (0 ), Action .CONNECT .name () + " " + 1 );
227
+ gameStates .put (gameState .play (0 ). setBias ( 10 ) , Action .CONNECT .name () + " " + 1 );
229
228
}
230
229
}
231
230
break ;
232
231
}
233
232
case DIAGNOSIS : {
234
233
if (currentBot .canMakeMedicine ()) {
235
- gameStates .put (gameState .play (Position .LABORATORY ).setBias (0.95 ), Action .GOTO .name () + " " + Position .LABORATORY .name ());
234
+ gameStates .put (gameState .play (Position .LABORATORY ).setBias (1000 ), Action .GOTO .name () + " " + Position .LABORATORY .name ());
236
235
}
237
236
if (currentBot .totalMolecules < 5 ) {
238
237
gameStates .put (gameState .play (Position .MOLECULES ).setBias (0.4 ), Action .GOTO .name () + " " + Position .MOLECULES .name ());
239
238
} else if (currentBot .totalMolecules < 10 ) {
240
239
for (int i = 0 ; i < currentBot .samplesLength ; i ++) {
241
240
final Sample sample = currentBot .samples [i ];
242
241
if (currentBot .isPossible (sample , gameState .availableMolecules ) && !currentBot .isAdequate (sample )) {
243
- gameStates .put (gameState .play (Position .MOLECULES ).setBias (0.95 ), Action .GOTO .name () + " " + Position .MOLECULES .name ());
242
+ gameStates .put (gameState .play (Position .MOLECULES ).setBias (9 ), Action .GOTO .name () + " " + Position .MOLECULES .name ());
244
243
}
245
244
}
246
245
}
247
246
if (currentBot .samplesLength < 3 ) {
248
247
gameStates .put (gameState .play (Position .SAMPLES ).setBias (0.2 ), Action .GOTO .name () + " " + Position .SAMPLES .name ());
249
248
}
250
249
for (int i = 0 ; i < currentBot .samplesLength ; i ++) {
251
- if (!currentBot .samples [i ].visible || ! currentBot . isPossible ( currentBot . samples [ i ], gameState . availableMolecules ) ) {
252
- gameStates .put (gameState .play (currentBot .samples [i ].material .sampleId ),
250
+ if (!currentBot .samples [i ].visible ) {
251
+ gameStates .put (gameState .play (currentBot .samples [i ].material .sampleId ). setBias ( 10 ) ,
253
252
Action .CONNECT .name () + " " + currentBot .samples [i ].material .sampleId );
254
253
}
255
254
}
@@ -259,29 +258,28 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
259
258
final int rank = gameState .samples [i ].material .rank ;
260
259
if (rank == 2 ) {
261
260
if (5 <= currentBot .totalExpertise ) {
262
- gameStates .put (gameState .play (gameState .samples [i ].material .sampleId ), Action .CONNECT .name () + " " + gameState .samples [i ].material .sampleId );
261
+ gameStates .put (gameState .play (gameState .samples [i ].material .sampleId ). setBias ( 3 ) , Action .CONNECT .name () + " " + gameState .samples [i ].material .sampleId );
263
262
}
264
263
} else if (rank == 1 ) {
265
264
if (2 <= currentBot .totalExpertise ) {
266
- gameStates .put (gameState .play (gameState .samples [i ].material .sampleId ), Action .CONNECT .name () + " " + gameState .samples [i ].material .sampleId );
265
+ gameStates .put (gameState .play (gameState .samples [i ].material .sampleId ). setBias ( 3 ) , Action .CONNECT .name () + " " + gameState .samples [i ].material .sampleId );
267
266
}
268
267
} else {
269
- final GameState play = gameState .play (gameState .samples [i ].material .sampleId );
270
- gameStates .put (play .setBias (0.25 ), Action .CONNECT .name () + " " + gameState .samples [i ].material .sampleId );
268
+ gameStates .put (gameState .play (gameState .samples [i ].material .sampleId ).setBias (3 ), Action .CONNECT .name () + " " + gameState .samples [i ].material .sampleId );
271
269
}
272
270
}
273
271
}
274
272
}
275
273
if (gameStates .size () == 0 ) {
276
274
for (int i = 0 ; i < currentBot .samplesLength ; i ++) {
277
- gameStates .put (gameState .play (currentBot .samples [i ].material .sampleId ), Action .CONNECT .name () + " " + currentBot .samples [i ].material .sampleId );
275
+ gameStates .put (gameState .play (currentBot .samples [i ].material .sampleId ). setBias ( 3 ) , Action .CONNECT .name () + " " + currentBot .samples [i ].material .sampleId );
278
276
}
279
277
}
280
278
break ;
281
279
}
282
280
case MOLECULES : {
283
281
if (currentBot .canMakeMedicine ()) {
284
- gameStates .put (gameState .play (Position .LABORATORY ).setBias (0.9 ), Action .GOTO .name () + " " + Position .LABORATORY .name ());
282
+ gameStates .put (gameState .play (Position .LABORATORY ).setBias (1000 ), Action .GOTO .name () + " " + Position .LABORATORY .name ());
285
283
}
286
284
if (diagnosisLeft || gameState .samplesLength != 0 || currentBot .samplesLength == 3 ) {
287
285
gameStates .put (gameState .play (Position .DIAGNOSIS ).setBias (0.4 ), Action .GOTO .name () + " " + Position .DIAGNOSIS .name ());
@@ -293,10 +291,10 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
293
291
int x = 0 ;
294
292
for (int i = 0 ; i < currentBot .samplesLength ; i ++) {
295
293
final Sample sample = currentBot .samples [i ];
296
- if (currentBot .isPossible (sample , gameState .availableMolecules ) && ! currentBot . isAdequate ( sample ) ) {
294
+ if (currentBot .isPossible (sample , gameState .availableMolecules )) {
297
295
for (int j = 0 ; j < gameState .availableMolecules .length ; j ++) {
298
296
if (gameState .availableMolecules [j ] > 0 && currentBot .storage [j ] + currentBot .expertise [j ] < sample .material .cost [j ]) {
299
- gameStates .put (gameState .play (j ), Action .CONNECT .name () + " " + (char ) ('A' + j ));
297
+ gameStates .put (gameState .play (j ). setBias ( 1000 ) , Action .CONNECT .name () + " " + (char ) ('A' + j ));
300
298
x ++;
301
299
}
302
300
}
@@ -305,7 +303,7 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
305
303
if (x == 0 && currentBot .totalMolecules < 5 ) {
306
304
for (int j = 0 ; j < gameState .availableMolecules .length ; j ++) {
307
305
if (gameState .availableMolecules [j ] > 0 ) {
308
- gameStates .put (gameState .play (j ), Action .CONNECT .name () + " " + (char ) ('A' + j ));
306
+ gameStates .put (gameState .play (j ). setBias ( 1000 ) , Action .CONNECT .name () + " " + (char ) ('A' + j ));
309
307
}
310
308
}
311
309
}
@@ -317,7 +315,7 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
317
315
final Sample sample = currentBot .samples [i ];
318
316
if (sample .visible ) {
319
317
if (currentBot .isAdequate (sample )) {
320
- gameStates .put (gameState .play (sample .material .sampleId ).setBias (100 ), Action .CONNECT .name () + " " + sample .material .sampleId );
318
+ gameStates .put (gameState .play (sample .material .sampleId ).setBias (1000 ), Action .CONNECT .name () + " " + sample .material .sampleId );
321
319
}
322
320
}
323
321
}
@@ -852,6 +850,9 @@ public boolean canMakeMedicine() {
852
850
}
853
851
854
852
public boolean isAdequate (final Sample sample ) {
853
+ if (!sample .visible ) {
854
+ return false ;
855
+ }
855
856
for (int i = 0 ; i < storage .length ; i ++) {
856
857
if (storage [i ] + expertise [i ] < sample .material .cost [i ]) {
857
858
return false ;
@@ -861,6 +862,9 @@ public boolean isAdequate(final Sample sample) {
861
862
}
862
863
863
864
public boolean isPossible (final Sample sample , final int available []) {
865
+ if (!sample .visible ) {
866
+ return false ;
867
+ }
864
868
for (int i = 0 ; i < storage .length ; i ++) {
865
869
if (storage [i ] + expertise [i ] + available [i ] < sample .material .cost [i ]) {
866
870
return false ;
0 commit comments