int main() { load_board(); flip(); return 0; }
bool restart_game(void) { // reload current game if (!load_board()) return false; // redraw board draw_grid(); draw_numbers(); copy_board(); // get window's dimensions int maxy, maxx; getmaxyx(stdscr, maxy, maxx); // move cursor to board's center g.y = g.x = 4; show_cursor(); // remove log, if any remove("log.txt"); // w00t return true; }
/* Initialize structures. Load all boards. */ void load_boards () { int i; for (i = 0; i < MAX_BOARD; i++) load_board (&boards[i]); }
/* * Initialize structures. Load all boards. */ void load_notes( void ) { int i; for ( i = 0; i < MAX_BOARD; i++ ) load_board( &board_table[i] ); return; }
int init_quiz() { int i, k=0; char ans[4]; load_board(); while (1) { clear(); move(2,20); setfcolor(WHITE,0); prints("开心词典测试中心("); setfcolor(RED,1); prints("HAPPYQUIZ"); setfcolor(WHITE,0); prints(")测试版0.1"); move(3,40); prints("作者: "); setfcolor(RED,0); prints("*****@*****.**"); move(5,28); setfcolor(WHITE,1); prints("===排行榜(%d--%d)===", k*10+1, k*10+10); move(6,22); setfcolor(RED,1); prints("╭──────────────╮"); for (i=0;i<10;i++) { move(7+i, 22); setfcolor(RED,1); prints("│"); if (i+k*10>=topn) { move(7+i, 34); setfcolor(GREEN,1); prints("--空--"); } else { char p[100]; move(7+i, 24); setfcolor(GREEN,1); sprintf(p, "%3d %-12s %4d", i+1+k*10, topid[i+k*10], topscore[i+k*10]); prints("%s", p); } move(7+i, 52); setfcolor(RED,1); prints("│"); } move(17,22); setfcolor(RED,1); prints("╰──────────────╯"); resetcolor(); getdata(19, 22, "开始游戏(Y-开始,N-退出)", ans, 3, 1, NULL, 1); if (toupper(ans[0])=='Y') return 1; if (toupper(ans[0])=='N') return 0; k++; if (k>=10) k=0; } }
static void sudoku_init(void) { Sudoku_Class = 1; cur_col = 0; cur_row = 0; do{ load_board(); }while(Sudoku_Class!=game_class+1); }
static void sudoku_start(void) { do{ load_board(); }while(Sudoku_Class!=game_class+1); sudoku_draw_board(); cur_row = 0; cur_col = 0; sudoku_draw_cursor(cur_row, cur_col); }
int main() // int argc, char* argv) { init_stats(&stats); board_t* board = new_board(); if (false == load_board(board)) { printf("bad board\n"); } else { printf("loaded board:\n"); print_board(board); solve_board(board); } // print_board(board); return 0; }
ChineseChess::ChineseChess() { dir_path="files/game/chessMaster/game/chineseChess/"; game_name="chineseChess"; board_size=math::vec2<int>(9,9); init_drawobject(); create_pieces(); load_board(dir_path+"chessBoard/board.txt"); cube_type_num=21; tex_path="chineseChess/board_textures"; normal_path="chineseChess/board_normals"; dboard->init_drawObject("",tex_path,normal_path,true); if(rule)delete rule; rule=new CM::ChineseChessRule(); load_mct(); table_pos.set_pos(glm::vec3(0.5*chess_board->sizex,-6,0.5*chess_board->sizey)); //rule->load_rule(rule_path); }
int check_top(int score) { int i,j,lasttopn; lasttopn = topn; load_board(); if (topn<lasttopn) return -1; for (i=0;i<topn;i++) if (!strcmp(topid[i],getCurrentUser()->userid)) { if (score<=topscore[i]) return 0; topn--; for (j=i;j<topn;j++) { strcpy(topid[j],topid[j+1]); topscore[j] = topscore[j+1]; } i--; } for (i=0;i<topn;i++) { if (score>topscore[i]) { if (topn<100) topn++; for (j=topn-1;j>i;j--) { strcpy(topid[j], topid[j-1]); topscore[j] = topscore[j-1]; } strcpy(topid[i], getCurrentUser()->userid); topscore[i] = score; return 1; } } if (topn<100) { strcpy(topid[topn], getCurrentUser()->userid); topscore[topn] = score; topn++; return 1; } return 0; }
int main (int argc, char* argv[]) { /* * Set verifyp to 1 if you want to turn on verification. */ const int verifyp = DO_VERIFY; const int argc_min = 3; const int argc_max = 4; int gens_max = 0; char* inboard = NULL; char* outboard = NULL; char* checkboard = NULL; char* final_board = NULL; int nrows = 0; int ncols = 0; FILE* input = NULL; FILE* output = NULL; int err = 0; /* Parse command-line arguments */ if (argc < argc_min || argc > argc_max) { fprintf (stderr, "*** Wrong number of command-line arguments; " "got %d, need at least %d and no more than %d ***\n", argc - 1, argc_min - 1, argc_max - 1); print_usage (argv[0]); exit (EXIT_FAILURE); } err = to_int (&gens_max, argv[1]); if (err != 0) { fprintf (stderr, "*** <num_generations> argument \'%s\' " "must be a nonnegative integer! ***\n", argv[1]); print_usage (argv[0]); exit (EXIT_FAILURE); } /* Open input and output files */ input = fopen (argv[2], "r"); if (input == NULL) { fprintf (stderr, "*** Failed to open input file \'%s\' for reading! ***\n", argv[2]); print_usage (argv[0]); exit (EXIT_FAILURE); } if (argc < argc_max || 0 == strcmp (argv[3], "-")) output = stdout; else { output = fopen (argv[3], "w"); if (output == NULL) { fprintf (stderr, "*** Failed to open output file \'%s\' for writing! ***\n", argv[3]); print_usage (argv[0]); exit (EXIT_FAILURE); } } /* Load the initial board state from the input file */ inboard = load_board (input, &nrows, &ncols); fclose (input); /* Create a second board for ping-ponging */ outboard = make_board (nrows, ncols); /* If we want to verify the result, then make a third board and copy the initial state into it */ if (verifyp) { checkboard = make_board (nrows, ncols); copy_board (checkboard, inboard, nrows, ncols); } /* * Evolve board gens_max ticks, and time the evolution. You will * parallelize the game_of_life() function for this assignment. */ copy_board (outboard, inboard, nrows, ncols); final_board = game_of_life (outboard, inboard, nrows, ncols, gens_max); /* Print (or save, depending on command-line argument <outfilename>) the final board */ save_board (output, final_board, nrows, ncols); if (output != stdout && output != stderr) fclose (output); if (verifyp) { /* Make sure that outboard has the final state, so we can verify it. Since we ping-pong between inboard and outboard, it could be either that inboard == final_board or that outboard == final_board */ copy_board (outboard, final_board, nrows, ncols); /* Ping-pong between checkboard (contains the initial state) and inboard */ final_board = sequential_game_of_life (inboard, checkboard, nrows, ncols, gens_max); if (boards_equalp (final_board, outboard, nrows, ncols)) printf ("Verification successful\n"); else { fprintf (stderr, "*** Verification failed! ***\n"); exit (EXIT_FAILURE); } } /* Clean up */ if (inboard != NULL) free (inboard); if (outboard != NULL) free (outboard); if (checkboard != NULL) free (checkboard); return 0; }