int main(int argc, char* argv[]) { store_map(); init_position(0); display(); printf("prediction\n"); prediction(1);// we move from one meter to the right display(); printf("estimation\n"); estimation(wall,wall); normalization(); display(); printf("prediction\n"); prediction(1);// we move from one meter to the right display(); printf("estimation\n"); estimation(wall,wall); normalization(); display(); printf("prediction\n"); prediction(1);// we move from one meter to the right display(); printf("estimation\n"); estimation(wall,wall); normalization(); display(); printf("prediction\n"); prediction(1);// we move from one meter to the right display(); printf("estimation\n"); estimation(wall,wall); normalization(); display(); printf("prediction\n"); prediction(1);// we move from one meter to the right display(); printf("estimation\n"); estimation(wall,wall); normalization(); display(); return 0; }// main
void GazeTrackerHistogramFeatures::draw() { if (!Application::Components::pointTracker->isTrackingSuccessful()) return; cv::Mat image = Application::Components::videoInput->debugFrame; // If not blinking, draw the estimations to debug window if (isActive() && !Application::Components::eyeExtractor->isBlinking()) { Point estimation(0, 0); /* //Utils::mapToVideoCoordinates(Application::Data::gazePointGP, Application::Components::videoInput->getResolution(), estimation); cv::circle(image, Utils::mapFromMainScreenToDebugCoordinates(cv::Point(Application::Data::gazePointHistFeaturesGP.x, Application::Data::gazePointHistFeaturesGP.y)), 8, cv::Scalar(0, 255, 0), -1, 8, 0); //Utils::mapToVideoCoordinates(Application::Data::gazePointGPLeft, Application::Components::videoInput->getResolution(), estimation); cv::circle(image, Utils::mapFromMainScreenToDebugCoordinates(cv::Point(Application::Data::gazePointHistFeaturesGPLeft.x, Application::Data::gazePointHistFeaturesGPLeft.y)), 8, cv::Scalar(255, 0, 0), -1, 8, 0); */ // MIXED ESTIMATION //Utils::mapToVideoCoordinates(Application::Data::gazePointGP, Application::Components::videoInput->getResolution(), estimation); cv::circle(image, Utils::mapFromMainScreenToDebugCoordinates(cv::Point((Application::Data::gazePointHistFeaturesGP.x + Application::Data::gazePointHistFeaturesGPLeft.x) / 2, (Application::Data::gazePointHistFeaturesGP.y + Application::Data::gazePointHistFeaturesGPLeft.y) / 2)), 8, cv::Scalar(255, 0, 0), -1, 8, 0); } }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { //declare variables //const mwSize *dims; double *batt_E; double *P_solar; double *inc_I; double *load_I; double *batt_I; double *batt_V; double lastPower; int T_orbit; //inputs batt_E = mxGetPr(prhs[0]); P_solar = mxGetPr(prhs[1]); inc_I = mxGetPr(prhs[2]); load_I = mxGetPr(prhs[3]); batt_I = mxGetPr(prhs[4]); batt_V = mxGetPr(prhs[5]); lastPower = mxGetScalar(prhs[6]); T_orbit = mxGetScalar(prhs[7]); struct Estimated_values output; //program output = estimation(T_orbit, batt_E, P_solar, inc_I, load_I, batt_I, batt_V, lastPower); //output plhs[0] = mxCreateDoubleScalar(output.Energy); plhs[1] = mxCreateDoubleScalar(output.Power); }
int Agent::best_choice() { static int base = 0; result[0] = -MAX_INT; move_list_len[0] = history->move_list_len(role, step); save_all(0); temp_move[0] = best_move[0] = 0; if(hash->exist(role)){ temp_move[0] = best_move[0] = hash->match_best; } if(best_move[0]){ board->put(best_move[0], role); result[0] = estimation(opp_role, 1, -MAX_INT, MAX_INT); recover_all(0); #ifdef VERBOSE printf("%d @ (%d, %d) <- %d (best)\n", result[0], xx[best_move[0]], yy[best_move[0]], history->get_init_index(best_move[0])); #endif } for(register int i = 1; i <= move_list_len[0]; ++i){ cur_move[0] = history->move(role, step, i); if( !board->can_put(cur_move[0], role) || cur_move[0] == temp_move[0]) continue; board->put(cur_move[0], role); value[0] = estimation(opp_role, 1, result[0], MAX_INT); recover_all(0); #ifdef VERBOSE printf("%d @ (%d, %d) <- %d\n", value[0], xx[cur_move[0]], yy[cur_move[0]],\ history->get_init_index(cur_move[0])); #endif if(value[0] > result[0]){ result[0] = value[0]; best_move[0] = cur_move[0]; } } hash->insert(result[0], role, H_EXACT, best_move[0], base, step); // this is for hash history saved file return best_move[0]; }
void GazeTrackerHistogramFeatures::draw() { if (!Application::Data::isTrackingSuccessful) return; cv::Mat image = Application::Components::videoInput->debugFrame; // If not blinking, draw the estimations to debug window if (isActive() && !_eyeExtractor->isBlinking()) { cv::Point estimation(gazePoint.x, gazePoint.y); cv::circle(image, Utils::mapFromSecondMonitorToDebugFrameCoordinates(estimation), 8, cv::Scalar(255, 0, 0), -1, 8, 0); } }
int Agent::estimation(char color, int depth, int alpha, int beta) { if( !board->able_to_put(color)){ color = opposite(color); if( !board->able_to_put(color)){ if(!end_game) cost->update(); return eval->value(); } } temp_move[depth] = best_move[depth] = 0; switch(hash->exist(color, alpha, beta, depth)){ case H_NONE_EXIST: break; case H_MATCH_EXIST: temp_move[depth] = best_move[depth] = hash->match_best; break; case H_EXACT_EXIST: return hash->match_eval; } if(depth == max_depth){ //the last search ply, no pv used return terminal_eval(color, depth, alpha, beta); } //pv_found[depth] = false; save_all(depth); if(best_move[depth]){ board->put(best_move[depth], color); value[depth] = estimation(opposite(color), depth+1, alpha, beta); recover_all(depth); if( color == role){ if( value[depth] > alpha){ if( (alpha = value[depth]) >= beta){ return alpha; } //pv_found[depth] = true; } result[depth] = value[depth]; } else{ if(value[depth] < beta){ if( (beta = value[depth]) <= alpha){ return beta; } //pv_found[depth] = true; } result[depth] = value[depth]; } } else{ result[depth] = (color == role)? -MAX_INT: MAX_INT; } move_list_len[depth] = history->move_list_len(color, step+depth); for(register int i = 1; i <= move_list_len[depth]; ++i){ cur_move[depth] = history->move(color, step+depth, i); if( !board->can_put(cur_move[depth], color) || cur_move[depth] == temp_move[depth]) continue; board->put(cur_move[depth], color); //if(pv_found[depth] == true){ // if(color == role){ // value[depth] = estimation(opposite(color), depth+1, beta-1, beta); // if(value[depth] > alpha && value[depth] < beta){ // value[depth] = // estimation(opposite(color), depth+1, alpha, value[depth]); // } // } // else{ // value[depth] = estimation(opposite(color), depth+1, alpha, alpha+1); // if(value[depth] > alpha && value[depth] < beta){ // value[depth] = // estimation(opposite(color), depth+1, value[depth], beta); // } // } //} //else value[depth] = estimation(opposite(color), depth+1, alpha, beta); recover_all(depth); if( color == role){ if( value[depth] > alpha){ if( (alpha = value[depth]) >= beta){ history->advance_move(color, step+depth, i); hash->insert(alpha, color, H_LOW_BOUND, cur_move[depth], depth, step+depth); return alpha; } //(void)((pv_found[depth])? : pv_found[depth] = true); } if(value[depth] > result[depth]){ result[depth] = value[depth]; best_move[depth] = cur_move[depth]; } } else{ if(value[depth] < beta){ if( (beta = value[depth]) <= alpha){ history->advance_move(color, step+depth, i); hash->insert(beta, color, H_UP_BOUND, cur_move[depth], depth, step+depth); return beta; } //(void)((pv_found[depth])? : pv_found[depth] = true); } if(value[depth] < result[depth]){ result[depth] = value[depth]; best_move[depth] = cur_move[depth]; } } } hash->insert(result[depth], color, H_EXACT, best_move[depth], depth, step+depth); return result[depth]; }