10 #define GO_THROUGH_ALL_PARAMETERS_BY_FOO \
11 for ( i=0; i < nsquare*pos_n; i++ ) { Foo( pc_on_sq[0][i] ) } \
12 for ( i=0; i < nsquare*nsquare*kkp_end; i++ ) { Foo( kkp[0][0][i] ) }
15 static void rmt( const double avalue[16], int pc );
16 static void rparam( short *pv, float dv );
17 static void fv_sym( void );
18 static int brand( void );
19 static int make_list( const tree_t * restrict ptree, int list0[52],
20 int list1[52], int anpiece[16], param_t * restrict pd,
25 ini_param( param_t *p )
29 p->pawn = p->lance = p->knight = p->silver = 0.0;
30 p->gold = p->bishop = p->rook = p->pro_pawn = 0.0;
31 p->pro_lance = p->pro_knight = p->pro_silver = p->horse = 0.0;
34 #define Foo(x) p->x = 0;
35 GO_THROUGH_ALL_PARAMETERS_BY_FOO;
41 add_param( param_t *p1, const param_t *p2 )
46 p1->lance += p2->lance;
47 p1->knight += p2->knight;
48 p1->silver += p2->silver;
50 p1->bishop += p2->bishop;
52 p1->pro_pawn += p2->pro_pawn;
53 p1->pro_lance += p2->pro_lance;
54 p1->pro_knight += p2->pro_knight;
55 p1->pro_silver += p2->pro_silver;
56 p1->horse += p2->horse;
57 p1->dragon += p2->dragon;
59 #define Foo(x) p1->x += p2->x;
60 GO_THROUGH_ALL_PARAMETERS_BY_FOO;
66 fill_param_zero( void )
70 p_value[15+pawn] = 100;
71 p_value[15+lance] = 300;
72 p_value[15+knight] = 300;
73 p_value[15+silver] = 400;
74 p_value[15+gold] = 500;
75 p_value[15+bishop] = 600;
76 p_value[15+rook] = 700;
77 p_value[15+pro_pawn] = 400;
78 p_value[15+pro_lance] = 400;
79 p_value[15+pro_knight] = 400;
80 p_value[15+pro_silver] = 500;
81 p_value[15+horse] = 800;
82 p_value[15+dragon] = 1000;
85 GO_THROUGH_ALL_PARAMETERS_BY_FOO;
88 set_derivative_param();
93 param_sym( param_t *p )
95 int q, r, il, ir, ir0, jl, jr, k0l, k0r, k1l, k1r;
97 for ( k0l = 0; k0l < nsquare; k0l++ ) {
100 k0r = q*nfile + nfile-1-r;
101 if ( k0l > k0r ) { continue; }
103 for ( il = 0; il < fe_end; il++ ) {
104 if ( il < fe_hand_end ) { ir0 = il; }
106 q = ( il- fe_hand_end ) / nfile;
107 r = ( il- fe_hand_end ) % nfile;
108 ir0 = q*nfile + nfile-1-r + fe_hand_end;
111 for ( jl = 0; jl <= il; jl++ ) {
112 if ( jl < fe_hand_end )
118 q = ( jl - fe_hand_end ) / nfile;
119 r = ( jl - fe_hand_end ) % nfile;
120 jr = q*nfile + nfile-1-r + fe_hand_end;
128 if ( k0l == k0r && il*(il+1)/2+jl >= ir*(ir+1)/2+jr ) { continue; }
130 p->PcPcOnSq(k0l,il,jl)
131 = p->PcPcOnSq(k0r,ir,jr)
132 = p->PcPcOnSq(k0l,il,jl) + p->PcPcOnSq(k0r,ir,jr);
137 for ( k0l = 0; k0l < nsquare; k0l++ ) {
140 k0r = q*nfile + nfile-1-r;
141 if ( k0l > k0r ) { continue; }
143 for ( k1l = 0; k1l < nsquare; k1l++ ) {
146 k1r = q*nfile + nfile-1-r;
147 if ( k0l == k0r && k1l > k1r ) { continue; }
149 for ( il = 0; il < kkp_end; il++ ) {
150 if ( il < kkp_hand_end ) { ir = il; }
152 q = ( il- kkp_hand_end ) / nfile;
153 r = ( il- kkp_hand_end ) % nfile;
154 ir = q*nfile + nfile-1-r + kkp_hand_end;
156 if ( k0l == k0r && k1l == k1r && il >= ir ) { continue; }
159 = p->kkp[k0r][k1r][ir]
160 = p->kkp[k0l][k1l][il] + p->kkp[k0r][k1r][ir];
167 static void fv_sym( void )
169 int q, r, il, ir, ir0, jl, jr, k0l, k0r, k1l, k1r;
171 for ( k0l = 0; k0l < nsquare; k0l++ ) {
174 k0r = q*nfile + nfile-1-r;
175 if ( k0l > k0r ) { continue; }
177 for ( il = 0; il < fe_end; il++ ) {
178 if ( il < fe_hand_end ) { ir0 = il; }
180 q = ( il- fe_hand_end ) / nfile;
181 r = ( il- fe_hand_end ) % nfile;
182 ir0 = q*nfile + nfile-1-r + fe_hand_end;
185 for ( jl = 0; jl <= il; jl++ ) {
186 if ( jl < fe_hand_end )
192 q = ( jl - fe_hand_end ) / nfile;
193 r = ( jl - fe_hand_end ) % nfile;
194 jr = q*nfile + nfile-1-r + fe_hand_end;
202 if ( k0l == k0r && il*(il+1)/2+jl >= ir*(ir+1)/2+jr ) { continue; }
204 PcPcOnSq(k0l,il,jl) = PcPcOnSq(k0r,ir,jr);
209 for ( k0l = 0; k0l < nsquare; k0l++ ) {
212 k0r = q*nfile + nfile-1-r;
213 if ( k0l > k0r ) { continue; }
215 for ( k1l = 0; k1l < nsquare; k1l++ ) {
218 k1r = q*nfile + nfile-1-r;
219 if ( k0l == k0r && k1l > k1r ) { continue; }
221 for ( il = 0; il < kkp_end; il++ ) {
222 if ( il < kkp_hand_end ) { ir = il; }
224 q = ( il- kkp_hand_end ) / nfile;
225 r = ( il- kkp_hand_end ) % nfile;
226 ir = q*nfile + nfile-1-r + kkp_hand_end;
228 if ( k0l == k0r && k1l == k1r && il >= ir ) { continue; }
230 kkp[k0l][k1l][il] = kkp[k0r][k1r][ir];
245 #define Foo(x) u64sum += (uint64_t)abs((int)x);
246 GO_THROUGH_ALL_PARAMETERS_BY_FOO;
249 return (double)u64sum * FV_PENALTY;
254 renovate_param( const param_t *pd )
258 unsigned int u32rand, u;
261 v[pawn] = pd->pawn; v[lance] = pd->lance;
262 v[knight] = pd->knight; v[silver] = pd->silver;
263 v[gold] = pd->gold; v[bishop] = pd->bishop;
264 v[rook] = pd->rook; v[pro_pawn] = pd->pro_pawn;
265 v[pro_lance] = pd->pro_lance; v[pro_knight] = pd->pro_knight;
266 v[pro_silver] = pd->pro_silver; v[horse] = pd->horse;
267 v[dragon] = pd->dragon; v[king] = FLT_MAX;
269 pv[ 0] = v + pawn; pv[ 1] = v + lance;
270 pv[ 2] = v + knight; pv[ 3] = v + silver;
271 pv[ 4] = v + gold; pv[ 5] = v + bishop;
272 pv[ 6] = v + rook; pv[ 7] = v + pro_pawn;
273 pv[ 8] = v + pro_lance; pv[ 9] = v + pro_knight;
274 pv[10] = v + pro_silver; pv[11] = v + horse;
275 pv[12] = v + dragon; pv[13] = v + king;
278 for ( i = 13 - 2; i >= 0; i-- )
281 for ( j = i+1; *pv[j] < *p; j++ ) { pv[j-1] = pv[j]; }
287 u32rand = u32rand / 7U;
288 p = pv[u+6]; pv[u+6] = pv[12]; pv[12] = p;
289 for ( i = 5; i > 0; i-- )
292 u32rand = u32rand / (i+1);
293 p = pv[u]; pv[u] = pv[i]; pv[i] = p;
296 u32rand = u32rand / (i+1);
297 p = pv[u+6]; pv[u+6] = pv[i+6]; pv[i+6] = p;
300 *pv[ 0] = *pv[ 1] = -2.0;
301 *pv[ 2] = *pv[ 3] = *pv[ 4] = -1.0;
302 *pv[ 5] = *pv[ 6] = *pv[ 7] = 0.0;
303 *pv[ 8] = *pv[ 9] = *pv[10] = 1.0;
304 *pv[11] = *pv[12] = 2.0;
306 rmt( v, pawn ); rmt( v, lance ); rmt( v, knight );
307 rmt( v, silver ); rmt( v, gold ); rmt( v, bishop );
308 rmt( v, rook ); rmt( v, pro_pawn ); rmt( v, pro_lance );
309 rmt( v, pro_knight ); rmt( v, pro_silver ); rmt( v, horse );
312 #define Foo(v) rparam( &v, pd->v );
313 GO_THROUGH_ALL_PARAMETERS_BY_FOO;
317 set_derivative_param();
327 int apc[17], apv[17];
328 int iret, i, j, pc, pv;
330 for ( i = 0; i < 17; i++ ) { apc[i] = i; apv[i] = INT_MAX; }
331 apv[pawn] = p_value_ex[15+pawn];
332 apv[lance] = p_value_ex[15+lance];
333 apv[knight] = p_value_ex[15+knight];
334 apv[silver] = p_value_ex[15+silver];
335 apv[gold] = p_value_ex[15+gold];
336 apv[bishop] = p_value_ex[15+bishop];
337 apv[rook] = p_value_ex[15+rook];
338 apv[pro_pawn] = p_value_ex[15+pro_pawn];
339 apv[pro_lance] = p_value_ex[15+pro_lance];
340 apv[pro_knight] = p_value_ex[15+pro_knight];
341 apv[pro_silver] = p_value_ex[15+pro_silver];
342 apv[horse] = p_value_ex[15+horse];
343 apv[dragon] = p_value_ex[15+dragon];
346 for ( i = dragon-1; i >= 0; i-- )
348 pv = apv[i]; pc = apc[i];
349 for ( j = i+1; apv[j] < pv; j++ )
354 apv[j-1] = pv; apc[j-1] = pc;
357 pf = file_open( "param.h_", "w" );
358 if ( pf == NULL ) { return -2; }
360 for ( i = 0; i < 13; i++ )
362 fprintf( pf, "#define " );
365 case pawn: fprintf( pf, "DPawn " ); break;
366 case lance: fprintf( pf, "DLance " ); break;
367 case knight: fprintf( pf, "DKnight " ); break;
368 case silver: fprintf( pf, "DSilver " ); break;
369 case gold: fprintf( pf, "DGold " ); break;
370 case bishop: fprintf( pf, "DBishop " ); break;
371 case rook: fprintf( pf, "DRook " ); break;
372 case pro_pawn: fprintf( pf, "DProPawn " ); break;
373 case pro_lance: fprintf( pf, "DProLance " ); break;
374 case pro_knight: fprintf( pf, "DProKnight" ); break;
375 case pro_silver: fprintf( pf, "DProSilver" ); break;
376 case horse: fprintf( pf, "DHorse " ); break;
377 case dragon: fprintf( pf, "DDragon " ); break;
379 fprintf( pf, " %4d /* %4d */\n", p_value[15+apc[i]], apv[i] );
381 fprintf( pf, "#define DKing 15000\n\n" );
383 iret = file_close( pf );
384 if ( iret < 0 ) { return -2; }
386 pf = file_open( "fv.bin", "wb" );
387 if ( pf == NULL ) { return -2; }
389 size = nsquare * pos_n;
390 if ( fwrite( pc_on_sq, sizeof(short), size, pf ) != size )
392 str_error = str_io_error;
396 size = nsquare * nsquare * kkp_end;
397 if ( fwrite( kkp, sizeof(short), size, pf ) != size )
399 str_error = str_io_error;
403 return file_close( pf );
408 inc_param( const tree_t * restrict ptree, param_t * restrict pd, double dinc )
411 int anpiece[16], list0[52], list1[52];
412 int nlist, sq_bk, sq_wk, k0, k1, l0, l1, i, j;
414 f = (float)( dinc / (double)FV_SCALE );
415 nlist = make_list( ptree, list0, list1, anpiece, pd, f );
417 sq_wk = Inv( SQ_WKING );
419 pd->pawn += dinc * (double)anpiece[pawn];
420 pd->lance += dinc * (double)anpiece[lance];
421 pd->knight += dinc * (double)anpiece[knight];
422 pd->silver += dinc * (double)anpiece[silver];
423 pd->gold += dinc * (double)anpiece[gold];
424 pd->bishop += dinc * (double)anpiece[bishop];
425 pd->rook += dinc * (double)anpiece[rook];
426 pd->pro_pawn += dinc * (double)anpiece[pro_pawn];
427 pd->pro_lance += dinc * (double)anpiece[pro_lance];
428 pd->pro_knight += dinc * (double)anpiece[pro_knight];
429 pd->pro_silver += dinc * (double)anpiece[pro_silver];
430 pd->horse += dinc * (double)anpiece[horse];
431 pd->dragon += dinc * (double)anpiece[dragon];
433 for ( i = 0; i < nlist; i++ )
437 for ( j = 0; j <= i; j++ )
441 assert( k0 >= l0 && k1 >= l1 );
442 pd->PcPcOnSq( sq_bk, k0, l0 ) += f;
443 pd->PcPcOnSq( sq_wk, k1, l1 ) -= f;
450 make_list( const tree_t * restrict ptree, int list0[52], int list1[52],
451 int anpiece[16], param_t * restrict pd, float f )
455 int nlist, sq, sq_bk0, sq_bk1, sq_wk0, sq_wk1, n2, i, itemp1, itemp2;
457 itemp1 = (int)I2HandPawn(HAND_B);
458 itemp2 = (int)I2HandPawn(HAND_W);
459 anpiece[pawn] = itemp1 - itemp2;
461 itemp1 = (int)I2HandLance(HAND_B);
462 itemp2 = (int)I2HandLance(HAND_W);
463 anpiece[lance] = itemp1 - itemp2;
465 itemp1 = (int)I2HandKnight(HAND_B);
466 itemp2 = (int)I2HandKnight(HAND_W);
467 anpiece[knight] = itemp1 - itemp2;
469 itemp1 = (int)I2HandSilver(HAND_B);
470 itemp2 = (int)I2HandSilver(HAND_W);
471 anpiece[silver] = itemp1 - itemp2;
473 itemp1 = (int)I2HandGold(HAND_B);
474 itemp2 = (int)I2HandGold(HAND_W);
475 anpiece[gold] = itemp1 - itemp2;
477 itemp1 = (int)I2HandBishop(HAND_B);
478 itemp2 = (int)I2HandBishop(HAND_W);
479 anpiece[bishop] = itemp1 - itemp2;
481 itemp1 = (int)I2HandRook(HAND_B);
482 itemp2 = (int)I2HandRook(HAND_W);
483 anpiece[rook] = itemp1 - itemp2;
485 anpiece[pro_pawn] = anpiece[pro_lance] = anpiece[pro_knight] = 0;
486 anpiece[pro_silver] = anpiece[horse] = anpiece[dragon] = 0;
490 sq_bk1 = Inv(SQ_WKING);
491 sq_wk1 = Inv(SQ_BKING);
493 list0[ 0] = f_hand_pawn + I2HandPawn(HAND_B);
494 list0[ 1] = e_hand_pawn + I2HandPawn(HAND_W);
495 list0[ 2] = f_hand_lance + I2HandLance(HAND_B);
496 list0[ 3] = e_hand_lance + I2HandLance(HAND_W);
497 list0[ 4] = f_hand_knight + I2HandKnight(HAND_B);
498 list0[ 5] = e_hand_knight + I2HandKnight(HAND_W);
499 list0[ 6] = f_hand_silver + I2HandSilver(HAND_B);
500 list0[ 7] = e_hand_silver + I2HandSilver(HAND_W);
501 list0[ 8] = f_hand_gold + I2HandGold(HAND_B);
502 list0[ 9] = e_hand_gold + I2HandGold(HAND_W);
503 list0[10] = f_hand_bishop + I2HandBishop(HAND_B);
504 list0[11] = e_hand_bishop + I2HandBishop(HAND_W);
505 list0[12] = f_hand_rook + I2HandRook(HAND_B);
506 list0[13] = e_hand_rook + I2HandRook(HAND_W);
508 list1[ 0] = f_hand_pawn + I2HandPawn(HAND_W);
509 list1[ 1] = e_hand_pawn + I2HandPawn(HAND_B);
510 list1[ 2] = f_hand_lance + I2HandLance(HAND_W);
511 list1[ 3] = e_hand_lance + I2HandLance(HAND_B);
512 list1[ 4] = f_hand_knight + I2HandKnight(HAND_W);
513 list1[ 5] = e_hand_knight + I2HandKnight(HAND_B);
514 list1[ 6] = f_hand_silver + I2HandSilver(HAND_W);
515 list1[ 7] = e_hand_silver + I2HandSilver(HAND_B);
516 list1[ 8] = f_hand_gold + I2HandGold(HAND_W);
517 list1[ 9] = e_hand_gold + I2HandGold(HAND_B);
518 list1[10] = f_hand_bishop + I2HandBishop(HAND_W);
519 list1[11] = e_hand_bishop + I2HandBishop(HAND_B);
520 list1[12] = f_hand_rook + I2HandRook(HAND_W);
521 list1[13] = e_hand_rook + I2HandRook(HAND_B);
523 pd->kkp[sq_bk0][sq_wk0][kkp_hand_pawn +I2HandPawn(HAND_B) ] += f;
524 pd->kkp[sq_bk0][sq_wk0][kkp_hand_lance +I2HandLance(HAND_B) ] += f;
525 pd->kkp[sq_bk0][sq_wk0][kkp_hand_knight+I2HandKnight(HAND_B)] += f;
526 pd->kkp[sq_bk0][sq_wk0][kkp_hand_silver+I2HandSilver(HAND_B)] += f;
527 pd->kkp[sq_bk0][sq_wk0][kkp_hand_gold +I2HandGold(HAND_B) ] += f;
528 pd->kkp[sq_bk0][sq_wk0][kkp_hand_bishop+I2HandBishop(HAND_B)] += f;
529 pd->kkp[sq_bk0][sq_wk0][kkp_hand_rook +I2HandRook(HAND_B) ] += f;
531 pd->kkp[sq_bk1][sq_wk1][kkp_hand_pawn +I2HandPawn(HAND_W) ] -= f;
532 pd->kkp[sq_bk1][sq_wk1][kkp_hand_lance +I2HandLance(HAND_W) ] -= f;
533 pd->kkp[sq_bk1][sq_wk1][kkp_hand_knight+I2HandKnight(HAND_W)] -= f;
534 pd->kkp[sq_bk1][sq_wk1][kkp_hand_silver+I2HandSilver(HAND_W)] -= f;
535 pd->kkp[sq_bk1][sq_wk1][kkp_hand_gold +I2HandGold(HAND_W) ] -= f;
536 pd->kkp[sq_bk1][sq_wk1][kkp_hand_bishop+I2HandBishop(HAND_W)] -= f;
537 pd->kkp[sq_bk1][sq_wk1][kkp_hand_rook +I2HandRook(HAND_W) ] -= f;
541 while ( BBTest(bb) ) {
545 pd->kkp[sq_bk0][sq_wk0][kkp_pawn+sq] += f;
547 list0[nlist] = f_pawn + sq;
548 list2[n2] = e_pawn + Inv(sq);
554 while ( BBTest(bb) ) {
558 pd->kkp[sq_bk1][sq_wk1][kkp_pawn+Inv(sq)] -= f;
560 list0[nlist] = e_pawn + sq;
561 list2[n2] = f_pawn + Inv(sq);
565 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
569 while ( BBTest(bb) ) {
573 pd->kkp[sq_bk0][sq_wk0][kkp_lance+sq] += f;
575 list0[nlist] = f_lance + sq;
576 list2[n2] = e_lance + Inv(sq);
582 while ( BBTest(bb) ) {
586 pd->kkp[sq_bk1][sq_wk1][kkp_lance+Inv(sq)] -= f;
588 list0[nlist] = e_lance + sq;
589 list2[n2] = f_lance + Inv(sq);
593 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
598 while ( BBTest(bb) ) {
602 pd->kkp[sq_bk0][sq_wk0][kkp_knight+sq] += f;
603 anpiece[knight] += 1;
604 list0[nlist] = f_knight + sq;
605 list2[n2] = e_knight + Inv(sq);
611 while ( BBTest(bb) ) {
615 pd->kkp[sq_bk1][sq_wk1][kkp_knight+Inv(sq)] -= f;
616 anpiece[knight] -= 1;
617 list0[nlist] = e_knight + sq;
618 list2[n2] = f_knight + Inv(sq);
622 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
627 while ( BBTest(bb) ) {
631 pd->kkp[sq_bk0][sq_wk0][kkp_silver+sq] += f;
632 anpiece[silver] += 1;
633 list0[nlist] = f_silver + sq;
634 list2[n2] = e_silver + Inv(sq);
640 while ( BBTest(bb) ) {
644 pd->kkp[sq_bk1][sq_wk1][kkp_silver+Inv(sq)] -= f;
645 anpiece[silver] -= 1;
646 list0[nlist] = e_silver + sq;
647 list2[n2] = f_silver + Inv(sq);
651 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
656 while ( BBTest(bb) ) {
660 pd->kkp[sq_bk0][sq_wk0][kkp_gold+sq] += f;
661 anpiece[BOARD[sq]] += 1;
662 list0[nlist] = f_gold + sq;
663 list2[n2] = e_gold + Inv(sq);
669 while ( BBTest(bb) ) {
673 pd->kkp[sq_bk1][sq_wk1][kkp_gold+Inv(sq)] -= f;
674 anpiece[-BOARD[sq]] -= 1;
675 list0[nlist] = e_gold + sq;
676 list2[n2] = f_gold + Inv(sq);
680 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
685 while ( BBTest(bb) ) {
689 pd->kkp[sq_bk0][sq_wk0][kkp_bishop+sq] += f;
690 anpiece[bishop] += 1;
691 list0[nlist] = f_bishop + sq;
692 list2[n2] = e_bishop + Inv(sq);
698 while ( BBTest(bb) ) {
702 pd->kkp[sq_bk1][sq_wk1][kkp_bishop+Inv(sq)] -= f;
703 anpiece[bishop] -= 1;
704 list0[nlist] = e_bishop + sq;
705 list2[n2] = f_bishop + Inv(sq);
709 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
714 while ( BBTest(bb) ) {
718 pd->kkp[sq_bk0][sq_wk0][kkp_horse+sq] += f;
720 list0[nlist] = f_horse + sq;
721 list2[n2] = e_horse + Inv(sq);
727 while ( BBTest(bb) ) {
731 pd->kkp[sq_bk1][sq_wk1][kkp_horse+Inv(sq)] -= f;
733 list0[nlist] = e_horse + sq;
734 list2[n2] = f_horse + Inv(sq);
738 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
743 while ( BBTest(bb) ) {
747 pd->kkp[sq_bk0][sq_wk0][kkp_rook+sq] += f;
749 list0[nlist] = f_rook + sq;
750 list2[n2] = e_rook + Inv(sq);
756 while ( BBTest(bb) ) {
760 pd->kkp[sq_bk1][sq_wk1][kkp_rook+Inv(sq)] -= f;
762 list0[nlist] = e_rook + sq;
763 list2[n2] = f_rook + Inv(sq);
767 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
772 while ( BBTest(bb) ) {
776 pd->kkp[sq_bk0][sq_wk0][kkp_dragon+sq] += f;
777 anpiece[dragon] += 1;
778 list0[nlist] = f_dragon + sq;
779 list2[n2] = e_dragon + Inv(sq);
785 while ( BBTest(bb) ) {
789 pd->kkp[sq_bk1][sq_wk1][kkp_dragon+Inv(sq)] -= f;
790 anpiece[dragon] -= 1;
791 list0[nlist] = e_dragon + sq;
792 list2[n2] = f_dragon + Inv(sq);
796 for ( i = 0; i < n2; i++ ) { list1[nlist-i-1] = list2[i]; }
798 assert( nlist <= 52 );
804 rmt( const double avalue[16], int pc )
808 pc_v = (int)p_value[15+pc] + (int)avalue[pc];
810 if ( 0 < pc_v && pc_v <= SHRT_MAX ) { p_value[15+pc] = (short)pc_v; }
812 out_warning( "A material value is out of bounce. (%s=%d)\n",
813 astr_table_piece[pc], pc_v );
819 rparam( short *pv, float dv )
827 if ( v > 0 ) { dv -= (float)FV_PENALTY; }
828 else if ( v < 0 ) { dv += (float)FV_PENALTY; }
830 if ( dv >= 0.0 && v <= SHRT_MAX - istep ) { v += istep; }
831 else if ( dv <= 0.0 && v >= SHRT_MIN + istep ) { v -= istep; }
832 else { out_warning( "A fvcoef parameter is out of bounce.\n" ); }
841 static unsigned int urand = 0;
842 static unsigned int uc = 31;