static SCM game_run (SCM game_smob) { Game *game = check_game (game_smob); if (scm_is_true (game->on_start)) { scm_call_0 (game->on_start); } al_start_timer (game->timer); game->last_update_time = al_get_time (); while (game->running) { game_process_event (game); if (game->redraw && al_is_event_queue_empty (game->event_queue)) { game->redraw = false; game_draw (game); } } game_destroy (game); return SCM_UNSPECIFIED; }
static void print_move_path(const struct game *original_game, const move *m, enum move_notation_type mn) { char str[MOVE_STR_BUFFER_LENGTH]; bool first = true; struct game *g = game_copy(original_game); if (g == NULL) INTERNAL_ERROR(); for (; *m != 0; ++m) { if (!is_uci) { if (game_turn(g) == white || first) printf("%u. ", game_full_move_count(g)); if (first && game_turn(g) == black) printf("... "); } first = false; (void) print_move(game_current_position(g), *m, str, mn, game_turn(g)); printf("%s ", str); if (game_append(g, *m) != 0) INTERNAL_ERROR(); } game_destroy(g); }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); setup_board_every_gem_different (game); int **old_board = copy_board (game); int m = game->n_rows; int n = game->n_cols; replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 2, 1999999); replace_gem (game, 4, 2, 999999); int i; for (i = 0; i < 50 * 2; ++i) { game_loop (game); } for (i = 0; i < m; ++i) { fail_if (game->board[3][i] == old_board[3][i]); } for (i = 0; i < n; ++i) { if (i == 3) continue; fail_if (game->board[i][1] != old_board[i][0]); fail_if (game->board[i][0] == old_board[i][0]); } setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 3, 1999999); replace_gem (game, 2, 4, 999999); for (i = 0; i < 50 * 2; ++i) { game_loop (game); } for (i = 0; i < m; ++i) { fail_if (game->board[2][i] == old_board[2][i]); } for (i = 0; i < n; ++i) { if (i == 2) continue; fail_if (game->board[i][1] != old_board[i][0]); fail_if (game->board[i][0] == old_board[i][0]); } game_destroy (game); return 0; }
extern int d2cs_gamelist_destroy(void) { t_game * game; BEGIN_LIST_TRAVERSE_DATA(gamelist_head, game, t_game) { game_destroy(game,&curr_elem_); }
extern int gamelist_destroy(void) { t_game * game; BEGIN_LIST_TRAVERSE_DATA(gamelist_head, game) { game_destroy(game); }
int main (int argc, char *argv[]) { GAME *game = game_init (); game_loop (game); game_destroy (game); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { game_t *game = game_create (); fail_if (game->state != SPLASH_STATE); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); fail_if (game->frame != 0); game_destroy (game); return 0; }
int main(int argc, char *argv[]) { game_init(); while (!quit_flag) { game_event(&event); game_loop(); game_render(); } game_destroy(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { game *g = game_init(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); if (g != NULL) { game_prepare(g); game_main_loop(g); game_destroy(g); } else { error_message("fail to create game object"); } return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game->board = (int**)malloc (sizeof (int*) * 8); int i, j; for (i = 0; i < 8; ++i) { game->board[i] = (int*)malloc (sizeof (int) * 8); for (j = 0; j < 8; ++j) { game->board[i][j] = -1; } } game->n_gem_types = 4; gem_t *gem = (gem_t*)malloc (sizeof (gem_t)); gem->x = 0; gem->y = 0; gem->type = 0; gem->level = 0; game_add_gem (game, gem); fail_if (game->n_gems != 1); gem = (gem_t*)malloc (sizeof (gem_t)); gem->x = 24; gem->y = 48; gem->type = 2; gem->level = 3; game_add_gem (game, gem); fail_if (game->n_gems != 2); game_swap_gems (game, 0, 0, 1, 2); fail_if (game->board[0][0] != 14); fail_if (game->board[1][2] != 0); for (i = 0; i < game->n_gems; ++i) { gem_t *gem = game->gems[i]; if (gem->x / 24 == 0 && gem->y / 24 == 0) { fail_if (gem->type != 2 || gem->level != 3); } if (gem->x / 24 == 1 && gem->y / 24 == 2) { fail_if (gem->type != 0 || gem->level != 0); } } game_destroy (game); return 0; }
int main(int argc, char *argv[]) { struct timeval start_time; gettimeofday(&start_time, NULL); Game *game = game_init(start_time); while(1) { game_tick(game); } game_destroy(game); return 0; }
int main(int argc, const char **argv) { prog_argc = argc; prog_argv = argv; init_zhash_table(); run_tests(); if (g != NULL) game_destroy(g); }
int main(){ clear_tty(); srand(time(NULL)); int frame_left1 = 3; char *cd1[] = {"w","a","d","s","p"}; int frame_left2 = 42; char *cd2[] = {"i","j","l","k","p"}; GAME_UI *ui1 = ui_init(frame_left1, cd1); GAME *game1 = game_init(ui1); ui1->game = game1; GAME_UI *ui2 = ui_init(frame_left2, cd2); GAME *game2 = game_init(ui2); ui2->game = game2; int size = 0; PRESS_HANDLER handlers[20]; bind_press_handlers(game1, cd1, handlers, &size); bind_press_handlers(game2, cd2, handlers, &size); game_begin(game1); game_begin(game2); key_press_loop(handlers, size); game_destroy(game1); game_destroy(game2); ui_destroy(ui1); ui_destroy(ui2); reset_tty(); return 0; }
int main( int argc, char *argv[] ) { Uint32 FPS_MAX = 1000 / 63; // 60 fps game_init(); while ( quit_flag == false ) { game_event( &event ); game_loop(); game_render(); SDL_Delay( FPS_MAX ); } game_destroy(); return EXIT_SUCCESS; }
int game_launch(void) { gint status; GGZGame *game = ggzcore_server_get_cur_game(ggz_gtk.server); /* Launch game */ if ((status = ggzcore_game_launch(game) < 0)) { msgbox(_("Failed to execute game module.\n Launch aborted."), _("Launch Error"), MSGBOX_OKONLY, MSGBOX_STOP, MSGBOX_NORMAL); game_destroy(); return -1; } return 0; }
int main(int argc, char *argv[]) { game *g; regular_message("loading..."); if (!main_init_allegro_library()) { error_message("fail to init allegro library"); return 1; } g = game_init(); if (g != NULL) { game_prepare(g); game_main_loop(g); game_destroy(g); main_close_allegro_library(); return 0; } else { return 1; } }
static void cmd_new(void) { callback_key++; stop_thinking(); mtx_lock(&game_mutex); game_destroy(game); if ((game = game_create()) == NULL) INTERNAL_ERROR(); reset_engine(current_position()); debug_engine_set_player_to_move(turn()); computer_side = black; set_thinking_done_cb(computer_move, ++callback_key); unset_search_depth_limit(); if (!(is_xboard || is_uci)) puts("New game - computer black"); game_started = false; is_force_mode = false; mtx_unlock(&game_mutex); }
static void cmd_setboard(void) { struct game *g; if (game_started) return; g = game_create_fen(xstrtok_r(NULL, "\n\r", &line_lasts)); if (g == NULL) { (void) fprintf(stderr, "Unable to parse FEN\n"); return; } mtx_lock(&game_mutex); game_destroy(game); game = g; reset_engine(current_position()); debug_engine_set_player_to_move(turn()); mtx_unlock(&game_mutex); }
int main (int argc, char *argv[]) { game_t *game = game_create (); fail_if (game->state != SPLASH_STATE); bool gets_to_menu = false; int i; for (i = 0; i < 50 * 30; ++i) { game_loop (game); if (game->state == MENU_STATE) { gets_to_menu = true; break; } } fail_if (!gets_to_menu); game->key_states[SDLK_ESCAPE] = true; game_loop (game); fail_if (game->state != QUIT_STATE); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); int n = game->n_rows; int m = game->n_cols; int i; game->n_gem_types = 1000000; // #@$%# ##### // #...# #@#%# // ##.## -> ##$## // ##.## ##.## // ##### ##### setup_board_every_gem_different (game); int **old_board = copy_board (game); replace_gem (game, 1, 1, 999999); replace_gem (game, 2, 1, 999999); replace_gem (game, 3, 1, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 3, 999999); bool old_ones_dropped = false; bool special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[2][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][1] == old_board[1][0] && game->board[2][2] == old_board[2][0] && game->board[3][1] == old_board[3][0] && game->board[1][0] != old_board[1][0] && game->board[2][1] != old_board[2][1] && game->board[2][0] != old_board[2][0] && game->board[3][0] != old_board[3][0]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); // #@### ##### // #.$%# ##### // #...# -> #@$%# // #.### #.### // ##### ##### setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 1, 1, 999999); replace_gem (game, 1, 2, 999999); replace_gem (game, 1, 3, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 2, 999999); old_ones_dropped = false; special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[1][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][2] == old_board[1][0] && game->board[2][2] == old_board[2][1] && game->board[3][2] == old_board[3][1] && game->board[1][0] != old_board[1][0] && game->board[1][1] != old_board[1][1] && game->board[2][0] != old_board[2][0] && game->board[2][1] != old_board[2][1] && game->board[3][0] != old_board[3][0] && game->board[3][1] != old_board[3][1]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); // ##$## ##### // ##.## ##### // #@.%# -> ##$## // #...# #@.%# // ##### ##### setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 1, 3, 999999); replace_gem (game, 2, 3, 999999); replace_gem (game, 3, 3, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 1, 999999); old_ones_dropped = false; special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[2][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][3] == old_board[1][2] && game->board[2][2] == old_board[2][0] && game->board[3][3] == old_board[3][2] && game->board[1][0] != old_board[1][0] && game->board[1][1] != old_board[1][1] && game->board[1][2] != old_board[1][2] && game->board[2][1] != old_board[2][1] && game->board[2][0] != old_board[2][0] && game->board[2][1] != old_board[2][1] && game->board[3][0] != old_board[3][0] && game->board[3][1] != old_board[3][1] && game->board[3][2] != old_board[3][2]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); // ###%# ##### // #@$.# ##### // #...# -> #@$%# // ###.# ###.# // ##### ##### setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 1, 2, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 1, 999999); replace_gem (game, 3, 2, 999999); replace_gem (game, 3, 3, 999999); old_ones_dropped = false; special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[3][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][2] == old_board[1][1] && game->board[2][2] == old_board[2][1] && game->board[3][2] == old_board[3][0] && game->board[1][0] != old_board[1][0] && game->board[1][1] != old_board[1][1] && game->board[2][0] != old_board[2][0] && game->board[2][1] != old_board[2][1] && game->board[3][0] != old_board[3][0] && game->board[3][1] != old_board[3][1]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); game_destroy (game); return 0; }
/* GdkDestroyNotify function for server fd */ static void game_input_removed(gpointer data) { game_destroy(); }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); int n = game->n_rows; int m = game->n_cols; int i; int j; int k; setup_board_every_gem_different (game); int **old_board = copy_board (game); game->n_gem_types = 1000000; replace_gem (game, 0, n-1, 999999); replace_gem (game, 1, n-1, 999999); replace_gem (game, 2, n-1, 999999); replace_gem (game, m-1, n-1, 999999); replace_gem (game, m-2, n-1, 999999); replace_gem (game, m-3, n-1, 999999); bool old_ones_dropped_1 = false; bool old_ones_dropped_2 = false; game_loop_n (game, 100); old_ones_dropped_1 = true; for (k = 0; k < 3; ++k) { for (j = 1; j < n; ++j) { if (game->board[k][j] != old_board[k][j-1]) { old_ones_dropped_1 = false; } } } old_ones_dropped_2 = true; for (k = m-3; k < m; ++k) { for (j = 1; j < n; ++j) { if (game->board[k][j] != old_board[k][j-1]) { old_ones_dropped_1 = false; } } } fail_if (!old_ones_dropped_1 || !old_ones_dropped_2); bool new_gems_1 = false; bool new_gems_2 = false; if (game->board[0][0] != old_board[0][0] || game->board[1][0] != old_board[1][0] || game->board[2][0] != old_board[2][0]) { new_gems_1 = true; } if (game->board[m-3][0] != old_board[m-3][0] || game->board[m-2][0] != old_board[m-2][0] || game->board[m-1][0] != old_board[m-1][0]) { new_gems_2 = true; } fail_if (!new_gems_1 || !new_gems_2); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); int **old_board = NULL; old_board = setup_board (game); game->board_cursor_x = 2; game->board_cursor_y = 4; game->board[3][4] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_RIGHT); release_key_and_loop (game, SDLK_RIGHT); wait (game, 50 * 2); fail_if (!success (old_board, game, 3, 4, 2, 4)); old_board = setup_board (game); game->board_cursor_x = 3; game->board_cursor_y = 4; game->board[3][4] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_LEFT); release_key_and_loop (game, SDLK_LEFT); wait (game, 50 * 2); fail_if (!success (old_board, game, 2, 4, 3, 4)); old_board = setup_board (game); game->board_cursor_x = 2; game->board_cursor_y = 4; game->board[2][5] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_DOWN); release_key_and_loop (game, SDLK_DOWN); wait (game, 50 * 2); fail_if (!success (old_board, game, 2, 5, 2, 4)); old_board = setup_board (game); game->board_cursor_x = 2; game->board_cursor_y = 5; game->board[2][5] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_UP); release_key_and_loop (game, SDLK_UP); wait (game, 50 * 2); fail_if (!success (old_board, game, 2, 4, 2, 5)); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (game); game_start (game); // Swapping to or from outside of the board is illegal fail_if (session_legal_move (game, 0, 0, -1, 0)); fail_if (session_legal_move (game, 0, 0, 0, -1)); fail_if (session_legal_move (game, game->n_cols - 1, 0, game->n_cols, 0)); fail_if (session_legal_move (game, game->n_cols - 1, 0, game->n_cols - 1, -1)); fail_if (session_legal_move (game, 0, game->n_rows - 1, 0, game->n_rows)); fail_if (session_legal_move (game, 0, game->n_rows - 1, -1, game->n_rows - 1)); fail_if (session_legal_move (game, game->n_cols - 1, game->n_rows - 1, game->n_cols - 1, game->n_rows)); fail_if (session_legal_move (game, game->n_cols - 1, game->n_rows - 1, game->n_cols, game->n_rows - 1)); // Swapping non-adjacent locations is illegal fail_if (session_legal_move (game, 0, 0, 1, 1)); fail_if (session_legal_move (game, 1, 1, 0, 0)); fail_if (session_legal_move (game, 3, 2, 0, 1)); fail_if (session_legal_move (game, 5, 4, 2, 2)); // Swap and neither location is part of row or col of 3 or more game->n_gem_types = 1000000; setup_board_every_gem_different (game); // Since every location is different, there can be no legal moves int i, j; for (i = 0; i < game->n_cols; ++i) { for (j = 0; j < game->n_rows; ++j) { fail_if (session_legal_move (game, i, j, i - 1, j)); fail_if (session_legal_move (game, i, j, i, j - 1)); fail_if (session_legal_move (game, i, j, i + 1, j)); fail_if (session_legal_move (game, i, j, i, j + 1)); } } // Swap into a row of three // On bottom setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[2][3] = 999999; game->board[2][4] = 0; game->board[3][4] = 999999; fail_if (!session_legal_move (game, 2, 4, 3, 4)); fail_if (!session_legal_move (game, 3, 4, 2, 4)); // In middle setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[2][3] = 0; game->board[2][4] = 1999999; game->board[3][3] = 999999; fail_if (!session_legal_move (game, 2, 3, 3, 3)); fail_if (!session_legal_move (game, 3, 3, 2, 3)); // On top setup_board_every_gem_different (game); game->board[2][2] = 0; game->board[2][3] = 999999; game->board[2][4] = 2999999; game->board[3][2] = 999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swap into a col of three // On right setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[3][2] = 3999999; game->board[4][2] = 0; game->board[4][3] = 999999; fail_if (!session_legal_move (game, 4, 2, 4, 3)); fail_if (!session_legal_move (game, 4, 3, 4, 2)); // In middle setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 0; game->board[4][2] = 999999; game->board[3][3] = 999999; fail_if (!session_legal_move (game, 3, 2, 3, 3)); fail_if (!session_legal_move (game, 3, 3, 3, 2)); // On left setup_board_every_gem_different (game); game->board[2][2] = 0; game->board[3][2] = 999999; game->board[4][2] = 999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); // Swapping a special1 with a special1 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 1999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 1999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special1 with a special2 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 2999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special2 with a special2 setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[3][2] = 2999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special1 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special2 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special3 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 3999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 3999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); game_destroy (game); return 0; }