RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v
retrieving revision 1.68
diff -u -p -r1.68 matchpat.c
|
|
|
|
| 36 | 36 | /* Pattern profiling functions: */ |
| 37 | 37 | /**************************************************************************/ |
| 38 | 38 | |
| 39 | | /* define this to see how each phase of pattern rejection is performing */ |
| 40 | | /* #define PROFILE_MATCHER */ |
| 41 | | |
| 42 | | |
| 43 | | #ifdef PROFILE_MATCHER |
| 44 | | static int totals[6]; |
| 45 | | #endif |
| 46 | | |
| 47 | 39 | |
| 48 | 40 | #if PROFILE_PATTERNS |
| 49 | 41 | /* Initialize pattern profiling fields in one pattern struct array. */ |
| … |
… |
|
| 382 | 374 | */ |
| 383 | 375 | |
| 384 | 376 | if (anchor_test != pattern->anchored_at_X) |
| 385 | | { |
| 386 | | #ifdef PROFILE_MATCHER |
| 387 | | /* oops - need to work out something we deferred */ |
| 388 | | totals[0] += (pattern->trfno == 5 ? 4 : pattern->trfno); |
| 389 | | #endif |
| 390 | 377 | continue; /* does not match the anchor */ |
| 391 | | } |
| 392 | 378 | |
| 393 | 379 | ll = 0; /* first transformation number */ |
| 394 | 380 | end_transformation = pattern->trfno; |
| … |
… |
|
| 399 | 385 | end_transformation = 6; |
| 400 | 386 | } |
| 401 | 387 | |
| 402 | | #ifdef PROFILE_MATCHER |
| 403 | | totals[0] += end_transformation - ll; |
| 404 | | #endif |
| 405 | | |
| 406 | 388 | /* try each orientation transformation. Assume at least 1 */ |
| 407 | 389 | |
| 408 | 390 | do { |
| … |
… |
|
| 411 | 393 | int nodes_before; |
| 412 | 394 | #endif |
| 413 | 395 | |
| 414 | | #ifdef PROFILE_MATCHER |
| 415 | | ++totals[1]; |
| 416 | | #endif |
| 417 | | |
| 418 | 396 | #if GRID_OPT == 1 |
| 419 | 397 | |
| 420 | 398 | /* We first perform the grid check : this checks up to 16 |
| … |
… |
|
| 432 | 410 | |
| 433 | 411 | #endif /* GRID_OPT == 1 */ |
| 434 | 412 | |
| 435 | | #ifdef PROFILE_MATCHER |
| 436 | | ++totals[2]; |
| 437 | | #endif |
| 438 | 413 | /* Next, we do the range check. This applies the edge |
| 439 | 414 | * constraints implicitly. |
| 440 | 415 | */ |
| … |
… |
|
| 460 | 435 | continue; /* out of range */ |
| 461 | 436 | } |
| 462 | 437 | |
| 463 | | #ifdef PROFILE_MATCHER |
| 464 | | ++totals[3]; |
| 465 | | #endif |
| 466 | | |
| 467 | 438 | /* Now iterate over the elements of the pattern. */ |
| 468 | 439 | found_goal = 0; |
| 469 | 440 | for (k = 0; k < pattern->patlen; ++k) { /* match each point */ |
| … |
… |
|
| 502 | 473 | #endif /* we don't trust the grid optimisation */ |
| 503 | 474 | |
| 504 | 475 | |
| 505 | | #ifdef PROFILE_MATCHER |
| 506 | | ++totals[4]; |
| 507 | | #endif |
| 508 | | |
| 509 | 476 | /* Make it here ==> We have matched all the elements to the board. */ |
| 510 | 477 | if ((goal != NULL) && !found_goal) |
| 511 | 478 | goto match_failed; |
| 512 | 479 | |
| 513 | | #ifdef PROFILE_MATCHER |
| 514 | | ++totals[5]; |
| 515 | | #endif |
| 516 | | |
| 517 | 480 | #if PROFILE_PATTERNS |
| 518 | 481 | pattern->hits++; |
| 519 | 482 | nodes_before = stats.nodes; |
| … |
… |
|
| 535 | 498 | } while (++ll < end_transformation); /* ll loop over symmetries */ |
| 536 | 499 | } /* if not rejected by maxwt */ |
| 537 | 500 | } while ((++pattern)->patn); /* loop over patterns */ |
| 538 | | |
| 539 | | |
| 540 | | #ifdef PROFILE_MATCHER |
| 541 | | fprintf(stderr, |
| 542 | | "total %d, anchor=%d, grid=%d, edge=%d, matched=%d, accepted=%d\n", |
| 543 | | totals[0], totals[1], totals[2], totals[3], totals[4], totals[5]); |
| 544 | | #endif |
| 545 | | |
| 546 | 501 | } |
| 547 | 502 | |
| 548 | 503 | |
| … |
… |
|
| 976 | 931 | int nodes_before; |
| 977 | 932 | #endif |
| 978 | 933 | |
| 979 | | #ifdef PROFILE_MATCHER |
| 980 | | ++totals[1]; |
| 981 | | #endif |
| 982 | | |
| 983 | 934 | if (0) |
| 984 | 935 | gprintf("check_pattern_light @ %1m rot:%d pattern: %s\n", |
| 985 | 936 | anchor, ll, pattern->name); |
| … |
… |
|
| 1023 | 974 | if (goal != NULL && !found_goal) |
| 1024 | 975 | goto match_failed; |
| 1025 | 976 | } |
| 1026 | | |
| 1027 | | #ifdef PROFILE_MATCHER |
| 1028 | | ++totals[4]; |
| 1029 | | #endif |
| 1030 | 977 | |
| 1031 | 978 | #if PROFILE_PATTERNS |
| 1032 | 979 | pattern->hits++; |