int main(int argc, char *argv[]) { #if defined(RPI2) enable_rpi2_jtag_pin(); #endif #ifdef LINUX signal(SIGALRM, check_timer_list); struct itimerval stTimer, ovalue; stTimer.it_value.tv_sec = 0; stTimer.it_value.tv_usec = 1000; stTimer.it_interval.tv_sec = 0; stTimer.it_interval.tv_usec = 1000; setitimer(ITIMER_REAL, &stTimer, &ovalue); #endif init_eval(); Environment *global_env = get_env(0, "global"); create_primitive_procedure(global_env); #if defined(P103) || defined(RPI2) || defined(STM32F407) || defined(X86_16) || defined(UEFI) non_os_repl("simple scheme> ", global_env); #else REPL("simple scheme> ", global_env); #endif return 0; }
void EvalBezierCurveVec3d( fp_t *cp, vec3d_t out, float t, int order ) { float s, powert; int i, k, bincoeff; init_eval(); // fixme if ( order >= 2 ) { bincoeff = order - 1; s = 1.0 - t; for ( k = 0; k < 3; k++ ) out[k] = s*cp[k] + bincoeff*t*cp[3+k]; for ( i = 2, cp+=2*3, powert=t*t; i < order; i++, powert*=t, cp+=3 ) { bincoeff *= order-i; bincoeff *= inv_tab[i]; for( k = 0; k<3; k++ ) out[k] = s*out[k] + bincoeff*powert*cp[k]; } } else { for ( k = 0; k < 3; k++ ) out[k] = cp[k]; } }
int main(int argc, char *argv[]) { // Disable IO buffering setbuf(stdin, NULL); setbuf(stdout, NULL); std::cout.rdbuf()->pubsetbuf(NULL, 0); std::cin.rdbuf()->pubsetbuf(NULL, 0); // Initialization init_mersenne(); init_direction_table(); init_bitboards(); init_uci_options(); Position::init_zobrist(); Position::init_piece_square_tables(); MaterialInfo::init(); MovePicker::init_phase_table(); init_eval(1); init_bitbases(); init_threads(); // Make random number generation less deterministic, for book moves int i = abs(get_system_time() % 10000); for(int j = 0; j < i; j++) genrand_int32(); // Process command line arguments if(argc >= 2) { if(std::string(argv[1]) == "bench") { if(argc != 4) { std::cout << "Usage: glaurung bench <hash> <threads>" << std::endl; exit(0); } benchmark(std::string(argv[2]), std::string(argv[3])); return 0; } } // Print copyright notice std::cout << engine_name() << ". " << "Copyright (C) 2004-2008 Tord Romstad." << std::endl; // Enter UCI mode uci_main_loop(); return 0; }
int main() { int i; curve_ctrl_t *cc; curve_points_t *p; surface_ctrl_t *sc; surface_points_t *sp; surface_points_t *nmesh; init_eval(); #if 0 cc = NewBezierCurve( 3 ); SetCurveCtrlPoint3f( cc, 0, 3,3,0 ); SetCurveCtrlPoint3f( cc, 1, 0,3,0 ); SetCurveCtrlPoint3f( cc, 2, 0,0,0 ); p = EvalCurvePoints( cc, 10 ); for ( i = 0; i < p->pointnum; i++ ) { printf( "%f %f %f\n", p->p[i][0], p->p[i][1], p->p[i][2] ); } FreeCurvePoints( p ); FreeBezierCurve( cc ); #else sc = NewBezierSurface( 2, 2 ); SetSurfaceCtrlPoint3f( sc, 0,0, 0,0,0 ); SetSurfaceCtrlPoint3f( sc, 1,0, 1,0,0 ); SetSurfaceCtrlPoint3f( sc, 1,1, 1,1,0 ); SetSurfaceCtrlPoint3f( sc, 0,1, 0,1,0 ); sp = EvalSurfacePoints( sc, 10, 10 ); nmesh = EvalSurfaceNormals( sp ); for ( i = 0; i < 100; i++ ) { printf( "%f %f %f\n", nmesh->p[i][0], nmesh->p[i][1], nmesh->p[i][2] ); } FreeSurfacePoints( sp ); FreeBezierSurface( sc ); #endif }
Application::Application() { init_mersenne(); init_direction_table(); init_bitboards(); init_uci_options(); Position::init_zobrist(); Position::init_piece_square_tables(); init_eval(1); init_bitbases(); init_search(); init_threads(); // Make random number generation less deterministic, for book moves for (int i = abs(get_system_time() % 10000); i > 0; i--) genrand_int32(); }
void game_init( const char *file_name, int *side_to_move ) { setup_game( file_name, side_to_move ); setup_search(); setup_midgame(); setup_end(); init_eval(); clear_ponder_times(); reset_counter( &total_nodes ); reset_counter( &total_evaluations ); init_flip_stack(); total_time = 0.0; max_depth_reached = 0; last_time_used = 0.0; endgame_performed[BLACKSQ] = endgame_performed[WHITESQ] = FALSE; }
t_chess_value calc_evaluation(struct t_board *board, struct t_chess_eval *eval) { //-- Normal Position, so initialize the values init_eval(eval); //-- Is it a king & pawn endgame if (board->pawn_hash == board->hash) { eval->static_score = calc_king_pawn_endgame(board, eval); return eval->static_score; } t_chess_value score; eval->king_zone[WHITE] = king_zone[board->king_square[WHITE]]; eval->king_zone[BLACK] = king_zone[board->king_square[BLACK]]; //-- Are we in the middle game, endgame or somewhere in between calc_game_phase(board, eval); //-- What are the strengths / weaknesses of the pawn structure calc_pawn_value(board, eval); //-- How well placed are the pieces calc_piece_value(board, eval); //-- How dangerous are the passed pawns calc_passed_pawns(board, eval); //-- Is the king in danger calc_king_safety(board, eval); //-- Scale the score and adjust for color to move score = (1 - 2 * board->to_move) * (((eval->middlegame * eval->game_phase) + (eval->endgame * (256 - eval->game_phase))) / 256); //-- Store the score eval->static_score = score; return score; }
void test_lambda_simple() { init_eval(); Cell *lambda = alloc_cell(); Cell *a = alloc_cell(); Cell *code = get_one_plus_two(); set_car_ptr(lambda, LAMBDA_CELL, NULL); set_cdr_ptr(lambda, LIST_CELL, a); set_car_ptr(a, SYMBOL_CELL, g_strdup("a")); set_cdr_ptr(a, LIST_CELL, code); eval(lambda); Cell *ptr = g_hash_table_lookup(symbol_table, g_strdup("a")); g_assert(code == ptr); Cell *a2 = alloc_cell(); set_car_ptr(a2, SYMBOL_CELL, g_strdup("a")); Cell *result = eval(a2); g_assert_cmpint(result->car.type, ==, INTEGER_CELL); g_assert_cmpint(result->car.data.int_value, ==, 3); }
/* ARGSUSED */ int main (int argc, char **argv, char **envp) { int skip_args = 0; #ifdef HAVE_PERSONALITY_LINUX32 /* See if there is a gap between the end of BSS and the heap. In that case, set personality and exec ourself again. */ if (!initialized && strcmp (argv[argc-1], "dump") == 0 && !getenv ("EMACS_HEAP_EXEC")) { /* Set this so we only do this once. */ putenv ("EMACS_HEAP_EXEC=true"); /* A flag to turn off address randomization which is introduced in linux kernel shipped with fedora core 4 */ personality (PER_LINUX32 | ADDR_NO_RANDOMIZE); execvp (argv[0], argv); /* If the exec fails, try to dump anyway. */ perror ("execvp"); } #endif /* HAVE_PERSONALITY_LINUX32 */ /* Map in shared memory, if we are using that. */ #ifdef HAVE_SHM if (argc > 1 && !strcmp (argv[1], "-nl")) { map_in_data (0); /* The shared memory was just restored, which clobbered this. */ skip_args = 1; } else { map_in_data (1); /* The shared memory was just restored, which clobbered this. */ skip_args = 0; } #endif #ifdef VMS /* If -map specified, map the data file in */ if (argc > 2 && ! strcmp (argv[1], "-map")) { skip_args = 2; mapin_data (argv[2]); } #ifdef LINK_CRTL_SHARE #ifdef SHAREABLE_LIB_BUG /* Bletcherous shared libraries! */ if (!stdin) stdin = fdopen (0, "r"); if (!stdout) stdout = fdopen (1, "w"); if (!stderr) stderr = fdopen (2, "w"); if (!environ) environ = envp; #endif /* SHAREABLE_LIB_BUG */ #endif /* LINK_CRTL_SHARE */ #endif /* VMS */ /* 92.11.4, 93.2.17 by M.Higashida */ #if defined(MSDOS) && defined(EMX) environ = envp; #endif #ifdef WIN32 environ = envp; #endif /* end of patch */ #ifdef USG_SHARED_LIBRARIES if (bss_end) brk (bss_end); #endif #ifdef NeXT extern int malloc_cookie; /* This helps out unexnext.c. */ if (initialized) { if (malloc_jumpstart (malloc_cookie) != 0) fatal("malloc jumpstart failed!\n"); } else { emacszone = NXCreateZone(ZONESIZE*vm_page_size,vm_page_size,1); if(emacszone == NX_NOZONE) fatal("can't create emacs zone.\n"); } #endif /* NeXT */ clearerr (stdin); #ifdef APOLLO #ifndef APOLLO_SR10 /* If USE_DOMAIN_ACLS environment variable exists, use ACLs rather than UNIX modes. */ if (egetenv ("USE_DOMAIN_ACLS")) default_acl (USE_DEFACL); #endif #endif /* APOLLO */ #ifndef SYSTEM_MALLOC /* Arrange for warnings when nearly out of space. */ malloc_init (0, malloc_warning); #endif /* 91.10.16 by S.Hirano */ #if defined(MSDOS) && defined(GO32) _fmode = O_BINARY; /* all of files are treated as binary files */ (stdin)->_flag &= ~_IOTEXT; /* also binary for stdio */ (stdout)->_flag &= ~_IOTEXT; (stderr)->_flag &= ~_IOTEXT; #endif /* MSDOS */ /* end of patch */ #ifdef HIGHPRI setpriority (PRIO_PROCESS, getpid (), HIGHPRI); setuid (getuid ()); #endif inhibit_window_system = 0; /* 92.3.31 by K.Handa, 92.10.21 by M.Higashida */ #if defined (HAVE_X_WINDOWS) || defined (HAVE_SUN_CONSOLE) || (defined(MSDOS) && defined(HAVE_VGA_ADAPTER)) || defined (WIN32) xargv = argv; xargc = argc; #endif /* Handle the -t switch, which specifies filename to use as terminal */ if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t")) { skip_args += 2; close (0); close (1); open (argv[skip_args], O_RDWR, 2 ); dup (0); fprintf (stderr, "Using %s\n", argv[skip_args]); /* 92.3.31 by K.Handa, 92.10.21 by M.Higashida */ #if defined (HAVE_X_WINDOWS) || defined (HAVE_SUN_CONSOLE) || (defined(MSDOS) && defined(HAVE_VGA_ADAPTER)) || defined (WIN32) inhibit_window_system = 1; /* -t => -nw */ #endif } #ifdef HAVE_X_WINDOWS /* Handle the -d switch, which means use a different display for X */ if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-d") || !strcmp (argv[skip_args + 1], "-display"))) { skip_args += 2; alternate_display = argv[skip_args]; } else alternate_display = 0; #endif /* HAVE_X_WINDOWS */ /* 92.3.31 by K.Handa */ #ifdef HAVE_SUN_CONSOLE if (skip_args + 1 < argc && (!strcmp (argv[skip_args + 1], "-sun"))) { extern Pixrect *screen; inhibit_window_system = -1; skip_args++; alternate_display = "/dev/fb"; if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-fb"))) { skip_args += 2; alternate_display = argv[skip_args]; } if (screen = pr_open(alternate_display)) /* Just a test. */ pr_close(screen); else alternate_display = 0; } #endif /* HAVE_SUN_CONSOLE */ /* end of patch */ /* 92.10.17, 93.2.17 by M.Higashida */ #if defined(MSDOS) && defined(HAVE_VGA_ADAPTER) if (skip_args + 1 < argc && (!strcmp (argv[skip_args + 1], "-vga"))) { inhibit_window_system = -1; skip_args++; } #endif /* MSDOS and HAVE_VGA_ADAPTER */ #ifdef WIN32 inhibit_window_system = -1; #endif /* end of patch */ if (skip_args + 1 < argc && (!strcmp (argv[skip_args + 1], "-nw"))) { skip_args += 1; inhibit_window_system = 1; } /* Handle the -batch switch, which means don't do interactive display. */ noninteractive = 0; if (skip_args + 1 < argc && !strcmp (argv[skip_args + 1], "-batch")) { skip_args += 1; noninteractive = 1; } #ifdef POSIX_SIGNALS init_signals (); #endif #ifdef HAVE_TZSET /* Reinitialize the time zone if it was initialized before dumping Emacs. */ if (initialized) tzset (); #endif #ifdef WIN32 /* 93.2.25 by M.Higashida */ _tzset (); #endif if ( #ifndef CANNOT_DUMP ! noninteractive || initialized #else 1 #endif ) { /* Don't catch these signals in batch mode if not initialized. On some machines, this sets static data that would make signal fail to work right when the dumped Emacs is run. */ /* 91.10.16 by S.Hirano, 92.11.4 by M.Higashida */ #ifdef MSDOS #ifdef GO32 /* Nothing */ #else #ifdef EMX signal (SIGBREAK, fatal_error_signal); signal (SIGQUIT, fatal_error_signal); #endif #endif #else /* not MSDOS */ signal (SIGHUP, fatal_error_signal); signal (SIGQUIT, fatal_error_signal); signal (SIGILL, fatal_error_signal); signal (SIGTRAP, fatal_error_signal); signal (SIGIOT, fatal_error_signal); #ifdef SIGEMT signal (SIGEMT, fatal_error_signal); #endif signal (SIGFPE, fatal_error_signal); signal (SIGBUS, fatal_error_signal); signal (SIGSEGV, fatal_error_signal); signal (SIGSYS, fatal_error_signal); signal (SIGTERM, fatal_error_signal); #ifdef SIGXCPU signal (SIGXCPU, fatal_error_signal); #endif #ifdef SIGXFSZ signal (SIGXFSZ, fatal_error_signal); #endif #endif /* not MSDOS and GO32 */ /* end of patch */ #ifdef AIX /* This used to run fatal_error_signal, but it isn't fatal. There's nothing Emacs can usefully do. Might as well let the system kill us if it insists. */ signal (SIGDANGER, SIG_IGN); signal (20, fatal_error_signal); signal (21, fatal_error_signal); signal (22, fatal_error_signal); signal (23, fatal_error_signal); signal (24, fatal_error_signal); #ifdef SIGIO signal (SIGAIO, fatal_error_signal); signal (SIGPTY, fatal_error_signal); #endif #ifdef SIGURG /* Note that SIGIOINT is the same as SIGIO on some machines, and the same as SIGURG on others. It seems ore reliable to use the name with a uniform meaning. */ signal (SIGURG, fatal_error_signal); #endif signal (SIGGRANT, fatal_error_signal); signal (SIGRETRACT, fatal_error_signal); signal (SIGSOUND, fatal_error_signal); signal (SIGMSG, fatal_error_signal); #endif /* AIX */ } noninteractive1 = noninteractive; /* Perform basic initializations (not merely interning symbols) */ if (!initialized) { init_alloc_once (); init_obarray (); init_eval_once (); init_mc_once (); /* 89.7.26, 91.10.19 by K.Handa */ init_syntax_once (); /* Create standard syntax table. */ init_category_once (); /* 91.12.7 by K.Handa */ /* Must be done before init_buffer */ init_buffer_once (); /* Create buffer table and some buffers */ init_minibuf_once (); /* Create list of minibuffers */ /* Must precede init_window_once */ init_window_once (); /* Init the window system */ /* 92.10.28 by M.Higashida */ #if defined (MSDOS) && defined (HAVE_VGA_ADAPTER) init_bdf_once (); /* Init the BDF font structure. */ #endif /* end of patch */ } init_alloc (); #ifdef MAINTAIN_ENVIRONMENT init_environ (); /* 92.3.25 by N.Hikichi */ #ifdef HAVE_X_WINDOWS if (alternate_display) set_environment_alist (build_string ("DISPLAY"), build_string (alternate_display)); #endif /* HAVE_X_WINDOWS */ /* end of patch */ #endif init_codeconv (); /* 92.1.7 by K.Handa */ init_eval (); init_data (); init_read (); init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */ init_buffer (); /* Init default directory of main buffer */ if (!noninteractive) { #ifdef VMS init_vms_input ();/* init_display calls get_screen_size, that needs this */ #endif /* VMS */ init_display (); /* Determine terminal type. init_sys_modes uses results */ } init_keyboard (); /* This too must precede init_sys_modes */ init_callproc (); /* And this too. */ init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.) */ init_xdisp (); init_macros (); init_editfns (); #ifdef VMS init_vmsfns (); #endif /* VMS */ #ifdef subprocesses init_process (); #endif /* subprocesses */ /* Intern the names of all standard functions and variables; define standard keys */ if (!initialized) { /* The basic levels of Lisp must come first */ /* And data must come first of all for the sake of symbols like error-message */ syms_of_data (); syms_of_alloc (); #ifdef MAINTAIN_ENVIRONMENT syms_of_environ (); #endif /* MAINTAIN_ENVIRONMENT */ syms_of_read (); syms_of_print (); syms_of_eval (); syms_of_fns (); syms_of_abbrev (); syms_of_buffer (); syms_of_bytecode (); syms_of_callint (); syms_of_casefiddle (); syms_of_callproc (); syms_of_category (); /* 91.11.11 by K.Handa */ syms_of_codeconv (); /* 92.1.7 by K.Handa */ syms_of_cmds (); #ifndef NO_DIR_LIBRARY syms_of_dired (); #endif /* not NO_DIR_LIBRARY */ syms_of_display (); syms_of_doc (); syms_of_editfns (); syms_of_emacs (); syms_of_fileio (); #ifdef CLASH_DETECTION syms_of_filelock (); #endif /* CLASH_DETECTION */ /* 92.11.1 by M.Higashida */ #ifdef FILE_TRANSLATION_MODE syms_of_transmode (); #endif /* FILE_TRANSLATION_MODE */ /* end of patch */ syms_of_indent (); syms_of_keyboard (); syms_of_keymap (); syms_of_macros (); syms_of_marker (); syms_of_minibuf (); syms_of_mocklisp (); #ifdef subprocesses syms_of_process (); #endif /* subprocesses */ syms_of_search (); syms_of_syntax (); syms_of_undo (); syms_of_window (); syms_of_xdisp (); #ifdef HAVE_X_WINDOWS syms_of_xfns (); #ifdef HAVE_X_MENU syms_of_xmenu (); #endif /* HAVE_X_MENU */ #endif /* HAVE_X_WINDOWS */ /* 87.6.8, 91.11.2, 92.3.31, 92.7.31 by K.Handa, 92.10.17, 93.2.17 by M.Higashida */ #ifdef HAVE_SUN_CONSOLE syms_of_sunterm (); #endif #if defined(MSDOS) && defined(HAVE_VGA_ADAPTER) syms_of_vgaterm (); #endif #ifdef WIN32 syms_of_win32term (); #endif syms_of_mc (); syms_of_ccl (); /* 93.5.14 by K.Handa */ #ifdef WNN4 syms_of_wnn (); #endif #ifdef CANNA syms_of_canna (); #endif /* CANNA */ /* end of patch */ #ifdef MCPATH syms_of_mcpath (); #endif /* MCPATH */ #ifdef SYMS_SYSTEM SYMS_SYSTEM; #endif #ifdef SYMS_MACHINE SYMS_MACHINE; #endif keys_of_casefiddle (); keys_of_cmds (); keys_of_buffer (); keys_of_keyboard (); keys_of_keymap (); keys_of_macros (); keys_of_minibuf (); keys_of_window (); } if (!initialized) { /* Handle -l loadup-and-dump, args passed by Makefile. */ if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l")) Vtop_level = Fcons (intern ("load"), Fcons (build_string (argv[2 + skip_args]), Qnil)); #ifdef CANNOT_DUMP /* Unless next switch is -nl, load "loadup.el" first thing. */ if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl"))) Vtop_level = Fcons (intern ("load"), Fcons (build_string ("loadup.el"), Qnil)); #endif /* CANNOT_DUMP */ } initialized = 1; /* Enter editor command loop. This never returns. */ Frecursive_edit (); /* NOTREACHED */ }
int mcpp_lib_main #else int main #endif ( int argc, char ** argv ) { char * in_file = NULL; char * out_file = NULL; char * stdin_name = "<stdin>"; if (setjmp( error_exit) == -1) { errors++; goto fatal_error_exit; } #if MCPP_LIB /* Initialize global and static variables. */ init_main(); init_directive(); init_eval(); init_support(); init_system(); #endif fp_in = stdin; fp_out = stdout; fp_err = stderr; fp_debug = stdout; /* * Debugging information is output to stdout in order to * synchronize with preprocessed output. */ inc_dirp = &null; /* Initialize to current (null) directory */ cur_fname = cur_fullname = "(predefined)"; /* For predefined macros */ init_defines(); /* Predefine macros */ mb_init(); /* Should be initialized prior to get options */ do_options( argc, argv, &in_file, &out_file); /* Command line options */ /* Open input file, "-" means stdin. */ if (in_file != NULL && ! str_eq( in_file, "-")) { if ((fp_in = fopen( in_file, "r")) == NULL) { mcpp_fprintf( ERR, "Can't open input file \"%s\".\n", in_file); errors++; #if MCPP_LIB goto fatal_error_exit; #else return( IO_ERROR); #endif } } else { in_file = stdin_name; } /* Open output file, "-" means stdout. */ if (out_file != NULL && ! str_eq( out_file, "-")) { if ((fp_out = fopen( out_file, "w")) == NULL) { mcpp_fprintf( ERR, "Can't open output file \"%s\".\n", out_file); errors++; #if MCPP_LIB goto fatal_error_exit; #else return( IO_ERROR); #endif } fp_debug = fp_out; } if (option_flags.q) { /* Redirect diagnostics */ if ((fp_err = fopen( "mcpp.err", "a")) == NULL) { errors++; mcpp_fprintf( OUT, "Can't open \"mcpp.err\"\n"); #if MCPP_LIB goto fatal_error_exit; #else return( IO_ERROR); #endif } } init_sys_macro(); /* Initialize system-specific macros */ add_file( fp_in, NULL, in_file, in_file, FALSE); /* "open" main input file */ infile->dirp = inc_dirp; infile->sys_header = FALSE; cur_fullname = in_file; if (mkdep && str_eq( infile->real_fname, stdin_name) == FALSE) put_depend( in_file); /* Putout target file name */ at_start(); /* Do the pre-main commands */ mcpp_main(); /* Process main file */ if (mkdep) put_depend( NULL); /* Append '\n' to dependency line */ at_end(); /* Do the final commands */ fatal_error_exit: #if MCPP_LIB /* Free malloced memory */ if (mcpp_debug & MACRO_CALL) { if (in_file != stdin_name) free( in_file); } clear_filelist(); clear_symtable(); #endif if (fp_in != stdin) fclose( fp_in); if (fp_out != stdout) fclose( fp_out); if (fp_err != stderr) fclose( fp_err); if (mcpp_debug & MEMORY) print_heap(); if (errors > 0 && option_flags.no_source_line == FALSE) { mcpp_fprintf( ERR, "%d error%s in preprocessor.\n", errors, (errors == 1) ? "" : "s"); return IO_ERROR; } return IO_SUCCESS; /* No errors */ }
void EvalBezierSurfaceVec3d( fp_t *cn, vec3d_t out, fp_t u, fp_t v, int uorder, int vorder ) { float *cp; int i, uinc; init_eval(); // fixme cp = cn+uorder*vorder*3; uinc = vorder*3; if ( vorder > uorder ) { if ( uorder >= 2 ) { float s, poweru; int j, k, bincoeff; for ( j = 0; j < vorder; j++ ) { float *ucp; ucp = &cn[j*3]; bincoeff = uorder - 1; s = 1.0 - u; for ( k = 0; k < 3; k++ ) cp[j*3+k] = s*ucp[k] + bincoeff*u*ucp[uinc+k]; for ( i = 2, ucp += 2*uinc, poweru = u*u; i < uorder; i++, poweru *= u, ucp += uinc ) { bincoeff *= uorder-i; bincoeff *= inv_tab[i]; for ( k = 0; k < 3; k++ ) cp[j*3+k] = s*cp[j*3+k] + bincoeff*poweru*ucp[k]; } } EvalBezierCurveVec3d( cp, out, v, vorder ); } else { EvalBezierCurveVec3d( cn, out, v, vorder ); } } else { if ( vorder > 1 ) { int i; for ( i = 0; i < uorder; i++, cn += uinc ) { EvalBezierCurveVec3d( cn, &cp[i*3], v, vorder ); } EvalBezierCurveVec3d( cp, out, u, uorder ); } else { EvalBezierCurveVec3d( cn, out, u, uorder ); } } }
BOOL test_eval() { struct t_chess_eval eval[1]; t_chess_value v; BOOL ok = TRUE; init_eval(eval); set_fen(position, "1k6/8/8/5PP1/3Pp2p/P7/8/4K3 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "1k6/8/8/4b3/8/3B4/K7/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "4r3/pbrq1p1k/1p3Bpp/3p1n2/3PPPQ1/P6R/1P4PP/1B3RK1 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "4r3/pbrq1p1k/1p2pBpp/3p1n2/3PPPQ1/P6R/1P4PP/1B3RK1 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "r5k1/pq2pn2/3pN1pp/n2P4/1rp1PQ2/1P3PP1/PN4K1/2R4R w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/5p1k/6p1/8/2PK4/p7/P5P1/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/8/7k/2R1Q1n1/1pRp4/8/2B5/5K2 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "3K4/6p1/2P5/3P4/7k/8/1B4B1/5N2 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/6k1/2p5/7K/N7/2N5/PPPP1PPP/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "3b2k1/ppp4p/4P1p1/2n1p2b/2B4B/2PP4/PP2N1PP/4K3 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "5k2/p1pK3p/1p2Q1p1/5Pq1/4P3/8/P5P1/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "4rbk1/pp3ppp/2p5/q1n2P2/2PRn2P/2N2Q2/PP2B1P1/1K5R b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "2kr1b1r/pppbqpp1/2n5/1B1pP2p/P2Pn3/5N2/1PN2PPP/R1BQ1RK1 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "r1bq1b1r/ppp3pp/4k3/3Np3/2B5/P4Q2/1P1P1PPP/n1BK3R b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "r2q1rk1/2pb1p1p/pp1bpPp1/4n1P1/1n2P3/2N1BN1Q/P1P4P/2KR1B1R b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/6pp/6p1/Pp6/1P6/1PK5/4P1k1/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); //-- Pawn Chain set_fen(position, "r7/5pp1/5p1k/2pPp3/1pP4P/pP1B1KPN/P4P2/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/2k5/1pP5/1P6/K7/8/8/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "5k2/8/8/7P/8/7K/8/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "6k1/8/7K/7P/8/8/8/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/6k1/8/3P4/1K6/8/8/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "2k5/2P1K3/1p6/1P6/8/8/8/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "r2r2k1/ppp4p/4p1p1/2B1Nb2/1PN2P2/3P2P1/P1P4P/5K2 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "1NQ5/k1p1p3/7p/pP2P1P1/2P5/2pq4/1n6/6K1 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "r1b1k3/1pq2pp1/p3p3/4p1Q1/3N2p1/1NP3Pr/PPP3Pb/R1BR3K w q -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "7k/6p1/K3p3/2P5/1P3r2/8/2R5/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); //-- B & P Endgame set_fen(position, "8/4k3/8/8/6KP/8/5B2/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/4k3/8/8/6KP/8/4B3/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/2k5/8/8/6KP/8/4B3/8 b - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/2k5/8/8/7P/8/4B3/6K1 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/3k4/8/8/6P1/8/4B3/6K1 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "8/8/8/k7/6P1/8/4B3/6K1 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); set_fen(position, "7k/8/8/7P/4B3/5K2/7P/8 w - -"); v = evaluate(position, eval); flip_board(position); ok &= (v == evaluate(position, eval)); return ok; }