int main(void) { bus_init(BUS_ADDRESS_CHASSIS); _delay_ms(100); engine_init(); regulator_init(); carrying_rfid = 0; handled_count = 0; manual_control = 0; scan_count = 0; lap_finished = 0; number_of_stations = 0; station_count = 0; // bus_register_receive(1, receive_line_data); bus_register_receive(2, arm_is_done); bus_register_receive(3, control_line_following); bus_register_receive(4, RFID_done); bus_register_receive(8, engine_control_command); bus_register_receive(11, engine_set_kp); bus_register_receive(12, engine_set_kd); sei(); start_button_init(); timer_interrupt_init(); while(1) { } }
double average_error(std::vector<std::pair<std::string, double>> positions, std::vector<std::string> options, double K, S16 limit, std::vector<S16> params) { //TODO: multithreading; Find all globals to make them private? double E = 0.0; int count = 0; engine_init(); engine_set_options(options, params); //#pragma omp parallel for private() for (size_t i = 0; i < positions.size(); ++i) { double R = positions[i].second; int_fast32_t eval = call_q_search(positions[i].first); if (i % 100000 == 0 && i != 0) std::cout << "Evaluated " << i << " positions out of " << positions.size() << ". " << count << " positions count." << std::endl; /*if (eval >= limit || eval <= -limit) continue;*/ double e1 = std::log(sigmoid(eval * K / 10000.0)), e2 = std::log(1.0 - sigmoid(eval * K / 10000.0)); if (std::isfinite(e1) && std::isfinite(e2)) { E += -R * e1 - (1.0 - R) * e2; //E += std::pow(R - 1.0 / (1.0 + std::pow(10.0, -K * eval / 400.0)), 2.0); ++count; } } E /= count; return E; }
int sk_detect_create() { int i; sk_detect_t* p_engine; /* * 设置参数 */ skdetect.debug = 0; char engine_name[5][20] = { "activation", "dynamic", "alert", "pass", "log" }; for(i=0; i<ENGINE_NUM; i++){ p_engine = &skdetect.engine[i]; if(engine_init(p_engine, engine_name[i])<0) return SK_ERR; } return 0; }
/** Main entry point for the game. I kept it as simple as I could. */ int main(int argc, char* argv[]) { global = new_globals(); config_handle(); /* Windows doesnt support getopt_long(). Ill need to work around this somehow */ #if !OS_IS_WINDOWS args_handle(argc, argv); #endif engine_init(); atexit(engine_exit); /* no need to call it when quitting */ game_s game = new_game(); engine_draw(&game); while (!game.quit) { int c = engine_get_input(game.speed); game_handle_input(&game, c); game_update(&game); if (game.is_over) game = new_game(); engine_draw(&game); } return EXIT_SUCCESS; }
bool engineInitSystem() { engine_shutdown(); if (!engine_init()) { // } initMapData(); #if defined(ARM_LINUX) loadGrammar(); registerCallback(); #endif g_navDisplay->initContext(); g_navDisplay->initViewport(); g_navDisplay->initDisplay(SCREEN_WIDTH,SCREEN_HEIGHT); LatLongGrid_Init(&g_latLongGrid); LatLongGrid_SetStep(&g_latLongGrid, 100000, 100000); gps_init(); #if defined(ARM_LINUX) gps_setContext(NMEA_CONTEXT_GPS); #else gps_setContext(NMEA_CONTEXT_MANUAL); #endif }
int main(int argc, char **argv) { // Default configuration that the engine will make use of struct Engine_Conf conf = { // Argument list argc, argv, // Window title "Allegro application", // Internal resolution 320, 200, // Scaling factor (<= 0 for auto) 0, // Frame-rate (FPS) 40, // Enable audio? FALSE }; if (engine_init(&conf)) { // Run with a starting state engine_run(Game_State()); } return 0; }
int main(int argc, char **argv) { struct Engine_Conf conf = { // Argument list argc, argv, // Window title "Allegro application", // Resolution 640, 480, // Refresh rate (or FPS) 40, // Color depth (8, 15, 16, 24, 32) 8, // Full-screen? FALSE, // Enable mouse? FALSE, // Enable audio? FALSE }; if (engine_init(&conf)) { // Run with a starting state engine_run(Game_State()); } return 0; }
static void msp_init (void) { if ((inits & ENGINE_INIT) && (inits & DB_INIT) && (inits & LOCK_INIT)) return; engine_init (); db_init (); lock_init (); }
int main(void) { struct json_object *cmd; engine_callback = main_callback; if (engine_init() < 0) exit(1); signal(SIGINT, stop_loop); loop_init(); initscr(); cbreak(); noecho(); keypad(stdscr, TRUE); win_body_lines = LINES - 8; // If you don't do this, the service config form won't be displayed while (win_body_lines % 4 != 3) win_body_lines--; win_body = newwin(win_body_lines + 2, COLS, 2, 0); box(win_body, 0 , 0); keypad(win_body, TRUE); win_header = newwin(2, COLS, 0, 0); win_footer = newwin(2, COLS, LINES-2, 0); // Print all windows, according to the man it's more efficient than 3 wnoutrefresh(win_header); wnoutrefresh(win_body); wnoutrefresh(win_footer); doupdate(); context.current_context = CONTEXT_HOME; context.serv = malloc(sizeof(struct userptr_data)); assert(context.serv != NULL); context.tech = malloc(sizeof(struct userptr_data)); assert(context.tech != NULL); // get_home_page (and render it) cmd = json_object_new_object(); json_object_object_add(cmd, key_command, json_object_new_string("get_home_page")); engine_query(cmd); loop_run(true); loop_terminate(); delwin(win_header); delwin(win_body); delwin(win_footer); endwin(); return 0; }
void gsm4_init( void ) { engine_init( gsm4_evn_default ); at_cmd_save( "RING", 1000, NULL, NULL, NULL, gsm4_ev_ring ); at_cmd( "AT" ); at_cmd( "AT+CSCS=\"GSM\"" ); at_cmd( "AT+CMGF=1" ); }
int main() { // Init components components_init(); // Load fonts f_small = font_load("font_small"); f_large = font_load("font_large"); // Load images img_blood = bmp_load("images/blood.bmp"); bmp_image *img_space = bmp_load("images/space.bmp"); bmp_image *img_ufo1 = bmp_load("images/ufo1.bmp"); bmp_image *img_ufo2 = bmp_load("images/ufo2.bmp"); bmp_image *img_ufo3 = bmp_load("images/ufo3.bmp"); bmp_image *img_ufo4 = bmp_load("images/ufo4.bmp"); bmp_image *img_ufo5 = bmp_load("images/ufo5.bmp"); bmp_image *img_rabby = bmp_load("rabbit.bmp"); bmp_image *img_powerup1 = bmp_load("images/pow1.bmp"); bmp_image *img_powerup2 = bmp_load("images/pow1.bmp"); bmp_image *img_powerup3 = bmp_load("images/pow1.bmp"); bmp_image *img_powerup4 = bmp_load("images/pow1.bmp"); bmp_image *img_rabby_red = bmp_copy(img_rabby); bmp_tint(img_rabby_red, 255, 128, 128); bmp_tint(img_powerup3, 0, 250, 29); bmp_tint(img_powerup2, 0, 0, 255); bmp_tint(img_powerup1, 255, 255, 29); // Create drawables space = drawable_create_bmp(img_space); ufo1 = drawable_create_bmp(img_ufo1); ufo2 = drawable_create_bmp(img_ufo2); ufo3 = drawable_create_bmp(img_ufo3); ufo4 = drawable_create_bmp(img_ufo4); ufo5 = drawable_create_bmp(img_ufo5); rabby = drawable_create_bmp(img_rabby); bullet = drawable_create_rect(4, 4, 255, 255, 255); rabby_red = drawable_create_bmp(img_rabby_red); power_sprite[0] = drawable_create_bmp(img_powerup1); power_sprite[1] = drawable_create_bmp(img_powerup2); power_sprite[2] = drawable_create_bmp(img_powerup3); power_sprite[3] = drawable_create_bmp(img_powerup4); // Start midi player in another thread pthread_t thread_midi; int result = pthread_create(&thread_midi, NULL, midi_run, NULL); // Loop game while (1) { engine_init(); init(); engine_run(); dispose(); engine_dispose(); } }
// Engine ---------------------------------------------------------------------- // ----------------------------------------------------------------------------- int engine_create(const int width, const int height, const int scale, const int fps) { engine = (struct Engine*)malloc(sizeof(struct Engine)); if (!engine_init(width, height, scale, fps)) { free(engine); return 1; } game_init(); // Main Loop, o'rly? int render_start = 0, render_diff = 0, render_wait = 0; int fps_count = 0, fps_time = 0; while (engine->running) { render_start = SDL_GetTicks(); engine_events(); if (key_pressed(SDLK_p)) { engine_pause(!engine->paused); } if (!engine->paused) { game_update(); } engine_clear_keys(); engine_clear_mouse(); game_render(engine->screen); SDL_Flip(engine->screen->bg); // Limit FPS render_diff = SDL_GetTicks() - render_start; if (render_diff > 0) { render_wait = engine->fps_wait - render_diff; if (render_wait > 0) { SDL_Delay(render_wait); } if (!engine->paused) { engine->time += SDL_GetTicks() - render_start; } } // Count FPS if (!engine->paused) { fps_count++; if (fps_count >= 10) { engine->fps_current = 1000 / ((engine->time - fps_time) / fps_count); fps_count = 0; fps_time = engine->time; } } } // Cleanup game_quit(); engine_cleanup(); return 0; }
int main (int argc, char* argv[]) { if (argc > 1) args_handle (argc, argv); if(tron.user_name[0] == 0) { char *tmp = getlogin(); if(tmp == NULL) { ifitron_abort("No username provided and attempts to fetch it automatically, failed.\n"); } strcpy(tron.user_name, tmp); } if(get_server_mode() == 2) { while(TRUE) { int result = play_multiplayer(); if(result == -1) break; } engine_exit(); ifitron_exit(); } if(client_host_addr != NULL) { //Connect to the server int sd = connect_to_server(); if(sd == -1) { ifitron_abort("Couldn't connect to the server.\n"); }else{ set_client_socket_descriptor(sd); } } engine_init (); engine_show_main_menu (); ifitron_init (); while (TRUE) { if (tron.is_alive == FALSE) ifitron_game_over (); engine_get_game_input(); player_update(get_tron()); player_increase_size (get_tron(), 1); player_increase_score (get_tron(), game.level); if (tron.score % 50 == 0 && game.level < 9) game.level++; if (player_hit_self(get_tron()) == TRUE || player_hit_borders(get_tron()) == TRUE) tron.is_alive = FALSE; engine_show_screen (); } return 0; }
/* ======================================= 获取引擎插件接口 ======================================= */ CR_API sENGINE* engine_syn (void_t) { sENGINE* engine; engine = engine_init(s_finda, s_findw, s_loada, s_loadw); if (engine == NULL) return (NULL); engine->fmtz_load = engine_syn_load; engine->info = "SYN FMTz Engine (Done by CrHackOS)"; return (engine); }
/* ======================================= 获取引擎插件接口 ======================================= */ CR_API sENGINE* engine_rar (void_t) { sENGINE* engine; engine = engine_init(NULL, NULL, NULL, NULL); if (engine == NULL) return (NULL); engine->fmtz_load = engine_rar_load; engine->info = "RAR FMTz Engine (Done by CrHackOS)"; return (engine); }
int main() { engine_init( 800, 600, "Snake", 100); engine_start(); engine_destroy(); }
void init_core(void) { config* config_handle = NULL; config_alloc(&config_handle, "config/core.cfg"); engine_init(config_get_int_value(config_handle, "enable_alarms")); global* global_handle = NULL; global_alloc(&global_handle); config_free(&config_handle); global_set(global_handle, GLOBAL_EDITOR_MODE, EDITOR_MODE_OFF); }
int main(int argc, char* argv[]) { const char* default_filename = "main.lua"; char* filename = NULL; const char* zipname = "game.zip"; int r; bool is_arg[argc]; int ziplen = strlen("--zip="); for (int i = 1; i < argc; i++) { is_arg[i] = false; if (!strncmp(argv[i], "--zip=", ziplen)) { zipname = argv[i] + ziplen; } else if (!filename) { filename = xstrdup(argv[i]); } else { is_arg[i] = true; } } if (!filename) { filename = xstrdup(default_filename); } else if (is_directory(filename)) { char* newfilename; if (endswith(filename, "/")) { newfilename = strjoin(filename, default_filename, NULL); } else { newfilename = strjoin(filename, "/", default_filename, NULL); } free(filename); filename = newfilename; } r = engine_init(filename, 60); if (r < 0) { return EXIT_FAILURE; } for (int i = 1; i < argc; i++) { if (is_arg[i]) { dlua_add_arg(argv[i]); } } log_info("Downloading %s...", zipname); emscripten_async_wget_data(zipname, NULL, on_zip_downloaded, on_zip_fail); emscripten_set_main_loop(loop, 0, true); return 0; }
int main(int argc, char* argv[]) { script_init(); load_ini(); engine_init(); // includes ttf init too vid_init(); dump_lua(); game_loop(); engine_shutdown(); script_shutdown(); return 0; }
Engine * engine_new( unsigned int w, unsigned int h, unsigned int iw, unsigned int ih ) { Engine * e = calloc( 1, sizeof(Engine) ); /*Setup things needed for the engine*/ e->dim_window[0] = w; e->dim_window[1] = h; e->dim_internal[0] = iw; e->dim_internal[1] = ih; engine_init( e ); return e; }
/*ARGSUSED*/ static void initialize(int argc, char *argv[]) { myname = uu_setpname(argv[0]); (void) atexit(lscf_cleanup); (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); (void) lxml_init(); internal_init(); engine_init(); lscf_init(); /* must follow engine_init() */ tmpl_init(); }
/* ======================================= 获取引擎插件接口 ======================================= */ CR_API sENGINE* engine_fmodex (void_t) { sENGINE* engine; engine = engine_init(NULL, NULL, NULL, NULL); if (engine == NULL) return (NULL); if (!fmodex_init()) { engine_free(engine); return (NULL); } engine->fmtz_load = engine_fmodex_load; engine->engine_free = engine_fmodex_free; engine->info = "FMODEx FMTz Engine (Done by CrHackOS)"; return (engine); }
int main( void ) { uint32_t dim_cl[2] = { 1024, 512 }; uint32_t dim_gl[2] = { 1024, 512 }; engine_init( dim_cl, dim_gl ); world_init( &engine.world ); while( 1 ) { if( engine_main() < 0 ) break; render_main(); } engine_destroy(); return EXIT_SUCCESS; }
/** The main function - contains the main loop of the game. * * * @note I tried to make this function as clear as possible, so anyone * could understaing the whole game logic starting by here. @n * Have fun with the source code! */ int main (int argc, char* argv[]) { if (argc > 1) args_handle (argc, argv); engine_init (); engine_show_main_menu (); nsnake_init (); while (TRUE == TRUE) { if (snake.is_alive == FALSE) nsnake_game_over (); engine_get_game_input (); player_update (); fruit_update_bonus (); if (player_hit_fruit () == TRUE) { // Is this score arbitrary? player_increase_score (game.level*3 + fruit.bonus); player_increase_size (2); fruit_init (); } if (player_hit_self () == TRUE) snake.is_alive = FALSE; if (player_collided_with_borders () == TRUE) snake.is_alive = FALSE; engine_show_screen (); } // Even though we have this here, the game always quits during // the main loop engine_exit (); nsnake_exit (); return 0; }
int main(int argc, char** argv) { printf("Loading Vitae.\n"); test_allocator(); init(argc, argv); // *** Initialise Engine engine* e = engine_create(); engine_init( e, argc, argv ); #if UNIT_TEST runTests(); #endif engine_run( e ); // Exit Gracefully return 0; }
int main(int argc, char** argv) { int rc; const char* port = "80"; struct engine* eng; while ((rc = getopt(argc, argv, "hp:")) != -1) { switch (rc) { case 'p': port = optarg; break; case 'h': usage(0); break; default: usage(2); break; } } if (pal_init(&pal)) return -1; eng = engine_init(&pal); rc = web_init(eng, port); if (rc) { LOG(("Web server failed to start: (%d) %s\n", rc, strerror(rc))); return rc; } LOG(("Running engine\n")); web_run(); engine_run(); web_destroy(); engine_destroy(); pal_destroy(&pal); LOG(("Exited gracefully\n")); return 0; }
/** Main entry point for the game. I kept it as simple as I could. */ int main(int argc, char* argv[]) { global = new_globals(); config_handle(); args_handle(argc, argv); engine_init(); atexit(engine_exit); /* no need to call it when quitting */ game_s game = new_game(); engine_draw(&game); while (!game.quit) { int c = engine_get_input(game.speed); game_handle_input(&game, c); game_update(&game); /* THIS WILL BE UNCOMMENTED SOON */ /* if (game.show_help) */ /* { */ /* engine_draw_help(); */ /* engine_wait_for_keypress(); */ /* game.show_help = false; */ /* } */ if (game.is_over) { game_over(&game); engine_draw_gameover(&game); engine_wait_for_keypress(); game = new_game(); } engine_draw(&game); } return EXIT_SUCCESS; }
int main(int argc, char **argv) { struct engine *engine = NULL; Display *dpy; int num; XSetWindowAttributes attr; unsigned long mask; Window root; Window win; XVisualInfo *info = NULL; GLXContext ctx = NULL; int conf[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GL_FALSE, GLX_DEPTH_SIZE, 1, None, }; dpy = XOpenDisplay(NULL); if (!dpy) { _err("failed to open X display\n"); return 1; } num = DefaultScreen(dpy); _inf("use GLX_SGIX_pbuffer on screen %d\n", num); root = RootWindow(dpy, num); info = glXChooseVisual(dpy, num, conf); if (!info) { _err("glXChooseVisual() failed\n"); goto out; } /* window attributes */ attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, info->visual, AllocNone); attr.event_mask = ButtonPressMask | ExposureMask | KeyPressMask; mask = CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow(dpy, root, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0, info->depth, InputOutput, info->visual, mask, &attr); ctx = glXCreateContext(dpy, info, NULL, GL_TRUE); if (!ctx) { _err("glXCreateContext() failed\n"); goto out; } XFree(info); info = NULL; XMapWindow(dpy, win); _msg("call glXMakeCurrent()\n"); glXMakeCurrent(dpy, win, ctx); _inf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); _inf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); _inf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); _inf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); _inf("GL_SHADING_LANGUAGE_VERSION = %s\n", (char *) glGetString(GL_SHADING_LANGUAGE_VERSION)); _msg("clear window\n"); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glXSwapBuffers(dpy, win); _msg("init engine\n"); if (engine_init(&engine, argc, argv) < 0) { _err("engine_init() failed\n"); goto out; } _msg("start engine\n"); engine_start(engine); glXSwapBuffers(dpy, win); engine_stop(engine); event_loop(dpy); _msg("exit engine\n"); engine_exit(&engine); out: glXMakeCurrent(dpy, 0, 0); if (info) XFree(info); if (ctx) glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); XCloseDisplay(dpy); return 0; }
int main() { char input[16]; int done = 0, state; if (!engine_init()) return 1; init_states(); while (!done) { state = read_keyword(input, sizeof(input)); if (state == 0) break; if (state == STATE_ERROR) continue; //fprintf(stderr, "cmd %s state %d\n", input, state); switch (state) { case STATE_BLACK: engine_set_color(BLACK); break; case STATE_WHITE: engine_set_color(WHITE); break; case STATE_CGCBOARD: write_string("\n"); break; case STATE_DRAW: engine_offer_draw(); break; case STATE_FORCE: engine_set_go(0); break; case STATE_GO: engine_set_go(1); break; case STATE_NEW: engine_new(); break; case STATE_RANDOM: engine_set_random(!engine_get_random()); break; case STATE_RESULT: if (!handle_result()) done = 1; break; case STATE_REMOVE: engine_undo(); engine_undo(); break; case STATE_QUIT: write_string("bye\n"); done = 1; break; case STATE_SD: if (!handle_sd()) done = 1; break; case STATE_UNDO: engine_undo(); break; case STATE_MOVE: engine_move(str_to_move(input)); break; case STATE_PLAY: engine_go(); break; } } engine_destroy(); return 0; }
int main(int argc, char* argv[]) { bool finished; int ch; engine_t engine; /* Initialize */ rand_init(); /* must be called before engine_init () */ engine_init(&engine, score_function); /* must be called before using engine.curshape */ finished = shownext = FALSE; memset(shapecount, 0, NUMSHAPES * sizeof(int)); shapecount[engine.curshape]++; parse_options(argc,argv); /* must be called after initializing variables */ if (level < MINLEVEL) { choose_level(); } io_init(); drawbackground(); in_timeout(DELAY); /* Main loop */ do { /* draw shape */ showstatus(&engine); drawboard(engine.board); out_refresh(); /* Check if user pressed a key */ if ((ch = in_getch ()) != ERR) { switch (ch) { case 'j': case KEY_LEFT: engine_move(&engine,ACTION_LEFT); break; case 'k': case '\n': engine_move(&engine,ACTION_ROTATE); break; case 'l': case KEY_RIGHT: engine_move(&engine,ACTION_RIGHT); break; case ' ': case KEY_DOWN: engine_move(&engine,ACTION_DROP); break; /* show next piece */ case 's': shownext = TRUE; break; /* toggle dotted lines */ case 'd': dottedlines = !dottedlines; break; /* next level */ case 'a': case KEY_UP: if (level < MAXLEVEL) { level++; in_timeout(DELAY); } else out_beep(); break; /* quit */ case 'q': finished = TRUE; break; /* pause */ case 'p': out_setcolor(COLOR_WHITE,COLOR_BLACK); out_gotoxy((out_width() - 34) / 2,out_height() - 2); out_printf("Paused - Press any key to continue"); while ((ch = in_getch ()) == ERR) ; /* Wait for a key to be pressed */ in_flush(); /* Clear keyboard buffer */ out_gotoxy((out_width() - 34) / 2, out_height() - 2); out_printf(" "); break; /* unknown keypress */ default: out_beep(); } in_flush(); } else { switch (engine_evaluate(&engine)) { /* game over (board full) */ case -1: if ((level < MAXLEVEL) && ((engine.status.droppedlines / 10) > level)) level++; finished = TRUE; break; /* shape at bottom, next one released */ case 0: if ((level < MAXLEVEL) && ((engine.status.droppedlines / 10) > level)) { level++; in_timeout(DELAY); } shapecount[engine.curshape]++; break; /* shape moved down one line */ case 1: break; } } } while (!finished); /* Restore console settings and exit */ io_close(); /* Don't bother the player if he want's to quit */ if (ch != 'q') { showplayerstats(&engine); savescores(GETSCORE(engine.score)); } exit(EXIT_SUCCESS); }