Geschrieben von:/Posted by: Dann Corbit at 16 September 2004 19:18:35:
Als Antwort auf:/In reply to: Re: Super Tournament III Qualifier (after 74 of 76 rounds at 40 in 40) geschrieben von:/posted by: Lance Perkins at 16 September 2004 02:28:11:
Here is the answer for the inquiring minds: The Thinker source code is only slightly longer than TSCP.
The next release (in a few weeks) of Thinker will even be smaller (from 77K to 69K). I am replacing all of the experimental code with better implementation, now that I am contented with the results.
I have below an example of the efficient coding that is in Thinker. This is the entire move generator (the GeneratePawnMoves is similar to the GeneratePieceMoves). Other implementations that also use bitboards have at least five times the source code compared to my implementation.
>TMove *CPosition::GeneratePieceMoves (TMove *pmoves, TBitBoard target)
>{
>    TBitBoard pieces = AllPieces (wtm) ^ Pawns (wtm);
>    while (pieces)
>    {
>        TBitBoard moves;
>        TSquare from = FindBitAndClear(pieces);
>        TPieceType pct = PieceType (BoardPiece (from));
>        switch (pct)
>        {
>            case Knight:
>                moves = KnightAttacks (from) & target;
>                break;
>            case Bishop:
>                moves = BishopAttacks (from) & target;
>                break;
>            case Rook:
>                moves = RookAttacks (from) & target;
>                break;
>            case Queen:
>                moves = QueenAttacks (from) & target;
>                break;
>            case King:
>                moves = KingAttacks (from) & target;
>                break;
>        }
>        if (moves)
>        {
>            TMove mv = MvMkFrom (from) + MvMkPiece (pct);
>            do
>            {
>                TSquare to = FindBitAndClear(moves);
>                *pmoves++ = mv | MvMkTo (to) | CaptureOnSq (to);
>            }
>            while (moves);
>        }
>    }
>    return (pmoves);
>}
>#define EmptySquares() (~(AllPieces(White)|AllPieces(Black)))
>TMove *CPosition::GenerateCaptureAndPromotionMoves (TMove *pmoves) // used by q-search and gen-all-moves
>{
>    pmoves = GeneratePieceMoves (pmoves, AllPieces (Opponent (wtm)));
>    return GeneratePawnMoves (pmoves, AllPieces (Opponent (wtm)) | c_PromotionSquares);
>}
>TMove *CPosition::GenerateNonCaptureMoves (TMove *pmoves)
>{
>    pmoves = GeneratePieceMoves (pmoves, EmptySquares());
>    return GeneratePawnMoves (pmoves, EmptySquares() | c_NonPromotionSquares);
>}
>TMove *CPosition::GenerateAllMoves (TMove *pmoves)
>{
>    pmoves = GenerateCaptureAndPromotionMoves (pmoves);
>    return GenerateNonCaptureMoves (pmoves);
>}
>
Well, that's just what I was afraid of. You're smarter than the rest of us.
Now, I am not being facetious. My notion of genius is to take a compilcated problem and reduce it to the simplest, elegant solution. See (for example):
http://richardrplourde.home.comcast.net ... ivity.htmlmy ftp site {remove http:// unless you like error messages}