Rev 154 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 154 | Rev 156 | ||
---|---|---|---|
Line 51... | Line 51... | ||
51 | static int bs_played[200], bs_percent[200]; |
51 | static int bs_played[200], bs_percent[200]; |
52 | static int book_status[200], evaluations[200], bs_learn[200]; |
52 | static int book_status[200], evaluations[200], bs_learn[200]; |
53 | static float bs_value[200], total_value; |
53 | static float bs_value[200], total_value; |
54 | static uint64_t book_key[200], bs_key[200]; |
54 | static uint64_t book_key[200], bs_key[200]; |
55 | int m1_status, forced = 0, total_percent, play_percentage = 0; |
55 | int m1_status, forced = 0, total_percent, play_percentage = 0; |
56 | float tempr; |
56 | float tempr; int itempr; // Pierre-Marie Baty -- added integer exchange variable |
57 | int done, i, j, last_move, temp, which, minlv = 999999, maxlv = -999999; |
57 | int done, i, j, last_move, temp, which, minlv = 999999, maxlv = -999999; |
58 | int maxp = -999999, minev = 999999, maxev = -999999; |
58 | int maxp = -999999, minev = 999999, maxev = -999999; |
59 | int nflagged, im, value, np, book_ponder_move; |
59 | int nflagged, im, value, np, book_ponder_move; |
60 | int cluster, scluster, test, v; |
60 | int cluster, scluster, test, v; |
61 | unsigned char buf32[4]; |
61 | unsigned char buf32[4]; |
Line 278... | Line 278... | ||
278 | } |
278 | } |
279 | } |
279 | } |
280 | maxp++; |
280 | maxp++; |
281 | for (i = 0; i < nmoves; i++) { |
281 | for (i = 0; i < nmoves; i++) { |
282 | bs_value[i] = 1; |
282 | bs_value[i] = 1; |
283 | bs_value[i] += bs_played[i |
283 | bs_value[i] += (float) (bs_played[i] / (float) maxp *1000.0 * book_weight_freq); // Pierre-Marie Baty -- added type cast |
284 | 284 | ||
285 | if (minlv < maxlv) |
285 | if (minlv < maxlv) |
286 | bs_value[i] += |
286 | bs_value[i] += (float) // Pierre-Marie Baty -- added type cast |
287 | (bs_learn[i] - minlv) / (float) (maxlv - |
287 | ((bs_learn[i] - minlv) / (float) (maxlv - |
288 | minlv) * 1000.0 * book_weight_learn; |
288 | minlv) * 1000.0 * book_weight_learn); |
289 | if (minev < maxev) |
289 | if (minev < maxev) |
290 | bs_value[i] += |
290 | bs_value[i] += (float) // Pierre-Marie Baty -- added type cast |
291 | (evaluations[i] - minev) / (float) (Max(maxev - minev, |
291 | ((evaluations[i] - minev) / (float) (Max(maxev - minev, |
292 | 50)) * 1000.0 * book_weight_eval; |
292 | 50)) * 1000.0 * book_weight_eval); |
293 | } |
293 | } |
294 | total_played = total_moves; |
294 | total_played = total_moves; |
295 | /* |
295 | /* |
296 | ************************************************************ |
296 | ************************************************************ |
297 | * * |
297 | * * |
Line 323... | Line 323... | ||
323 | done = 1; |
323 | done = 1; |
324 | for (i = 0; i < nmoves - 1; i++) { |
324 | for (i = 0; i < nmoves - 1; i++) { |
325 | if (bs_percent[i] < bs_percent[i + 1] |
325 | if (bs_percent[i] < bs_percent[i + 1] |
326 | || (bs_percent[i] == bs_percent[i + 1] |
326 | || (bs_percent[i] == bs_percent[i + 1] |
327 | && bs_value[i] < bs_value[i + 1])) { |
327 | && bs_value[i] < bs_value[i + 1])) { |
328 |
|
328 | itempr = bs_played[i]; // Pierre-Marie Baty -- fixed exchange variable |
329 | bs_played[i] = bs_played[i + 1]; |
329 | bs_played[i] = bs_played[i + 1]; |
330 | bs_played[i + 1] = |
330 | bs_played[i + 1] = itempr; // Pierre-Marie Baty -- fixed exchange variable |
331 | tempr = bs_value[i]; |
331 | tempr = bs_value[i]; |
332 | bs_value[i] = bs_value[i + 1]; |
332 | bs_value[i] = bs_value[i + 1]; |
333 | bs_value[i + 1] = tempr; |
333 | bs_value[i + 1] = tempr; |
334 | temp = evaluations[i]; |
334 | temp = evaluations[i]; |
335 | evaluations[i] = evaluations[i + 1]; |
335 | evaluations[i] = evaluations[i + 1]; |
Line 427... | Line 427... | ||
427 | if (!play_percentage) { |
427 | if (!play_percentage) { |
428 | for (i = 0; i < nmoves; i++) |
428 | for (i = 0; i < nmoves; i++) |
429 | if (!(book_status[i] & 0x03) || bs_percent[i]) { |
429 | if (!(book_status[i] & 0x03) || bs_percent[i]) { |
430 | selected_status[num_selected] = book_status[i]; |
430 | selected_status[num_selected] = book_status[i]; |
431 | selected_order_played[num_selected] = bs_played[i]; |
431 | selected_order_played[num_selected] = bs_played[i]; |
432 | selected_value[num_selected] = |
432 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
433 | selected_percent[num_selected] = bs_percent[i]; |
433 | selected_percent[num_selected] = bs_percent[i]; |
434 | selected_key[num_selected] = book_key[i]; |
434 | selected_key[num_selected] = book_key[i]; |
435 | selected[num_selected++] = book_moves[i]; |
435 | selected[num_selected++] = book_moves[i]; |
436 | } |
436 | } |
437 | } else { |
437 | } else { |
438 | for (i = 0; i < nmoves; i++) |
438 | for (i = 0; i < nmoves; i++) |
439 | if (bs_percent[i]) { |
439 | if (bs_percent[i]) { |
440 | selected_status[num_selected] = book_status[i]; |
440 | selected_status[num_selected] = book_status[i]; |
441 | selected_order_played[num_selected] = bs_played[i]; |
441 | selected_order_played[num_selected] = bs_played[i]; |
442 | selected_value[num_selected] = |
442 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
443 | selected_percent[num_selected] = bs_percent[i]; |
443 | selected_percent[num_selected] = bs_percent[i]; |
444 | selected_key[num_selected] = book_key[i]; |
444 | selected_key[num_selected] = book_key[i]; |
445 | selected[num_selected++] = book_moves[i]; |
445 | selected[num_selected++] = book_moves[i]; |
446 | } |
446 | } |
447 | } |
447 | } |
448 | for (i = 0; i < num_selected; i++) { |
448 | for (i = 0; i < num_selected; i++) { |
449 | book_status[i] = selected_status[i]; |
449 | book_status[i] = selected_status[i]; |
450 | bs_played[i] = selected_order_played[i]; |
450 | bs_played[i] = selected_order_played[i]; |
451 | bs_value[i] = |
451 | bs_value[i] = (float) selected_value[i]; // Pierre-Marie Baty -- added type cast |
452 | bs_percent[i] = selected_percent[i]; |
452 | bs_percent[i] = selected_percent[i]; |
453 | book_moves[i] = selected[i]; |
453 | book_moves[i] = selected[i]; |
454 | } |
454 | } |
455 | nmoves = num_selected; |
455 | nmoves = num_selected; |
456 | /* |
456 | /* |
Line 500... | Line 500... | ||
500 | for (i = 0; i < nmoves; i++) |
500 | for (i = 0; i < nmoves; i++) |
501 | if (book_status[i] & 16) { |
501 | if (book_status[i] & 16) { |
502 | forced = 1; |
502 | forced = 1; |
503 | selected_status[num_selected] = book_status[i]; |
503 | selected_status[num_selected] = book_status[i]; |
504 | selected_order_played[num_selected] = bs_played[i]; |
504 | selected_order_played[num_selected] = bs_played[i]; |
505 | selected_value[num_selected] = |
505 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
506 | selected_key[num_selected] = book_key[i]; |
506 | selected_key[num_selected] = book_key[i]; |
507 | selected[num_selected++] = book_moves[i]; |
507 | selected[num_selected++] = book_moves[i]; |
508 | } |
508 | } |
509 | if (!num_selected && !puzzling) |
509 | if (!num_selected && !puzzling) |
510 | if (book_accept_mask & 8) |
510 | if (book_accept_mask & 8) |
511 | for (i = 0; i < nmoves; i++) |
511 | for (i = 0; i < nmoves; i++) |
512 | if (book_status[i] & 8) { |
512 | if (book_status[i] & 8) { |
513 | forced = 1; |
513 | forced = 1; |
514 | selected_status[num_selected] = book_status[i]; |
514 | selected_status[num_selected] = book_status[i]; |
515 | selected_order_played[num_selected] = bs_played[i]; |
515 | selected_order_played[num_selected] = bs_played[i]; |
516 | selected_value[num_selected] = |
516 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
517 | selected_key[num_selected] = book_key[i]; |
517 | selected_key[num_selected] = book_key[i]; |
518 | selected[num_selected++] = book_moves[i]; |
518 | selected[num_selected++] = book_moves[i]; |
519 | } |
519 | } |
520 | if (!num_selected && !puzzling) |
520 | if (!num_selected && !puzzling) |
521 | if (book_accept_mask & 4) |
521 | if (book_accept_mask & 4) |
522 | for (i = 0; i < nmoves; i++) |
522 | for (i = 0; i < nmoves; i++) |
523 | if (book_status[i] & 4) { |
523 | if (book_status[i] & 4) { |
524 | selected_status[num_selected] = book_status[i]; |
524 | selected_status[num_selected] = book_status[i]; |
525 | selected_order_played[num_selected] = bs_played[i]; |
525 | selected_order_played[num_selected] = bs_played[i]; |
526 | selected_value[num_selected] = |
526 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
527 | selected_key[num_selected] = book_key[i]; |
527 | selected_key[num_selected] = book_key[i]; |
528 | selected[num_selected++] = book_moves[i]; |
528 | selected[num_selected++] = book_moves[i]; |
529 | } |
529 | } |
530 | if (!num_selected && !puzzling) |
530 | if (!num_selected && !puzzling) |
531 | for (i = 0; i < nmoves; i++) |
531 | for (i = 0; i < nmoves; i++) |
532 | if (book_status[i] & book_accept_mask) { |
532 | if (book_status[i] & book_accept_mask) { |
533 | selected_status[num_selected] = book_status[i]; |
533 | selected_status[num_selected] = book_status[i]; |
534 | selected_order_played[num_selected] = bs_played[i]; |
534 | selected_order_played[num_selected] = bs_played[i]; |
535 | selected_value[num_selected] = |
535 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
536 | selected_key[num_selected] = book_key[i]; |
536 | selected_key[num_selected] = book_key[i]; |
537 | selected[num_selected++] = book_moves[i]; |
537 | selected[num_selected++] = book_moves[i]; |
538 | } |
538 | } |
539 | if (!num_selected) |
539 | if (!num_selected) |
540 | for (i = 0; i < nmoves; i++) { |
540 | for (i = 0; i < nmoves; i++) { |
541 | selected_status[num_selected] = book_status[i]; |
541 | selected_status[num_selected] = book_status[i]; |
542 | selected_order_played[num_selected] = bs_played[i]; |
542 | selected_order_played[num_selected] = bs_played[i]; |
543 | selected_value[num_selected] = |
543 | selected_value[num_selected] = (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
544 | selected_key[num_selected] = book_key[i]; |
544 | selected_key[num_selected] = book_key[i]; |
545 | selected[num_selected++] = book_moves[i]; |
545 | selected[num_selected++] = book_moves[i]; |
546 | } |
546 | } |
547 | if (!num_selected) |
547 | if (!num_selected) |
548 | return 0; |
548 | return 0; |
549 | for (i = 0; i < num_selected; i++) { |
549 | for (i = 0; i < num_selected; i++) { |
550 | book_status[i] = selected_status[i]; |
550 | book_status[i] = selected_status[i]; |
551 | book_moves[i] = selected[i]; |
551 | book_moves[i] = selected[i]; |
552 | bs_played[i] = selected_order_played[i]; |
552 | bs_played[i] = selected_order_played[i]; |
553 | bs_value[i] = |
553 | bs_value[i] = (float) selected_value[i]; // Pierre-Marie Baty -- added type cast |
554 | bs_key[i] = selected_key[i]; |
554 | bs_key[i] = selected_key[i]; |
555 | } |
555 | } |
556 | nmoves = num_selected; |
556 | nmoves = num_selected; |
557 | if (nmoves == 0) |
557 | if (nmoves == 0) |
558 | return 0; |
558 | return 0; |
Line 596... | Line 596... | ||
596 | if (fabs(total_value) < 0.0001) |
596 | if (fabs(total_value) < 0.0001) |
597 | total_value = 1000.0; |
597 | total_value = 1000.0; |
598 | total_percent = (total_percent > 99) ? 99 : total_percent; |
598 | total_percent = (total_percent > 99) ? 99 : total_percent; |
599 | for (i = 0; i < nmoves; i++) |
599 | for (i = 0; i < nmoves; i++) |
600 | if (bs_percent[i]) |
600 | if (bs_percent[i]) |
601 | bs_value[i] = |
601 | bs_value[i] = (float) // Pierre-Marie Baty -- added type cast |
602 | total_value / (1.0 - |
602 | (total_value / (1.0 - |
603 | (float) total_percent / 100.0) * (float) bs_percent[i] / 100.0; |
603 | (float) total_percent / 100.0) * (float) bs_percent[i] / 100.0); |
604 | /* |
604 | /* |
605 | ************************************************************ |
605 | ************************************************************ |
606 | * * |
606 | * * |
607 | * Display the book moves, and total counts, etc. if the * |
607 | * Display the book moves, and total counts, etc. if the * |
608 | * operator has requested it. * |
608 | * operator has requested it. * |
Line 729... | Line 729... | ||
729 | for (i = 0; i < j; i++) |
729 | for (i = 0; i < j; i++) |
730 | which = Random32(); |
730 | which = Random32(); |
731 | total_moves = 0; |
731 | total_moves = 0; |
732 | for (i = 0; i < last_move; i++) { |
732 | for (i = 0; i < last_move; i++) { |
733 | if (bs_percent[0]) |
733 | if (bs_percent[0]) |
734 | total_moves += |
734 | total_moves += (int) bs_value[i]; // Pierre-Marie Baty -- added type cast |
735 | else |
735 | else |
736 | total_moves += bs_value[i |
736 | total_moves += (int) (bs_value[i] * bs_value[i]); // Pierre-Marie Baty -- added type cast |
737 | } |
737 | } |
738 | distribution = Abs(which) % Max(total_moves, 1); |
738 | distribution = Abs(which) % Max(total_moves, 1); |
739 | for (which = 0; which < last_move; which++) { |
739 | for (which = 0; which < last_move; which++) { |
740 | if (bs_percent[0]) |
740 | if (bs_percent[0]) |
741 | distribution -= |
741 | distribution -= (int) bs_value[which]; // Pierre-Marie Baty -- added type cast |
742 | else |
742 | else |
743 | distribution -= bs_value[which |
743 | distribution -= (int) (bs_value[which] * bs_value[which]); // Pierre-Marie Baty -- added type cast |
744 | if (distribution < 0) |
744 | if (distribution < 0) |
745 | break; |
745 | break; |
746 | } |
746 | } |
747 | which = Min(which, last_move - 1); |
747 | which = Min(which, last_move - 1); |
748 | tree->pv[0].path[1] = book_moves[which]; |
748 | tree->pv[0].path[1] = book_moves[which]; |
Line 1306... | Line 1306... | ||
1306 | memcpy((void *) &book_buffer_char[0].position, |
1306 | memcpy((void *) &book_buffer_char[0].position, |
1307 | (void *) BookOut64(current.position), 8); |
1307 | (void *) BookOut64(current.position), 8); |
1308 | memcpy((void *) &book_buffer_char[0].status_played, |
1308 | memcpy((void *) &book_buffer_char[0].status_played, |
1309 | (void *) BookOut32(current.status_played), 4); |
1309 | (void *) BookOut32(current.status_played), 4); |
1310 | memcpy((void *) &book_buffer_char[0].learn, |
1310 | memcpy((void *) &book_buffer_char[0].learn, |
1311 | (void *) BookOut32(current.learn |
1311 | (void *) BookOut32((int) current.learn), 4); // Pierre-Marie Baty -- added type cast |
1312 | stat = |
1312 | stat = |
1313 | fwrite(book_buffer_char, sizeof(BOOK_POSITION), 1, book_file); |
1313 | fwrite(book_buffer_char, sizeof(BOOK_POSITION), 1, book_file); |
1314 | if (stat != 1) |
1314 | if (stat != 1) |
1315 | Print(4095, "ERROR! write failed, disk probably full.\n"); |
1315 | Print(4095, "ERROR! write failed, disk probably full.\n"); |
1316 | } else if (played < min_played) |
1316 | } else if (played < min_played) |