http://rybkaforum.net/cgi-bin/rybkaforu ... ;#pid20132Vasik Rajlich wrote:All right, fine - here's white knight captures:
Code: Select all
for (bb_t knights = Board.pieces [WN]; knights; knights &= knights-1) { int knight_sq = bit_scan (knights); for (bb_t captures = knight_moves [knight_sq] & opponent_pieces; captures; captures &= captures - 1) { int capture_sq = bit_scan (captures); *moves ++ = move (knight_sq, capture_sq); *values ++ = Board.sq [capture_sq] * 256 + 192; } }
Rybka source code - this time for real!
Moderator: Ras
Rybka source code - this time for real!
Well, a tiny part of it anyway.
-
- Posts: 224
- Joined: Mon Mar 12, 2007 7:31 pm
- Location: Bonn, Germany
Re: Rybka source code - this time for real!
Not a big surprise but the straightforward way to create knight captures in a bitboard engine. My code amounts to almost exactly the same, though the style is a bit different. Nice to see that Rybka also has an array Board.sq, in addition to the bitboards. Seems to be indexed by 0..63, so without dummy squares (otherwise you could not use the bitscan result directly to access it).
The only thing in the Rybka fragment that not everyone does is to create the values (seems to be mvv-lva) along with the moves rather than delaying it. As I think over it, this could mean a small speedup for my engine too.
The only thing in the Rybka fragment that not everyone does is to create the values (seems to be mvv-lva) along with the moves rather than delaying it. As I think over it, this could mean a small speedup for my engine too.
-
- Posts: 224
- Joined: Mon Mar 12, 2007 7:31 pm
- Location: Bonn, Germany
Re: Rybka source code - this time for real!
Another thing is that there is "Board" rather then "board" This might be just a coincidence, but it might also indicate that there is one global board rather than a parameter. Of course this speeds up the engine, but it makes debugging and modifications more difficult. I'm not sure if I would like to have it.
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Rybka source code - this time for real!
Symbolic merges white and black capture generation; here's the analogous knight code:
Code: Select all
case CTPieceKnight:
{
CTBB theToBB = RefAttackFrSq(theFrSq) & thePasLocusBB;
CTSq theToSq;
CTScanBB(theToSq, theToBB)
{
theMove.PutToSq(theToSq);
theMove.PutToMan(theBoard.GetSqMan(theToSq));
theMLPtr->ATM(theMove);
};
theMove.PutToMan(CTManVacant);
};
break;