Author: Gerd Isenberg
Date: 11:51:03 09/22/03
Go up one level in this thread
On September 22, 2003 at 09:16:09, Vincent Diepeveen wrote: >On September 21, 2003 at 23:25:15, Edward Seid wrote: > >>On September 21, 2003 at 21:15:06, Robert Hyatt wrote: >> >>> A chess board is a good example of an object. There is >>>no need to create a bunch of them, one is enough. I've personally seen more >>>than one _really_ elegant OO (C++) chess program that was just as fast as >>>mine (it was a bitboard program also). >> >>OK, so a chessboard is a good object for an OOP-oriented chess program. What >>other things would be good to represent as objects? >>For the chessboard and other objects, what would be the attributes and methods >>of each object? > >all bullshit of course, global arrays is more interesting to use. >even in gnuchess 4.0 (before the crappy rewrite to bitboards) > >int board[64]; // sq_a1 = 0, sq_a2 = 8, sq_h7 = 63, values 1..6 for material >int piecelist[2][16]; // having the squares for the pieces of each side >int piececnt[2]; // number of pieces minus 1 >int color[64]; // 0 = white, 1 = black, 2 = neutral >int quickboard[64]; // 12 different pieces for color specific code >int pindex[64]; // the index into piecelist > >etc. Hi Vincent, hmm, you can even put them inside a struct/class and use one "global" singleton of it - or you may use static class-members which act like globals. No runtime penalty - but better overview and flexibility - a first step. What about your NUMA approach and globals? I guess each process (thread?) has it's own "local" set of globals. About derefering via a (this) pointer: One additional register to load (on X86-64 we have some more, most likely fastcall passing). On x86-32/64 mov register,[globalAddress] is most likely few bytes longer than mov register,[register + smallOffset]. At least with a neat class with some bitboards inside. > >This is of course way easier and FASTER too than the bitboards stuff. And hopefully less (compiler?) bugs and easier to optimize! Anyway, good luck and success for Graz! Regards, Gerd Btw. is something wrong with your browser or mine? I see a lot of sibling copies of your postings. > > > >>(Sorry that I ask so many questions, but I promise the next one won't be "Write >>me code to do the above")
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.