From 09b69c3344a6f4c8683db13d20c6f20a0279c399 Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Fri, 13 May 2011 17:12:58 +0200 Subject: [PATCH] Fix parsing of mqprob, moves & handicap_value parameters --- playout/moggy.c | 5 +++-- uct/dynkomi.c | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/playout/moggy.c b/playout/moggy.c index cb77643..af84e25 100644 --- a/playout/moggy.c +++ b/playout/moggy.c @@ -982,9 +982,10 @@ playout_moggy_init(char *arg, struct board *b, struct joseki_dict *jdict) p->choose = optval && *optval == '0' ? playout_moggy_seqchoose : playout_moggy_fullchoose; } else if (!strcasecmp(optname, "mqprob") && optval) { /* KO%LATARI%L2LIB%LNLIB%PAT3%GATARI%JOSEKI%NAKADE */ - for (int i = 0; *optval && i < MQ_MAX; i++, optval += strcspn(optval, "%")) { - optval++; + for (int i = 0; *optval && i < MQ_MAX; i++) { pp->mq_prob[i] = atof(optval); + optval += strcspn(optval, "%"); + if (*optval) optval++; } } else if (!strcasecmp(optname, "tenukiprob") && optval) { pp->tenuki_prob = atof(optval); diff --git a/uct/dynkomi.c b/uct/dynkomi.c index 0ec214b..4f8ad02 100644 --- a/uct/dynkomi.c +++ b/uct/dynkomi.c @@ -121,16 +121,18 @@ uct_dynkomi_init_linear(struct uct *u, char *arg, struct board *b) /* Dynamic komi in handicap game; linearly * decreases to basic settings until move * #optval. moves=blackmoves%whitemoves */ - for (int i = S_BLACK; *optval && i <= S_WHITE; i++, optval += strcspn(optval, "%")) { - optval++; + for (int i = S_BLACK; *optval && i <= S_WHITE; i++) { l->moves[i] = atoi(optval); + optval += strcspn(optval, "%"); + if (*optval) optval++; } } else if (!strcasecmp(optname, "handicap_value") && optval) { /* Point value of single handicap stone, * for dynkomi computation. */ - for (int i = S_BLACK; *optval && i <= S_WHITE; i++, optval += strcspn(optval, "%")) { - optval++; + for (int i = S_BLACK; *optval && i <= S_WHITE; i++) { l->handicap_value[i] = atoi(optval); + optval += strcspn(optval, "%"); + if (*optval) optval++; } } else if (!strcasecmp(optname, "rootbased")) { /* If set, the extra komi applied will be -- 2.11.4.GIT