1 /* Heuristical playout (and tree prior) policy modelled primarily after
2 * the description of the Mogo engine. */
12 #include "joseki/base.h"
16 #include "playout/moggy.h"
18 #include "tactics/1lib.h"
19 #include "tactics/2lib.h"
20 #include "tactics/ladder.h"
21 #include "tactics/selfatari.h"
22 #include "uct/prior.h"
24 #define PLDEBUGL(n) DEBUGL_(p->debug_level, n)
27 /* In case "seqchoose" move picker is enabled (i.e. no "fullchoose"
28 * parameter passed), we stochastically apply fixed set of decision
29 * rules in given order.
31 * In "fullchoose" mode, we instead build a move queue of variously
32 * tagged candidates, then consider a probability distribution over
33 * them and pick a move from that. */
35 /* Move queue tags. Some may be even undesirable - these moves then
36 * receive a penalty; penalty tags should be used only when it is
37 * certain the move would be considered anyway. */
49 /* Note that the context can be shared by multiple threads! */
52 unsigned int lcapturerate
, atarirate
, capturerate
, patternrate
, korate
, josekirate
;
53 unsigned int selfatarirate
, alwaysccaprate
;
54 unsigned int fillboardtries
;
56 /* Whether to look for patterns around second-to-last move. */
58 /* Whether, when self-atari attempt is detected, to play the other
59 * group's liberty if that is non-self-atari. */
61 /* Whether to always pick from moves capturing all groups in
62 * global_atari_check(). */
65 bool atari_def_no_hopeless
;
68 struct joseki_dict
*jdict
;
69 struct pattern3s patterns
;
71 /* Gamma values for queue tags - correspond to probabilities. */
73 double mq_prob
[MQ_MAX
], tenuki_prob
;
77 static char moggy_patterns_src
[][11] = {
78 /* hane pattern - enclosing hane */
82 /* hane pattern - non-cutting hane */
86 /* hane pattern - magari */
90 /* hane pattern - thin hane */
94 /* generic pattern - katatsuke or diagonal attachment; similar to magari */
98 /* cut1 pattern (kiri) - unprotected cut */
102 /* cut1 pattern (kiri) - peeped cut */
106 /* cut2 pattern (de) */
110 /* cut keima (not in Mogo) */
113 "???", /* o?? has some pathological tsumego cases */
114 /* side pattern - chase */
118 /* side pattern - block side cut */
122 /* side pattern - block side connection */
126 /* side pattern - sagari (SUSPICIOUS) */
128 "x.x" /* Mogo has "x.?" */
129 "###" /* Mogo has "X" */,
130 /* side pattern - throw-in (SUSPICIOUS) */
136 /* side pattern - cut (SUSPICIOUS) */
139 "###" /* Mogo has "X" */,
140 /* side pattern - eye piercing:
151 #define moggy_patterns_src_n sizeof(moggy_patterns_src) / sizeof(moggy_patterns_src[0])
154 test_pattern3_here(struct playout_policy
*p
, struct board
*b
, struct move
*m
)
156 struct moggy_policy
*pp
= p
->data
;
157 /* Check if 3x3 pattern is matched by given move... */
158 if (!pattern3_move_here(&pp
->patterns
, b
, m
))
160 /* ...and the move is not obviously stupid. */
161 if (is_bad_selfatari(b
, m
->color
, m
->coord
))
163 /* Ladder moves are stupid. */
164 group_t atari_neighbor
= board_get_atari_neighbor(b
, m
->coord
, m
->color
);
165 if (atari_neighbor
&& is_ladder(b
, m
->coord
, atari_neighbor
))
171 apply_pattern_here(struct playout_policy
*p
, struct board
*b
, coord_t c
, enum stone color
, struct move_queue
*q
)
173 struct move m2
= { .coord
= c
, .color
= color
};
174 if (board_is_valid_move(b
, &m2
) && test_pattern3_here(p
, b
, &m2
))
175 mq_add(q
, c
, 1<<MQ_PAT3
);
178 /* Check if we match any pattern around given move (with the other color to play). */
180 apply_pattern(struct playout_policy
*p
, struct board
*b
, struct move
*m
, struct move
*mm
, struct move_queue
*q
)
182 /* Suicides do not make any patterns and confuse us. */
183 if (board_at(b
, m
->coord
) == S_NONE
|| board_at(b
, m
->coord
) == S_OFFBOARD
)
186 foreach_8neighbor(b
, m
->coord
) {
187 apply_pattern_here(p
, b
, c
, stone_other(m
->color
), q
);
188 } foreach_8neighbor_end
;
190 if (mm
) { /* Second move for pattern searching */
191 foreach_8neighbor(b
, mm
->coord
) {
192 if (coord_is_8adjecent(m
->coord
, c
, b
))
194 apply_pattern_here(p
, b
, c
, stone_other(m
->color
), q
);
195 } foreach_8neighbor_end
;
199 mq_print(q
, b
, "Pattern");
204 joseki_check(struct playout_policy
*p
, struct board
*b
, enum stone to_play
, struct move_queue
*q
)
206 struct moggy_policy
*pp
= p
->data
;
210 for (int i
= 0; i
< 4; i
++) {
211 hash_t h
= b
->qhash
[i
] & joseki_hash_mask
;
212 coord_t
*cc
= pp
->jdict
->patterns
[h
].moves
[to_play
];
214 for (; !is_pass(*cc
); cc
++) {
215 if (coord_quadrant(*cc
, b
) != i
)
217 mq_add(q
, *cc
, 1<<MQ_JOSEKI
);
221 if (q
->moves
> 0 && PLDEBUGL(5))
222 mq_print(q
, b
, "Joseki");
226 global_atari_check(struct playout_policy
*p
, struct board
*b
, enum stone to_play
, struct move_queue
*q
)
231 struct moggy_policy
*pp
= p
->data
;
232 if (pp
->capcheckall
) {
233 for (int g
= 0; g
< b
->clen
; g
++)
234 group_atari_check(pp
->alwaysccaprate
, b
, group_at(b
, group_base(b
->c
[g
])), to_play
, q
, NULL
, 1<<MQ_GATARI
);
236 mq_print(q
, b
, "Global atari");
240 int g_base
= fast_random(b
->clen
);
241 for (int g
= g_base
; g
< b
->clen
; g
++) {
242 group_atari_check(pp
->alwaysccaprate
, b
, group_at(b
, group_base(b
->c
[g
])), to_play
, q
, NULL
, 1<<MQ_GATARI
);
244 /* XXX: Try carrying on. */
246 mq_print(q
, b
, "Global atari");
250 for (int g
= 0; g
< g_base
; g
++) {
251 group_atari_check(pp
->alwaysccaprate
, b
, group_at(b
, group_base(b
->c
[g
])), to_play
, q
, NULL
, 1<<MQ_GATARI
);
253 /* XXX: Try carrying on. */
255 mq_print(q
, b
, "Global atari");
263 local_atari_check(struct playout_policy
*p
, struct board
*b
, struct move
*m
, struct move_queue
*q
)
265 struct moggy_policy
*pp
= p
->data
;
267 /* Did the opponent play a self-atari? */
268 if (board_group_info(b
, group_at(b
, m
->coord
)).libs
== 1) {
269 group_atari_check(pp
->alwaysccaprate
, b
, group_at(b
, m
->coord
), stone_other(m
->color
), q
, NULL
, 1<<MQ_LATARI
);
272 foreach_neighbor(b
, m
->coord
, {
273 group_t g
= group_at(b
, c
);
274 if (!g
|| board_group_info(b
, g
).libs
!= 1)
276 group_atari_check(pp
->alwaysccaprate
, b
, g
, stone_other(m
->color
), q
, NULL
, 1<<MQ_LATARI
);
280 mq_print(q
, b
, "Local atari");
285 local_2lib_check(struct playout_policy
*p
, struct board
*b
, struct move
*m
, struct move_queue
*q
)
287 struct moggy_policy
*pp
= p
->data
;
289 /* Does the opponent have just two liberties? */
290 if (board_group_info(b
, group_at(b
, m
->coord
)).libs
== 2) {
291 group_2lib_check(b
, group_at(b
, m
->coord
), stone_other(m
->color
), q
, 1<<MQ_L2LIB
, pp
->atari_miaisafe
, pp
->atari_def_no_hopeless
);
293 /* We always prefer to take off an enemy chain liberty
294 * before pulling out ourselves. */
295 /* XXX: We aren't guaranteed to return to that group
298 return q
->move
[fast_random(q
->moves
)];
302 /* Then he took a third liberty from neighboring chain? */
303 foreach_neighbor(b
, m
->coord
, {
304 group_t g
= group_at(b
, c
);
305 if (!g
|| board_group_info(b
, g
).libs
!= 2)
307 group_2lib_check(b
, g
, stone_other(m
->color
), q
, 1<<MQ_L2LIB
, pp
->atari_miaisafe
, pp
->atari_def_no_hopeless
);
311 mq_print(q
, b
, "Local 2lib");
315 fillboard_check(struct playout_policy
*p
, struct board
*b
)
317 struct moggy_policy
*pp
= p
->data
;
318 unsigned int fbtries
= b
->flen
/ 8;
319 if (pp
->fillboardtries
< fbtries
)
320 fbtries
= pp
->fillboardtries
;
322 for (unsigned int i
= 0; i
< fbtries
; i
++) {
323 coord_t coord
= b
->f
[fast_random(b
->flen
)];
324 if (immediate_liberty_count(b
, coord
) != 4)
326 foreach_diag_neighbor(b
, coord
) {
327 if (board_at(b
, c
) != S_NONE
)
329 } foreach_diag_neighbor_end
;
337 playout_moggy_seqchoose(struct playout_policy
*p
, struct playout_setup
*s
, struct board
*b
, enum stone to_play
)
339 struct moggy_policy
*pp
= p
->data
;
342 board_print(b
, stderr
);
345 if (!is_pass(b
->last_ko
.coord
) && is_pass(b
->ko
.coord
)
346 && b
->moves
- b
->last_ko_age
< pp
->koage
347 && pp
->korate
> fast_random(100)) {
348 if (board_is_valid_play(b
, to_play
, b
->last_ko
.coord
)
349 && !is_bad_selfatari(b
, to_play
, b
->last_ko
.coord
))
350 return b
->last_ko
.coord
;
354 if (!is_pass(b
->last_move
.coord
)) {
355 /* Local group in atari? */
356 if (pp
->lcapturerate
> fast_random(100)) {
357 struct move_queue q
; q
.moves
= 0;
358 local_atari_check(p
, b
, &b
->last_move
, &q
);
363 /* Local group can be PUT in atari? */
364 if (pp
->atarirate
> fast_random(100)) {
365 struct move_queue q
; q
.moves
= 0;
366 local_2lib_check(p
, b
, &b
->last_move
, &q
);
371 /* Check for patterns we know */
372 if (pp
->patternrate
> fast_random(100)) {
373 struct move_queue q
; q
.moves
= 0;
374 apply_pattern(p
, b
, &b
->last_move
,
375 pp
->pattern2
&& b
->last_move2
.coord
>= 0 ? &b
->last_move2
: NULL
,
384 /* Any groups in atari? */
385 if (pp
->capturerate
> fast_random(100)) {
386 struct move_queue q
; q
.moves
= 0;
387 global_atari_check(p
, b
, to_play
, &q
);
393 if (pp
->josekirate
> fast_random(100)) {
394 struct move_queue q
; q
.moves
= 0;
395 joseki_check(p
, b
, to_play
, &q
);
401 if (pp
->fillboardtries
> 0) {
402 coord_t c
= fillboard_check(p
, b
);
410 /* Pick a move from queue q, giving different likelihoods to moves
411 * based on their tags. */
413 mq_tagged_choose(struct playout_policy
*p
, struct board
*b
, enum stone to_play
, struct move_queue
*q
)
415 struct moggy_policy
*pp
= p
->data
;
417 /* First, merge all entries for a move. */
418 /* We use a naive O(N^2) since the average length of the queue
420 for (unsigned int i
= 0; i
< q
->moves
; i
++) {
421 for (unsigned int j
= i
+ 1; j
< q
->moves
; j
++) {
422 if (q
->move
[i
] != q
->move
[j
])
424 q
->tag
[i
] |= q
->tag
[j
];
426 q
->tag
[j
] = q
->tag
[q
->moves
];
427 q
->move
[j
] = q
->move
[q
->moves
];
431 /* Now, construct a probdist. */
434 for (unsigned int i
= 0; i
< q
->moves
; i
++) {
436 assert(q
->tag
[i
] != 0);
437 for (int j
= 0; j
< MQ_MAX
; j
++)
438 if (q
->tag
[i
] & (1<<j
)) {
439 //fprintf(stderr, "%s(%x) %d %f *= %f\n", coord2sstr(q->move[i], b), q->tag[i], j, val, pp->mq_prob[j]);
440 val
*= pp
->mq_prob
[j
];
442 pd
[i
] = double_to_fixp(val
);
445 total
+= double_to_fixp(pp
->tenuki_prob
);
447 /* Finally, pick a move! */
448 fixp_t stab
= fast_irandom(total
);
449 for (unsigned int i
= 0; i
< q
->moves
; i
++) {
450 //fprintf(stderr, "%s(%x) %f (%f/%f)\n", coord2sstr(q->move[i], b), q->tag[i], fixp_to_double(stab), fixp_to_double(pd[i]), fixp_to_double(total));
457 assert(stab
< double_to_fixp(pp
->tenuki_prob
));
462 playout_moggy_fullchoose(struct playout_policy
*p
, struct playout_setup
*s
, struct board
*b
, enum stone to_play
)
464 struct moggy_policy
*pp
= p
->data
;
465 struct move_queue q
; q
.moves
= 0;
468 board_print(b
, stderr
);
471 if (!is_pass(b
->last_ko
.coord
) && is_pass(b
->ko
.coord
)
472 && b
->moves
- b
->last_ko_age
< pp
->koage
) {
473 if (board_is_valid_play(b
, to_play
, b
->last_ko
.coord
)
474 && !is_bad_selfatari(b
, to_play
, b
->last_ko
.coord
))
475 mq_add(&q
, b
->last_ko
.coord
, 1<<MQ_KO
);
479 if (!is_pass(b
->last_move
.coord
)) {
480 /* Local group in atari? */
481 local_atari_check(p
, b
, &b
->last_move
, &q
);
483 /* Local group can be PUT in atari? */
484 local_2lib_check(p
, b
, &b
->last_move
, &q
);
486 /* Check for patterns we know */
487 apply_pattern(p
, b
, &b
->last_move
,
488 pp
->pattern2
&& b
->last_move2
.coord
>= 0 ? &b
->last_move2
: NULL
,
494 /* Any groups in atari? */
495 global_atari_check(p
, b
, to_play
, &q
);
498 joseki_check(p
, b
, to_play
, &q
);
501 /* Average length of the queue is 1.4 move. */
502 printf("MQL %d ", q
.moves
);
503 for (unsigned int i
= 0; i
< q
.moves
; i
++)
504 printf("%s ", coord2sstr(q
.move
[i
], b
));
509 return mq_tagged_choose(p
, b
, to_play
, &q
);
512 if (pp
->fillboardtries
> 0) {
513 coord_t c
= fillboard_check(p
, b
);
523 playout_moggy_assess_group(struct playout_policy
*p
, struct prior_map
*map
, group_t g
, int games
)
525 struct moggy_policy
*pp
= p
->data
;
526 struct board
*b
= map
->b
;
527 struct move_queue q
; q
.moves
= 0;
529 if (board_group_info(b
, g
).libs
> 2)
533 fprintf(stderr
, "ASSESS of group %s:\n", coord2sstr(g
, b
));
534 board_print(b
, stderr
);
537 if (board_group_info(b
, g
).libs
== 2) {
540 group_2lib_check(b
, g
, map
->to_play
, &q
, 0, pp
->atari_miaisafe
, pp
->atari_def_no_hopeless
);
542 coord_t coord
= q
.move
[q
.moves
];
544 fprintf(stderr
, "1.0: 2lib %s\n", coord2sstr(coord
, b
));
545 int assess
= games
/ 2;
546 add_prior_value(map
, coord
, 1, assess
);
551 /* This group, sir, is in atari! */
553 coord_t ladder
= pass
;
554 group_atari_check(pp
->alwaysccaprate
, b
, g
, map
->to_play
, &q
, &ladder
, 0);
556 coord_t coord
= q
.move
[q
.moves
];
558 /* _Never_ play here if this move plays out
559 * a caught ladder. */
560 if (coord
== ladder
&& !board_playing_ko_threat(b
)) {
561 /* Note that the opposite is not guarded against;
562 * we do not advise against capturing a laddered
563 * group (but we don't encourage it either). Such
564 * a move can simplify tactical situations if we
566 if (map
->to_play
!= board_at(b
, g
))
568 /* FIXME: We give the malus even if this move
569 * captures another group. */
571 fprintf(stderr
, "0.0: ladder %s\n", coord2sstr(coord
, b
));
572 add_prior_value(map
, coord
, 0, games
);
576 if (!pp
->capturerate
&& !pp
->lcapturerate
)
580 fprintf(stderr
, "1.0: atari %s\n", coord2sstr(coord
, b
));
581 int assess
= games
* 2;
582 add_prior_value(map
, coord
, 1, assess
);
587 playout_moggy_assess_one(struct playout_policy
*p
, struct prior_map
*map
, coord_t coord
, int games
)
589 struct moggy_policy
*pp
= p
->data
;
590 struct board
*b
= map
->b
;
593 fprintf(stderr
, "ASSESS of move %s:\n", coord2sstr(coord
, b
));
594 board_print(b
, stderr
);
597 /* Is this move a self-atari? */
598 if (pp
->selfatarirate
) {
599 if (!board_playing_ko_threat(b
) && is_bad_selfatari(b
, map
->to_play
, coord
)) {
601 fprintf(stderr
, "0.0: self-atari\n");
602 add_prior_value(map
, coord
, 0, games
);
603 if (!pp
->selfatari_other
)
605 /* If we can play on the other liberty of the
606 * endangered group, do! */
607 coord
= selfatari_cousin(b
, map
->to_play
, coord
);
611 fprintf(stderr
, "1.0: self-atari redirect %s\n", coord2sstr(coord
, b
));
612 add_prior_value(map
, coord
, 1.0, games
);
618 if (pp
->patternrate
) {
619 struct move m
= { .color
= map
->to_play
, .coord
= coord
};
620 if (test_pattern3_here(p
, b
, &m
)) {
622 fprintf(stderr
, "1.0: pattern\n");
623 add_prior_value(map
, coord
, 1, games
);
631 playout_moggy_assess(struct playout_policy
*p
, struct prior_map
*map
, int games
)
633 struct moggy_policy
*pp
= p
->data
;
635 /* First, go through all endangered groups. */
636 for (group_t g
= 1; g
< board_size2(map
->b
); g
++)
637 if (group_at(map
->b
, g
) == g
)
638 playout_moggy_assess_group(p
, map
, g
, games
);
640 /* Then, assess individual moves. */
641 if (!pp
->patternrate
&& !pp
->selfatarirate
)
643 foreach_free_point(map
->b
) {
644 if (map
->consider
[c
])
645 playout_moggy_assess_one(p
, map
, c
, games
);
646 } foreach_free_point_end
;
650 playout_moggy_permit(struct playout_policy
*p
, struct board
*b
, struct move
*m
)
652 struct moggy_policy
*pp
= p
->data
;
654 /* The idea is simple for now - never allow self-atari moves.
655 * They suck in general, but this also permits us to actually
656 * handle seki in the playout stage. */
658 if (fast_random(100) >= pp
->selfatarirate
) {
660 fprintf(stderr
, "skipping sar test\n");
663 bool selfatari
= is_bad_selfatari(b
, m
->color
, m
->coord
);
666 fprintf(stderr
, "__ Prohibiting self-atari %s %s\n",
667 stone2str(m
->color
), coord2sstr(m
->coord
, b
));
668 if (pp
->selfatari_other
) {
669 /* Ok, try the other liberty of the atari'd group. */
670 coord_t c
= selfatari_cousin(b
, m
->color
, m
->coord
);
671 if (is_pass(c
)) return false;
673 fprintf(stderr
, "___ Redirecting to other lib %s\n",
684 struct playout_policy
*
685 playout_moggy_init(char *arg
, struct board
*b
, struct joseki_dict
*jdict
)
687 struct playout_policy
*p
= calloc2(1, sizeof(*p
));
688 struct moggy_policy
*pp
= calloc2(1, sizeof(*pp
));
690 p
->choose
= playout_moggy_seqchoose
;
691 p
->assess
= playout_moggy_assess
;
692 p
->permit
= playout_moggy_permit
;
696 /* These settings are tuned for 19x19 play with several threads
697 * on reasonable time limits (i.e., rather large number of playouts).
698 * XXX: no 9x9 tuning has been done recently. */
699 int rate
= board_large(b
) ? 80 : 90;
701 pp
->lcapturerate
= pp
->atarirate
= pp
->patternrate
702 = pp
->selfatarirate
= pp
->josekirate
= -1U;
703 if (board_large(b
)) {
704 pp
->lcapturerate
= pp
->patternrate
= 100;
707 pp
->korate
= 20; pp
->koage
= 4;
708 pp
->alwaysccaprate
= 20;
709 pp
->selfatari_other
= true;
710 pp
->atari_def_no_hopeless
= true;
711 pp
->atari_miaisafe
= true;
714 double mq_prob_default
[MQ_MAX
] = {
722 memcpy(pp
->mq_prob
, mq_prob_default
, sizeof(pp
->mq_prob
));
725 char *optspec
, *next
= arg
;
728 next
+= strcspn(next
, ":");
729 if (*next
) { *next
++ = 0; } else { *next
= 0; }
731 char *optname
= optspec
;
732 char *optval
= strchr(optspec
, '=');
733 if (optval
) *optval
++ = 0;
735 if (!strcasecmp(optname
, "debug") && optval
) {
736 p
->debug_level
= atoi(optval
);
737 } else if (!strcasecmp(optname
, "lcapturerate") && optval
) {
738 pp
->lcapturerate
= atoi(optval
);
739 } else if (!strcasecmp(optname
, "atarirate") && optval
) {
740 pp
->atarirate
= atoi(optval
);
741 } else if (!strcasecmp(optname
, "capturerate") && optval
) {
742 pp
->capturerate
= atoi(optval
);
743 } else if (!strcasecmp(optname
, "patternrate") && optval
) {
744 pp
->patternrate
= atoi(optval
);
745 } else if (!strcasecmp(optname
, "selfatarirate") && optval
) {
746 pp
->selfatarirate
= atoi(optval
);
747 } else if (!strcasecmp(optname
, "korate") && optval
) {
748 pp
->korate
= atoi(optval
);
749 } else if (!strcasecmp(optname
, "josekirate") && optval
) {
750 pp
->josekirate
= atoi(optval
);
751 } else if (!strcasecmp(optname
, "alwaysccaprate") && optval
) {
752 pp
->alwaysccaprate
= atoi(optval
);
753 } else if (!strcasecmp(optname
, "rate") && optval
) {
755 } else if (!strcasecmp(optname
, "fillboardtries")) {
756 pp
->fillboardtries
= atoi(optval
);
757 } else if (!strcasecmp(optname
, "koage") && optval
) {
758 pp
->koage
= atoi(optval
);
759 } else if (!strcasecmp(optname
, "pattern2")) {
760 pp
->pattern2
= optval
&& *optval
== '0' ? false : true;
761 } else if (!strcasecmp(optname
, "selfatari_other")) {
762 pp
->selfatari_other
= optval
&& *optval
== '0' ? false : true;
763 } else if (!strcasecmp(optname
, "capcheckall")) {
764 pp
->capcheckall
= optval
&& *optval
== '0' ? false : true;
765 } else if (!strcasecmp(optname
, "atari_miaisafe")) {
766 pp
->atari_miaisafe
= optval
&& *optval
== '0' ? false : true;
767 } else if (!strcasecmp(optname
, "atari_def_no_hopeless")) {
768 pp
->atari_def_no_hopeless
= optval
&& *optval
== '0' ? false : true;
769 } else if (!strcasecmp(optname
, "fullchoose")) {
770 p
->choose
= optval
&& *optval
== '0' ? playout_moggy_seqchoose
: playout_moggy_fullchoose
;
771 } else if (!strcasecmp(optname
, "mqprob") && optval
) {
772 /* KO%LATARI%L2LIB%PAT3%GATARI%JOSEKI */
773 for (int i
= 0; *optval
&& i
< MQ_MAX
; i
++, optval
+= strcspn(optval
, "%")) {
775 pp
->mq_prob
[i
] = atof(optval
);
777 } else if (!strcasecmp(optname
, "tenukiprob") && optval
) {
778 pp
->tenuki_prob
= atof(optval
);
780 fprintf(stderr
, "playout-moggy: Invalid policy argument %s or missing value\n", optname
);
785 if (pp
->lcapturerate
== -1U) pp
->lcapturerate
= rate
;
786 if (pp
->atarirate
== -1U) pp
->atarirate
= rate
;
787 if (pp
->capturerate
== -1U) pp
->capturerate
= rate
;
788 if (pp
->patternrate
== -1U) pp
->patternrate
= rate
;
789 if (pp
->selfatarirate
== -1U) pp
->selfatarirate
= rate
;
790 if (pp
->korate
== -1U) pp
->korate
= rate
;
791 if (pp
->josekirate
== -1U) pp
->josekirate
= rate
;
792 if (pp
->alwaysccaprate
== -1U) pp
->alwaysccaprate
= rate
;
794 pattern3s_init(&pp
->patterns
, moggy_patterns_src
, moggy_patterns_src_n
);