int caClock::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QwtAnalogClock::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 2) qt_static_metacall(this, _c, _id, _a); _id -= 2; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = getPV(); break; case 1: *reinterpret_cast< timeType*>(_v) = getTimeType(); break; case 2: *reinterpret_cast< QColor*>(_v) = getBaseColor(); break; case 3: *reinterpret_cast< bool*>(_v) = getScaleDefaultColor(); break; case 4: *reinterpret_cast< QColor*>(_v) = getScaleColor(); break; case 5: *reinterpret_cast< colMode*>(_v) = getColorMode(); break; } _id -= 6; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setPV(*reinterpret_cast< QString*>(_v)); break; case 1: setTimeType(*reinterpret_cast< timeType*>(_v)); break; case 2: setBaseColor(*reinterpret_cast< QColor*>(_v)); break; case 3: setScaleDefaultColor(*reinterpret_cast< bool*>(_v)); break; case 4: setScaleColor(*reinterpret_cast< QColor*>(_v)); break; case 5: setColorMode(*reinterpret_cast< colMode*>(_v)); break; } _id -= 6; } else if (_c == QMetaObject::ResetProperty) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 6; } #endif // QT_NO_PROPERTIES return _id; }
int caNumeric::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = ENumeric::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = getPV(); break; case 1: *reinterpret_cast< QColor*>(_v) = getForeground(); break; case 2: *reinterpret_cast< QColor*>(_v) = getBackground(); break; case 3: *reinterpret_cast< SourceMode*>(_v) = getPrecisionMode(); break; case 4: *reinterpret_cast< bool*>(_v) = getFixedFormat(); break; case 5: *reinterpret_cast< SourceMode*>(_v) = getLimitsMode(); break; case 6: *reinterpret_cast< double*>(_v) = getMaxValue(); break; case 7: *reinterpret_cast< double*>(_v) = getMinValue(); break; } _id -= 8; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setPV(*reinterpret_cast< QString*>(_v)); break; case 1: setForeground(*reinterpret_cast< QColor*>(_v)); break; case 2: setBackground(*reinterpret_cast< QColor*>(_v)); break; case 3: setPrecisionMode(*reinterpret_cast< SourceMode*>(_v)); break; case 4: setFixedFormat(*reinterpret_cast< bool*>(_v)); break; case 5: setLimitsMode(*reinterpret_cast< SourceMode*>(_v)); break; case 6: setMaxValue(*reinterpret_cast< double*>(_v)); break; case 7: setMinValue(*reinterpret_cast< double*>(_v)); break; } _id -= 8; } else if (_c == QMetaObject::ResetProperty) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 8; } #endif // QT_NO_PROPERTIES return _id; }
score_t searchRoot(position_t *p, score_t alpha, score_t beta, int depth, int ply, move_t *pv, uint64_t *node_count_serial, FILE *OUT) { static int num_of_moves = 0; // number of moves in list // hopefully, more than we will need static sortable_move_t move_list[MAX_NUM_MOVES]; if (depth == 1) { // we are at depth 1; generate all possible moves num_of_moves = generate_all_opt(p, move_list, false); // shuffle the list of moves for (int i = 0; i < num_of_moves; i++) { int r = myrand() % num_of_moves; sortable_move_t tmp = move_list[i]; move_list[i] = move_list[r]; move_list[r] = tmp; } } searchNode rootNode; rootNode.parent = NULL; initialize_root_node(&rootNode, alpha, beta, depth, ply, p); assert(rootNode.best_score == alpha); // initial conditions searchNode next_node; next_node.subpv[0] = 0; next_node.parent = &rootNode; score_t score; for (int mv_index = 0; mv_index < num_of_moves; mv_index++) { move_t mv = get_move(move_list[mv_index]); if (TRACE_MOVES) { print_move_info(mv, ply); } (*node_count_serial)++; // make the move. victims_t x = make_move(&(rootNode.position), &(next_node.position), mv); if (is_KO(x)) { continue; // not a legal move } if (is_game_over(x, rootNode.pov, rootNode.ply)) { score = get_game_over_score(x, rootNode.pov, rootNode.ply); next_node.subpv[0] = 0; goto scored; } if (is_repeated(&(next_node.position), rootNode.ply)) { score = get_draw_score(&(next_node.position), rootNode.ply); next_node.subpv[0] = 0; goto scored; } if (mv_index == 0 || rootNode.depth == 1) { // We guess that the first move is the principle variation score = -searchPV(&next_node, rootNode.depth-1, node_count_serial); // Check if we should abort due to time control. if (abortf) { return 0; } } else { score = -scout_search(&next_node, rootNode.depth-1, node_count_serial); // Check if we should abort due to time control. if (abortf) { return 0; } // If its score exceeds the current best score, if (score > rootNode.alpha) { score = -searchPV(&next_node, rootNode.depth-1, node_count_serial); // Check if we should abort due to time control. if (abortf) { return 0; } } } scored: // only valid for the root node: tbassert((score > rootNode.best_score) == (score > rootNode.alpha), "score = %d, best = %d, alpha = %d\n", score, rootNode.best_score, rootNode.alpha); if (score > rootNode.best_score) { tbassert(score > rootNode.alpha, "score: %d, alpha: %d\n", score, rootNode.alpha); rootNode.best_score = score; pv[0] = mv; memcpy(pv+1, next_node.subpv, sizeof(move_t) * (MAX_PLY_IN_SEARCH - 1)); pv[MAX_PLY_IN_SEARCH - 1] = 0; // Print out based on UCI (universal chess interface) double et = elapsed_time(); char pvbuf[MAX_PLY_IN_SEARCH * MAX_CHARS_IN_MOVE]; getPV(pv, pvbuf, MAX_PLY_IN_SEARCH * MAX_CHARS_IN_MOVE); if (et < 0.00001) { et = 0.00001; // hack so that we don't divide by 0 } uint64_t nps = 1000 * *node_count_serial / et; fprintf(OUT, "info depth %d move_no %d time (microsec) %d nodes %" PRIu64 " nps %" PRIu64 "\n", depth, mv_index + 1, (int) (et * 1000), *node_count_serial, nps); fprintf(OUT, "info score cp %d pv %s\n", score, pvbuf); // Slide this move to the front of the move list for (int j = mv_index; j > 0; j--) { move_list[j] = move_list[j - 1]; } move_list[0] = mv; } // Normal alpha-beta logic: if the current score is better than what the // maximizer has been able to get so far, take that new value. Likewise, // score >= beta is the beta cutoff condition if (score > rootNode.alpha) { rootNode.alpha = score; } if (score >= rootNode.beta) { tbassert(0, "score: %d, beta: %d\n", score, rootNode.beta); break; } } return rootNode.best_score; }