@@ -90,7 +90,7 @@ public Node findBestMove() {
9090 }
9191 current .expand ();
9292 for (final Node child : current .children ) {
93- for (int simulate = 0 ; simulate < 1 ; simulate ++) {
93+ for (int simulate = 0 ; simulate < 3 ; simulate ++) {
9494 current .propagate (child .simulation ());
9595 }
9696 }
@@ -112,7 +112,7 @@ public Node findBestMove() {
112112
113113 public static long evaluate (final GameState gameState ) {
114114 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 ));
116116 }
117117
118118}
@@ -145,9 +145,8 @@ public Node getNextChild() {
145145 double max = -1 ;
146146 Node maxNode = null ;
147147 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 ));
151150 if (score > max ) {
152151 max = score ;
153152 maxNode = node ;
@@ -181,7 +180,7 @@ public long simulation() {
181180 } else {
182181 Node now = this ;
183182 int rounds = 0 ;
184- while (rounds < 26 ) {
183+ while (rounds < 18 ) {
185184 expand ();
186185 now = children .get (random .nextInt (children .size ()));
187186 rounds += 2 ;
@@ -218,38 +217,38 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
218217 }
219218 if (currentBot .samplesLength < 3 ) {
220219 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 );
222221 } 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 );
224223 } else if (2 <= currentBot .totalExpertise ) {
224+ gameStates .put (gameState .play (1 ).setBias (10 ), Action .CONNECT .name () + " " + 2 );
225225 gameStates .put (gameState .play (0 ).setBias (0.1 ), Action .CONNECT .name () + " " + 1 );
226- gameStates .put (gameState .play (1 ), Action .CONNECT .name () + " " + 2 );
227226 } else {
228- gameStates .put (gameState .play (0 ), Action .CONNECT .name () + " " + 1 );
227+ gameStates .put (gameState .play (0 ). setBias ( 10 ) , Action .CONNECT .name () + " " + 1 );
229228 }
230229 }
231230 break ;
232231 }
233232 case DIAGNOSIS : {
234233 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 ());
236235 }
237236 if (currentBot .totalMolecules < 5 ) {
238237 gameStates .put (gameState .play (Position .MOLECULES ).setBias (0.4 ), Action .GOTO .name () + " " + Position .MOLECULES .name ());
239238 } else if (currentBot .totalMolecules < 10 ) {
240239 for (int i = 0 ; i < currentBot .samplesLength ; i ++) {
241240 final Sample sample = currentBot .samples [i ];
242241 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 ());
244243 }
245244 }
246245 }
247246 if (currentBot .samplesLength < 3 ) {
248247 gameStates .put (gameState .play (Position .SAMPLES ).setBias (0.2 ), Action .GOTO .name () + " " + Position .SAMPLES .name ());
249248 }
250249 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 ) ,
253252 Action .CONNECT .name () + " " + currentBot .samples [i ].material .sampleId );
254253 }
255254 }
@@ -259,29 +258,28 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
259258 final int rank = gameState .samples [i ].material .rank ;
260259 if (rank == 2 ) {
261260 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 );
263262 }
264263 } else if (rank == 1 ) {
265264 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 );
267266 }
268267 } 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 );
271269 }
272270 }
273271 }
274272 }
275273 if (gameStates .size () == 0 ) {
276274 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 );
278276 }
279277 }
280278 break ;
281279 }
282280 case MOLECULES : {
283281 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 ());
285283 }
286284 if (diagnosisLeft || gameState .samplesLength != 0 || currentBot .samplesLength == 3 ) {
287285 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) {
293291 int x = 0 ;
294292 for (int i = 0 ; i < currentBot .samplesLength ; i ++) {
295293 final Sample sample = currentBot .samples [i ];
296- if (currentBot .isPossible (sample , gameState .availableMolecules ) && ! currentBot . isAdequate ( sample ) ) {
294+ if (currentBot .isPossible (sample , gameState .availableMolecules )) {
297295 for (int j = 0 ; j < gameState .availableMolecules .length ; j ++) {
298296 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 ));
300298 x ++;
301299 }
302300 }
@@ -305,7 +303,7 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
305303 if (x == 0 && currentBot .totalMolecules < 5 ) {
306304 for (int j = 0 ; j < gameState .availableMolecules .length ; j ++) {
307305 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 ));
309307 }
310308 }
311309 }
@@ -317,7 +315,7 @@ private Map<GameState, String> getPossibleMoves(final GameState gameState) {
317315 final Sample sample = currentBot .samples [i ];
318316 if (sample .visible ) {
319317 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 );
321319 }
322320 }
323321 }
@@ -852,6 +850,9 @@ public boolean canMakeMedicine() {
852850 }
853851
854852 public boolean isAdequate (final Sample sample ) {
853+ if (!sample .visible ) {
854+ return false ;
855+ }
855856 for (int i = 0 ; i < storage .length ; i ++) {
856857 if (storage [i ] + expertise [i ] < sample .material .cost [i ]) {
857858 return false ;
@@ -861,6 +862,9 @@ public boolean isAdequate(final Sample sample) {
861862 }
862863
863864 public boolean isPossible (final Sample sample , final int available []) {
865+ if (!sample .visible ) {
866+ return false ;
867+ }
864868 for (int i = 0 ; i < storage .length ; i ++) {
865869 if (storage [i ] + expertise [i ] + available [i ] < sample .material .cost [i ]) {
866870 return false ;
0 commit comments