[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] Looping over the board
From: |
Gunnar Farnebäck |
Subject: |
Re: [gnugo-devel] Looping over the board |
Date: |
Mon, 17 Jan 2005 03:57:41 +0100 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI) |
Arend wrote:
> An alternative, admittedly uglier solution would be
Well, that construction obviously has to be used as a macro but if
we're going to use a macro anyway it seems better not to have an
indexing matrix that needs to be kept in sync with board_size.
> #define LOOP_BOARD(pos) \
> for (pos = BOARDMIN; pos < BOARDMAX; \
> (ON_BOARD(pos++) ? pos : pos = pos + 1 + MAX_BOARD - boardsize))
That was obviously untested code. I assume you meant
#define LOOP_BOARD(pos) \
for (pos = BOARDMIN; pos < BOARDMAX; \
pos += ON_BOARD(pos + 1) ? 1 : MAX_BOARD - board_size + 2)
:-)
> > The drawback of the last construction is that it's doing a somewhat
> > scary amount of preprocesser magic, hiding a complete for statement in
> > a macro.
> Well, if you suggest it the preprocessor magic cannot be that scary :)
It's a borderline case. I've tested running the loop macro in gdb and
it behaves well, so that is at least not a problem.
> Despite my performance objection I am in favor of your proposal, since
> none of the current board loops are performance critical; we should just
> keep in mind to possibly not use it where loops could become
> bottlenecks.
Yes, we shouldn't really be looping over the board in time critical
code at all.
/Gunnar
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [gnugo-devel] Looping over the board,
Gunnar Farnebäck <=