static int cmd_analyze_cube(int argc, char *argv[]){ int i, j; cube_t cube; cube_info_t info; cube.face[CUBE_FRONT].word = word_ren; cube.face[CUBE_RIGHT].word = word_cong; cube.face[CUBE_BACK].word = word_he; cube.face[CUBE_LEFT].word = word_hai; cube.face[CUBE_UP].word = word_love; cube.face[CUBE_DOWN].word = word_orange; memset(&info, 0, sizeof(info)); analyze_cube(&cube, &info); for(i = 0; i < 21; ++i){ printf("face type %2u count = ", i); for(j = 0; j < 7; ++j){ printf("%u, ", info.type_count[j][i]); } printf("\n"); } print_cube(&cube); return 0; }
void print_cover(pset_family F, char *name) { pcube last, p; printf("%s:\t %d\n",name,F->count); foreach_set(F,last,p){ print_cube(stdout,p,"~0"); }
void shift_cube(uint8_t iterations) { int8_t it, lat, lay; for(it = 0; it < iterations; it++) { for(lay = 0; lay < 8; lay++) { for(lat = 0; lat < 7; lat++) { cube[lay][lat + 1] = cube[lay][lat]; } cube[lay][0] = 0x00; } printf("\n=================\n"); print_cube(8, 8, 8); } }
static void draw(void) { GLfloat mat[16], projection[16]; struct cube c; /* Set modelview/projection matrix */ matrix_make_unity(mat); matrix_rotate_x(view_rotx, mat); matrix_rotate_y(view_roty, mat); matrix_rotate_z(view_rotz, mat); matrix_translate(0.0, 0.0, view_transz, mat); matrix_scale(view_scale, view_scale, view_scale, mat); matrix_make_projection(0.9, projection); //print_matrix(mat); glUniformMatrix4fv(u_projection, 1, GL_FALSE, projection); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); start_cube(); int a; for (a = 0; a < N_CUBES; a++) { // print_cube(&cubes[a]); update_cube(&cubes[a]); draw_a_cube(&cubes[a], mat); printf("a=%d\n",a); print_cube(&cubes[a]); } /* GLfloat i,j,k; #define LOW -4.0 #define HIGH 4.0 #define STEP 2.0 for (i = LOW; i < HIGH; i += STEP) { for (j = LOW; j < HIGH; j += STEP) { for (k = HIGH+10.0; k > LOW+10.0; k -= STEP) { draw_cube(i, j, k, 0.0, 0.0, 0.0, 1.0, mat); } } } #undef LOW #undef HIGH #undef STEP */ end_cube(); #undef N }
int main(int argc, char *argv[]) { const int winWidth = 300, winHeight = 300; Display *x_dpy; Window win; EGLSurface egl_surf; EGLContext egl_ctx; EGLDisplay egl_dpy; char *dpyName = NULL; GLboolean printInfo = GL_FALSE; EGLint egl_major, egl_minor; int i; const char *s; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-display") == 0) { dpyName = argv[i+1]; i++; } else if (strcmp(argv[i], "-info") == 0) { printInfo = GL_TRUE; } else { usage(); return -1; } } x_dpy = XOpenDisplay(dpyName); if (!x_dpy) { printf("Error: couldn't open display %s\n", dpyName ? dpyName : getenv("DISPLAY")); return -1; } egl_dpy = eglGetDisplay(x_dpy); if (!egl_dpy) { printf("Error: eglGetDisplay() failed\n"); return -1; } if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { printf("Error: eglInitialize() failed\n"); return -1; } s = eglQueryString(egl_dpy, EGL_VERSION); printf("EGL_VERSION = %s\n", s); s = eglQueryString(egl_dpy, EGL_VENDOR); printf("EGL_VENDOR = %s\n", s); s = eglQueryString(egl_dpy, EGL_EXTENSIONS); printf("EGL_EXTENSIONS = %s\n", s); s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); printf("EGL_CLIENT_APIS = %s\n", s); make_x_window(x_dpy, egl_dpy, "OpenGL ES 2.x tri", 0, 0, winWidth, winHeight, &win, &egl_ctx, &egl_surf); XMapWindow(x_dpy, win); if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { printf("Error: eglMakeCurrent() failed\n"); return -1; } if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); } init(); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glDepthRangef(0.2f, 0.99f); glClearDepthf(0.999f); for (i = 0; i < N_CUBES; i++) { print_cube(&cubes[i]); init_cube(&cubes[i], 3.0, N_CUBES_FAR); print_cube(&cubes[i]); } /* Set initial projection/viewing transformation. * We can't be sure we'll get a ConfigureNotify event when the window * first appears. */ reshape(winWidth, winHeight); event_loop(x_dpy, win, egl_dpy, egl_surf); eglDestroyContext(egl_dpy, egl_ctx); eglDestroySurface(egl_dpy, egl_surf); eglTerminate(egl_dpy); XDestroyWindow(x_dpy, win); XCloseDisplay(x_dpy); return 0; }
void main() { send_char2(str_fly[0]); print_cube(8, 8, 8); shift_cube(8); }
void jungle_run(t_cube *cube, int cur, int depth, t_jungle *jgl, int *moves, int maxdepth, int maxface) { int i; int j; int rnbr; int rpn[18] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; if (depth < maxdepth) { j = 0; // while (j < 18) // { // rnbr = (rand() % 180000) / 10000; // swap(&rpn[rnbr], &rpn[17 - rnbr]); // j++; // } // j = 0; i = 0; // while (j < 18) while (i < 18) { // i = rpn[j]; if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 || i == 16) { i++; // j++; // continue; }else { moves[depth] = i; printf("\n");//!ST===================================================\n"); for (int k = 0;k < 18;k++) printf("[%s%s%s] ", (jgl->bl[k]) ? (g_color_FU[6 - jgl->bl[k]]) : "", (jgl->bl[k]) ? ft_itoa(jgl->bl[k]) : " \x1B[0m", "\x1B[0m"); printf("!ST==================================================="); printf("CURRENT: %d\tDEPTH:%d\tIter: %d\n", cur, depth, i); // print_cube(cube, 0); // if (moves[depth]) if (jgl->bl[i] == 2 || i == g_trees[cur]) { for (int k = 0; k < 18;k++) jgl->bl[k] = 0; jgl->bl[i] = (g_trees[cur] != i) ? 0 : 2; } else { if (jgl->bl[i] == 1) { // printf("SECOND CALL_SECOND CALL_SECOND CALL_SECOND CALL_SECOND CALLSECOND CALL_SECOND CALL_SECOND CALL_SECOND CALL_SECOND CALL\n"); // usleep(1500000); for (int k = 0; k < 18;k++) jgl->bl[k] = 0; jgl->bl[g_trees[cur]] = 2; jgl->bl[i] = 2; } else { for (int k = 0; k < 18;k++) jgl->bl[k] = 0; jgl->bl[g_trees[cur]] = 2; jgl->bl[i] = 1; } // usleep(8400); jgl->cct[i]->bl = jgl->bl; cube = rotate_side(cube, g_jungle_combo[i][0], g_jungle_combo[i][1], g_jungle_combo[i][2]); if (jungle_check(cube, maxface) >= maxface) { printf("$$$$$$$$$$$$$$$$$$$$$$$$JJJJJJJJJJJJJACCCCCCCKKKKKKKPPPPPPPPPOOOOOOTTTTTT$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); print_cube(cube, 0); printf("===================================================\n"); printf("RUNNING TEST\n"); printf("CURRENT: %d\tDEPTH:%d\tIter: %d\n", cur, depth, i); for (int k = 0;k < 18;k++) printf("[%d] ", jgl->bl[k]); printf("++=================================++\n"); for (int k = 0;k < depth + 1;k++) printf("%s ", g_jungle_ans[moves[k]]); printf("++MOVES\n"); usleep(500000); // exit(0); } // print_cube(cube, 0); jungle_run(cube, i, depth + 1, jgl->cct[i], moves, maxdepth, maxface); // for (int k = 0;k < 18;k++) // moves[k] = 0; // moves[i] = 0; cube = rotate_side(cube, g_jungle_combo[g_trees[i]][0], g_jungle_combo[g_trees[i]][1], g_jungle_combo[g_trees[i]][2]); } // j++; i++; } } } return ; }
int main(int argc, char **argv) { int index1,index2; CUBE F,R,D; CUBE W; /*this will store the original ON-set function*/ CUBE V; /*this will store the espresso expand output*/ /*in case of improper invocation*/ if(argc != 4) { printf("Please check the usage:\n"); printf("Usage: ./logic_min <input_file> <file_flag> <output_file\n"); printf("Example ./logic_min input_file -e\n"); exit(0); } /*parse the input file and build up the ON-set, *OFF-set and dont-care set*/ read_inputs_from_file(&F,&R,&D,argv[1]); /*preserve org onset function*/ cube_copy(&W, &F); /*call the expand function*/ expand(&F,&R); /*printing party*/ printf("\nJust after Espresso Expand and before logic_min\n"); printf("\n**********************************************\n"); printf("\nThe ON set is %d %d\n",F.rows,F.cols); print_cube(&F); printf("\n"); printf("\nThe OFF set is %d %d\n",R.rows,R.cols); print_cube(&R); printf("\n"); printf("\nThe DONT CARE set is %d %d\n",D.rows,D.cols); print_cube(&D); printf("\n"); printf("\n**********************************************\n"); /*preserve the espresso expand output*/ cube_copy(&V, &F); /*logic minimization routine*/ logic_min(&F); /*parse the command line argument to check what type of * output file needs to be generated*/ if (strcmp(argv[2],"-e") == 0) { text_file_output(&W, &V, &R, &D,argv[3], ESPEXP_TEXT_OUTPUT); } else if (strcmp(argv[2],"-t") == 0) { text_file_output(&W, &F, &R, &D,argv[3], OPT_TEXT_OUTPUT); } else if (strcmp(argv[2],"-v") == 0) { verilog_file_output(&F, argv[3]); } else { printf("Invalid flag.\n"); } }/*end of main*/