Steve Maughan wrote:Tord Romstad wrote:Just like you, I try to avoid color-dependent code whenever possible.
Tord
Writing none color dependent code is new for me. But the main aim of this major revision of Monarch is to write bug free code.
In my experience, color independent code makes it easier to achieve this aim. Back in the days when I still wrote color dependent code, my usual technique was to first write the code for white, and then make a copy of the code where I manually replaced '+' with '-', '>' with '<', WHITE_ROOK with BLACK_ROOK and so on. Of course, I often forgot something.
Steve Maughan wrote:I'm trying to write a test procedure for *every* routine - as well as liberal "asserts" in the code. Previous versions were just too complex / buggy to scale - a sentiment that you've expressed many times.
Yes. Like most of us, I learned this the hard way.
Dieter B?r?ner wrote:Another observation: Steve's code obviously depends on the "row length" of the board. Tord's expression doesn't. Both assume "row first" layout, however.
As far as I can see, my expression would work equally well in a "column first" board layout (if the phrases "row first" and "column first" mean what I think). Of course it would break in "diagonal first" and similar exotic layouts.
Thanks for the low-level optimization advice, by the way. Although we all agree that the difference would be insignificant in the case we are discussing, your advice could prove to be helpful in other contexts.
Tord