[computer-go] Orego's Adventures in C++
Darren Cook
darren at dcook.org
Mon Aug 7 16:34:25 PDT 2006
Hi Peter,
I'm keen to see how you get on, both in terms of effort and in terms of
any performance gain you get.
> ours. That said, if anyone has algorithmic or idiomatic suggestions,
> we'd be happy to hear them. Our C++ probably has a thick Java accent
> right now, but hopefully that will change in the next couple of weeks.
The size-specific types have _t appended. E.g. int8_t, uint32_t,
uint64_t, etc.
I'd suggest wrapping your code in a namespace. I also prefer to not do
"using namespace std" and instead put a std:: prefix when calling
standard library functions. It makes it easier for me to see at a glance
the external libraries I am using.
You can put everything in the .h file, and have no .cpp file. This is
considered more modern C++ style, a la Boost (and is also more java
like). Sometimes you have no choice of course, and you need a cpp file.
Using all .h files can also increase compilation times (as changing a
function body can cause more recompilation).
I have this in my code:
typedef unsigned short int BIX;
(where BIX stands for "Board Index"). This not only makes the code less
verbose it also makes it easy to try other data sizes. E.g. my code
actually looks like this:
#ifdef use_BIX_short
typedef unsigned short BIX;
#else
typedef unsigned int BIX;
#endif
Using an int was 5% quicker last time I tested, so is the default.
Darren
More information about the computer-go
mailing list