From 6afdf5802b6a0a7c909708a1b5b305b7b99a081b Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 28 Jun 2010 16:48:52 +0200 Subject: [PATCH] playout_elo_choose(): Make sure the ignores[] list is sorted --- playout/elo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/playout/elo.c b/playout/elo.c index 183d0f9..1e63d5d 100644 --- a/playout/elo.c +++ b/playout/elo.c @@ -183,6 +183,13 @@ playout_elo_choose(struct playout_policy *p, struct board *b, enum stone to_play #define ignore_move(c_) do { \ ignores[ignores_n++] = c_; \ + if (ignores_n > 1 && ignores[ignores_n - 1] < ignores[ignores_n - 2]) { \ + /* Keep ignores[] sorted. We abuse the fact that we know \ + * only one item can be out-of-order. */ \ + coord_t cc = ignores[ignores_n - 2]; \ + ignores[ignores_n - 2] = ignores[ignores_n - 1]; \ + ignores[ignores_n - 1] = cc; \ + } \ int rowi = c_ / pd->n1; \ lpd.browtotals_i[lpd.browtotals_n] = rowi; \ lpd.browtotals_v[lpd.browtotals_n++] = pd->rowtotals[rowi]; \ -- 2.11.4.GIT