Dull propellers at work

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Dull propellers at work

Post by Guenther »

https://github.com/BOSDOT/JOKO-TOLE

Just import another source to github. Delete a few random entries and add them again to bumb the commit history.
Permanently change the readme from 'heavy influenced by xx and yy' until 'my program XYZ 1.00 with ideas from xx and yy'.
Translate the readme to your native language. Offer it in a non-critical forum and voila...
You can even lower the estimated elo by a few hundreds or 1000 if it helps to not immediately raise suspects. Engine collector addicts won't bother anyways.

Disgusting.
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Dull propellers at work

Post by Guenther »

Another 'propeller' (already confused where to exchange Stockfish/Sugar names with fake engine names - one commit even even tells: remove
all Sugar sources lol)

Code: Select all

help:
 	@echo ""
-	@echo "To compile Nayeem , type: "
+	@echo "To compile stockfish, type: "
 	@echo ""
 	@echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]"
 	@echo ""
16 Srcs/benchmark.cpp
@@ -1,6 +1,5 @@
 /*
-  Nayeem - A UCI chess engine derived from Stockfish.
-  Copyright (C) 2016 Mohamed Nayeem
+  Nayeem - A UCI chess engine. Copyright (C) 2013-2015 Mohamed Nayeem
   Nayeem is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
@@ -13,8 +12,6 @@
   along with Nayeem. If not, see <http://www.gnu.org/licenses/>.

Code: Select all

Nayeem 6.0 - REMOVE THE SUGAR SOURCE

Nayeem 6.0 - REMOVE THE SUGAR SOURCE

    master 

1 parent 56e2dd0 commit b51636fdd2ea79cdc2c9c5b42b7de7e72be062a3 @MohamedNayeem MohamedNayeem committed 4 days ago
Showing
with 674 additions and 855 deletions. 
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

Re: Dull propellers at work

Post by velmarin »

Exactly this project is clone of that engine?
I does not recognize the code.
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Dull propellers at work

Post by Guenther »

velmarin wrote:
Exactly this project is clone of that engine?
I does not recognize the code.
Just a little snippet, but if you had looked at the kind of commits you should have realized WITHOUT knowing where it could have come from,
that it MUST be a clone.
No one reimports the complete source and then just indents and changes
names everywhere or removes one line and then adds the same line just
to bump the commit history and starts only working on translatation of ascii to javanese language - boring...

(cpp files just renamed to c files at first import - I took the search cpp of
around the same date as that ugly clone 04-09 vs. 04-12)

Code: Select all

 Update search.c

    master 

1 parent 0fad4cf commit b5be27b09a9723c2d61201679b55dfa7857af9c1 @BOSDOT BOSDOT committed on 9 Apr
Showing
with 5 additions and 6 deletions.
11 search.c
...

Code: Select all

// Record two fold stack 
         twoFoldPositions[threadID].push(b.getZobristKey());
 
         // Singular extensions
         if (depth >= 6 && reduction == 0 && extension == 0
          && m == hashed
          && abs(hashscore) < 2 * QUEEN_VALUE
          && ((hashscore >= beta && (nodeType == CUT_NODE || nodeType == PV_NODE)
                                 && hashDepth >= depth - 4)
           || (isPVNode && nodeType == PV_NODE && hashDepth >= depth - 2))) {
 
             bool isSingular = true;
 
             // Do a reduced depth search fail low check
             for (unsigned int i = 0; i < legalMoves.size(); i++) {
                 Move seMove = legalMoves.get(i);
                 Board seCopy = b.staticCopy();
                 // Search every move except the hash move
                 if (seMove == hashed)
                     continue;
                 if (!seCopy.doPseudoLegalMove(seMove, color))
                     continue;
 
                 // The window is lowered more for PV nodes and for higher depths
                 int SEWindow = isPVNode ? hashscore - 50 - 2 * depth
                                         : alpha - 10 - depth;
                 // Do a reduced search for fail-low confirmation
                 int SEDepth = isPVNode ? 2 * depth / 3 - 1
                                        : depth / 2 - 1;
 
                 parameter->ply++;
                 score = -PVS(seCopy, SEDepth, -SEWindow - 1, -SEWindow, threadID, &line);
                 parameter->ply--;
 
                 // If a move did not fail low, no singular extension
                 if (score > SEWindow) {
                     isSingular = false;
                     break;
                 }
             }
 
             // If all moves other than the hash move failed low, we extend for
             if (isSingular)
                 extension++;
         }
 
         // Reset the PV line just in case
         line.pvLength = 0;
 
         // Null-window search, with re-search if applicable
         if (movesSearched != 0) {
             parameter->ply++;
             score = -PVS(copy, depth-1-reduction+extension, -alpha-1, -alpha, threadID, &line);
             parameter->ply--;
 
             // LMR re-search if the reduced search did not fail low
             if (reduction > 0 && score > alpha) {
                 line.pvLength = 0;
                 parameter->ply++;
                 score = -PVS(copy, depth-1+extension, -alpha-1, -alpha, threadID, &line);
                 parameter->ply--;
             }
 
             // Re-search for a scout window at PV nodes
             else if (alpha < score && score < beta) {
                 line.pvLength = 0;
                 parameter->ply++;
                 score = -PVS(copy, depth-1+extension, -beta, -alpha, threadID, &line);
                 parameter->ply--;
             }
         }
 
         // The first move is always searched at a normal depth
         else {
             parameter->ply++;
             score = -PVS(copy, depth-1+extension, -beta, -alpha, threadID, &line);
             parameter->ply--;
         }
 
         // Pop the position in case we return early from this search
         twoFoldPositions[threadID].pop();
 
         // Stop condition to help break out as quickly as possible
         if (isStop || stopSignal)
             return INFTY;
         
         // Beta cutoff
         if (score >= beta) {
             searchStats->failHighs++;
             if (movesSearched == 0)
                 searchStats->firstFailHighs++;
             if (hashed != NULL_MOVE && nodeType != ALL_NODE) {
                 searchStats->hashMoveAttempts++;
                 if (m == hashed)
                     searchStats->hashMoveCuts++;
             }
 
             // Hash the cut move and score
             uint64_t hashData = packHashData(depth, m,
                 adjustHashscore(score, parameter->ply), CUT_NODE,
                 parameter->rootMoveNumber);
             transpositionTable.add(b, hashData, depth, parameter->rootMoveNumber);
 
             // Record killer if applicable
             if (!isCapture(m)) {
 
                 if (m != parameter->killers[parameter->ply][0]) {
                     parameter->killers[parameter->ply][1] =
                         parameter->killers[parameter->ply][0];
                     parameter->killers[parameter->ply][0] = m;
                 }
 
                 parameter->historyTable[color][pieceID][endSq]
                     += depth * depth;
                 moveSorter.reduceBadHistories(m);
             }
 
             changePV(m, pvLine, &line);
 
             return score;
         }
 
         if (score > bestscore) {
             bestscore = score;
             if (score > alpha) {
                 alpha = score;
                 toHash = m;
                 changePV(m, pvLine, &line);
             }
         }
 
         movesSearched++;
     }
     // End main search loop
     if (bestscore == -INFTY && movesSearched == 0)
         return scoreMate(moveSorter.isInCheck, parameter->ply);
     
     // Exact scores indicate a principal variation
     if (prevAlpha < alpha && alpha < beta) {
         if (hashed != NULL_MOVE && nodeType != ALL_NODE) {
             searchStats->hashMoveAttempts++;
             if (toHash == hashed)
                 searchStats->hashMoveCuts++;
         }
 
         uint64_t hashData = packHashData(depth, toHash,
             adjustHashscore(alpha, parameter->ply), PV_NODE,
             parameter->rootMoveNumber);
         transpositionTable.add(b, hashData, depth, parameter->rootMoveNumber);
 
         // Update the history table
         if (!isCapture(toHash)) {
             parameter->historyTable[color][b.getPieceOnSquare(color, getStartSq(toHash))][getEndSq(toHash)]
                 += depth * depth;
             moveSorter.reduceBadHistories(toHash);
         }
     }
 
     // Record all-nodes
     else if (alpha <= prevAlpha) {
         
 		// If we would have done IID
         if (!isPVNode && moveSorter.doIID()) {
             uint64_t hashData = packHashData(depth,
                 (hashed == NULL_MOVE) ? moveSorter.legalMoves.get(0) : hashed,
                 adjustHashscore(bestscore, parameter->ply), ALL_NODE,
                 parameter->rootMoveNumber);
             transpositionTable.add(b, hashData, depth, parameter->rootMoveNumber);
         }
 
         else {
             uint64_t hashData = packHashData(depth, NULL_MOVE,
                 adjustHashscore(bestscore, parameter->ply), ALL_NODE,
                 parameter->rootMoveNumber);
             transpositionTable.add(b, hashData, depth, parameter->rootMoveNumber);
         }
     }
 
     return bestscore;
 }
 
 int quiescence(Board &b, int plies, int alpha, int beta, int threadID) {
     SearchParameters *parameter = &(parameterArray[threadID]);
     SearchStatistics *searchStats = &(searchStatsArray[threadID]);
     int color = b.getPlayerToMove();
 
     // legal check 
     if (b.isInCheck(color))
         return checkQuiescence(b, plies, alpha, beta, threadID);
 
     if (b.isInsufficientMaterial())
         return 0;
     if (plies <= 2 && twoFoldPositions[threadID].find(b.getZobristKey()))
         return 0;
 
     // search hash table probe
     uint64_t hashEntry = transpositionTable.get(b);
     if (hashEntry != 0) {
         int hashscore = getHashscore(hashEntry);
 
         // Adjust the hash score
         if (hashscore >= MATE_score - MAX_DEPTH)
             hashscore -= parameter->ply + plies;
         else if (hashscore <= -MATE_score + MAX_DEPTH)
             hashscore += parameter->ply + plies;
 
         uint8_t nodeType = getHashNodeType(hashEntry);
 
         if (getHashDepth(hashEntry) >= -plies) {
             // Check for the correct node type and bounds
             if ((nodeType == ALL_NODE && hashscore <= alpha)
              || (nodeType == CUT_NODE && hashscore >= beta)
              || (nodeType == PV_NODE))
                 return hashscore;
         }
     }
 
     // Stand pat: if our current position is already way too good or way too bad
     int standPat;
     // Probe the eval cache for a saved calculation
     searchStats->evalCacheProbes++;
     int ehe = evalCache.get(b);
     if (ehe != 0) {
         searchStats->evalCacheHits++;
         standPat = ehe - EVAL_HASH_OFFSET;
     }
     else {
         standPat = (color == WHITE) ? b.evaluate() : -b.evaluate();
         evalCache.add(b, standPat);
     }
     
     // The stand pat cutoff
     if (standPat >= beta || standPat < alpha - MAX_POS_score - QUEEN_VALUE)
         return standPat;
 
     if (alpha < standPat)
         alpha = standPat;
 
     // Generate captures and order by MVV/LVA
     PieceMoveList pml = b.getPieceMoveList<PML_LEGAL_MOVES>(color);
     MoveList legalCaptures = b.getPseudoLegalCaptures(color, pml, false);
     scoreList scores;
     for (unsigned int i = 0; i < legalCaptures.size(); i++) {
         scores.add(b.getMVVLVAscore(color, legalCaptures.get(i)));
     }
     
     int bestscore = -INFTY;
     int score = -INFTY;
     unsigned int i = 0;
     unsigned int j = 0; 
     for (Move m = nextMove(legalCaptures, scores, i); m != NULL_MOVE;
               m = nextMove(legalCaptures, scores, ++i)) {
         // Delta prune
         if (standPat + b.valueOfPiece(b.getPieceOnSquare(color^1, getEndSq(m))) < alpha - MAX_POS_score)
             continue;
         // Static exchange evaluation pruning
         if (b.getExchangescore(color, m) < 0 && b.getSEEForMove(color, m) < -MAX_POS_score)
             continue;
         
         Board copy = b.staticCopy();
         if (!copy.doPseudoLegalMove(m, color))
             continue;
         
         searchStats->nodes++;
         searchStats->qsNodes++;
         score = -quiescence(copy, plies+1, -beta, -alpha, threadID);
         
         if (score >= beta) {
             searchStats->qsFailHighs++;
             if (j == 0)
                 searchStats->qsFirstFailHighs++;
 
             uint64_t hashData = packHashData(-plies, m,
                 adjustHashscore(score, parameter->ply + plies), CUT_NODE,
                 parameter->rootMoveNumber);
             transpositionTable.add(b, hashData, -plies, parameter->rootMoveNumber);
 
             return score;
         }
 
         if (score > bestscore) {
             bestscore = score;
             if (score > alpha)
                 alpha = score;
         }
 
         j++;
     }
 
     // Generate and search promotions
     MoveList legalPromotions = b.getPseudoLegalPromotions(color);
     for (unsigned int i = 0; i < legalPromotions.size(); i++) {
         Move m = legalPromotions.get(i);
 
         // Static exchange evaluation pruning
         if (b.getSEEForMove(color, m) < 0)
             continue;
 
         Board copy = b.staticCopy();
         if (!copy.doPseudoLegalMove(m, color))
             continue;
         
         searchStats->nodes++;
         searchStats->qsNodes++;
         score = -quiescence(copy, plies+1, -beta, -alpha, threadID);
         
         if (score >= beta) {
             searchStats->qsFailHighs++;
             if (j == 0)
                 searchStats->qsFirstFailHighs++;
 
             uint64_t hashData = packHashData(-plies, m,
                 adjustHashscore(score, parameter->ply + plies), CUT_NODE,
                 parameter->rootMoveNumber);
             transpositionTable.add(b, hashData, -plies, parameter->rootMoveNumber);
 
             return score;
         }
 
         if (score > bestscore) {
             bestscore = score;
             if (score > alpha)
                 alpha = score;
         }
 
         j++;
     }
 
     // Checks: only on the first two plies of q-search
     if (plies <= 1) {
         MoveList legalMoves = b.getPseudoLegalChecks(color);
 
         for (unsigned int i = 0; i < legalMoves.size(); i++) {
             Move m = legalMoves.get(i);
 
             // Static exchange evaluation pruning
             if (b.getSEEForMove(color, m) < 0)
                 continue;
 
             Board copy = b.staticCopy();
             if (!copy.doPseudoLegalMove(m, color))
                 continue;
             
             searchStats->nodes++;
             searchStats->qsNodes++;
             twoFoldPositions[threadID].push(b.getZobristKey());
 
             int score = -checkQuiescence(copy, plies+1, -beta, -alpha, threadID);
             
             twoFoldPositions[threadID].pop();
 
             if (score >= beta) {
                 searchStats->qsFailHighs++;
                 if (j == 0)
                     searchStats->qsFirstFailHighs++;
 
                 uint64_t hashData = packHashData(-plies, m,
                     adjustHashscore(score, parameter->ply + plies), CUT_NODE,
                     parameter->rootMoveNumber);
                 transpositionTable.add(b, hashData, -plies, parameter->rootMoveNumber);
 
                 return score;
             }
 
             if (score > bestscore) {
                 bestscore = score;
                 if (score > alpha)
                     alpha = score;
             }
 
             j++;
         }
     }

Code: Select all

jeffreyan11/uci-chess-engine
Code
Issues 0
Pull requests 0
Pulse
Graphs
uci-chess-engine/search.cpp
e8dee97 on 12 Apr
@jeffreyan11 jeffreyan11 Adjusted aspiration window parameters.
@jeffreyan11
@man4
1535 lines (1286 sloc) 54.3 KB
/*
    Laser, a UCI chess engine written in C++11.
    Copyright 2015-2016 Jeffrey An and Michael An
    Laser is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    Laser is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Laser.  If not, see <http://www.gnu.org/licenses/>.
*/
...

Code: Select all

        // Record two-fold stack since we may do a search for singular extensions
        twoFoldPositions[threadID].push(b.getZobristKey());

        // Singular extensions
        // If one move appears to be much better than all others, extend the move
        if (depth >= 6 && reduction == 0 && extension == 0
         && m == hashed
         && abs(hashScore) < 2 * QUEEN_VALUE
         && ((hashScore >= beta && (nodeType == CUT_NODE || nodeType == PV_NODE)
                                && hashDepth >= depth - 4)
          || (isPVNode && nodeType == PV_NODE && hashDepth >= depth - 2))) {

            bool isSingular = true;

            // Do a reduced depth search with a lowered window for a fail low check
            for (unsigned int i = 0; i < legalMoves.size(); i++) {
                Move seMove = legalMoves.get(i);
                Board seCopy = b.staticCopy();
                // Search every move except the hash move
                if (seMove == hashed)
                    continue;
                if (!seCopy.doPseudoLegalMove(seMove, color))
                    continue;

                // The window is lowered more for PV nodes and for higher depths
                int SEWindow = isPVNode ? hashScore - 50 - 2 * depth
                                        : alpha - 10 - depth;
                // Do a reduced search for fail-low confirmation
                int SEDepth = isPVNode ? 2 * depth / 3 - 1
                                       : depth / 2 - 1;

                searchParams->ply++;
                score = -PVS(seCopy, SEDepth, -SEWindow - 1, -SEWindow, threadID, &line);
                searchParams->ply--;

                // If a move did not fail low, no singular extension
                if (score > SEWindow) {
                    isSingular = false;
                    break;
                }
            }

            // If all moves other than the hash move failed low, we extend for
            // the singular move
            if (isSingular)
                extension++;
        }

        // Reset the PV line just in case
        line.pvLength = 0;

        // Null-window search, with re-search if applicable
        if (movesSearched != 0) {
            searchParams->ply++;
            score = -PVS(copy, depth-1-reduction+extension, -alpha-1, -alpha, threadID, &line);
            searchParams->ply--;

            // LMR re-search if the reduced search did not fail low
            if (reduction > 0 && score > alpha) {
                line.pvLength = 0;
                searchParams->ply++;
                score = -PVS(copy, depth-1+extension, -alpha-1, -alpha, threadID, &line);
                searchParams->ply--;
            }

            // Re-search for a scout window at PV nodes
            else if (alpha < score && score < beta) {
                line.pvLength = 0;
                searchParams->ply++;
                score = -PVS(copy, depth-1+extension, -beta, -alpha, threadID, &line);
                searchParams->ply--;
            }
        }

        // The first move is always searched at a normal depth
        else {
            searchParams->ply++;
            score = -PVS(copy, depth-1+extension, -beta, -alpha, threadID, &line);
            searchParams->ply--;
        }

        // Pop the position in case we return early from this search
        twoFoldPositions[threadID].pop();

        // Stop condition to help break out as quickly as possible
        if (isStop || stopSignal)
            return INFTY;
        
        // Beta cutoff
        if (score >= beta) {
            searchStats->failHighs++;
            if (movesSearched == 0)
                searchStats->firstFailHighs++;
            if (hashed != NULL_MOVE && nodeType != ALL_NODE) {
                searchStats->hashMoveAttempts++;
                if (m == hashed)
                    searchStats->hashMoveCuts++;
            }

            // Hash the cut move and score
            uint64_t hashData = packHashData(depth, m,
                adjustHashScore(score, searchParams->ply), CUT_NODE,
                searchParams->rootMoveNumber);
            transpositionTable.add(b, hashData, depth, searchParams->rootMoveNumber);

            // Record killer if applicable
            if (!isCapture(m)) {
                // Ensure the same killer does not fill both slots
                if (m != searchParams->killers[searchParams->ply][0]) {
                    searchParams->killers[searchParams->ply][1] =
                        searchParams->killers[searchParams->ply][0];
                    searchParams->killers[searchParams->ply][0] = m;
                }
                // Update the history table
                searchParams->historyTable[color][pieceID][endSq]
                    += depth * depth;
                moveSorter.reduceBadHistories(m);
            }

            changePV(m, pvLine, &line);

            return score;
        }

        // If alpha was raised, we have a new PV
        if (score > bestScore) {
            bestScore = score;
            if (score > alpha) {
                alpha = score;
                toHash = m;
                changePV(m, pvLine, &line);
            }
        }

        movesSearched++;
    }
    // End main search loop


    // If there were no legal moves
    if (bestScore == -INFTY && movesSearched == 0)
        return scoreMate(moveSorter.isInCheck, searchParams->ply);
    
    // Exact scores indicate a principal variation
    if (prevAlpha < alpha && alpha < beta) {
        if (hashed != NULL_MOVE && nodeType != ALL_NODE) {
            searchStats->hashMoveAttempts++;
            if (toHash == hashed)
                searchStats->hashMoveCuts++;
        }

        uint64_t hashData = packHashData(depth, toHash,
            adjustHashScore(alpha, searchParams->ply), PV_NODE,
            searchParams->rootMoveNumber);
        transpositionTable.add(b, hashData, depth, searchParams->rootMoveNumber);

        // Update the history table
        if (!isCapture(toHash)) {
            searchParams->historyTable[color][b.getPieceOnSquare(color, getStartSq(toHash))][getEndSq(toHash)]
                += depth * depth;
            moveSorter.reduceBadHistories(toHash);
        }
    }

    // Record all-nodes. No best move can be recorded.
    else if (alpha <= prevAlpha) {
        // If we would have done IID, save the hash/IID move so we don't have to
        // waste computation for it next time
        if (!isPVNode && moveSorter.doIID()) {
            uint64_t hashData = packHashData(depth,
                (hashed == NULL_MOVE) ? moveSorter.legalMoves.get(0) : hashed,
                adjustHashScore(bestScore, searchParams->ply), ALL_NODE,
                searchParams->rootMoveNumber);
            transpositionTable.add(b, hashData, depth, searchParams->rootMoveNumber);
        }
        // Otherwise, just store no best move as expected
        else {
            uint64_t hashData = packHashData(depth, NULL_MOVE,
                adjustHashScore(bestScore, searchParams->ply), ALL_NODE,
                searchParams->rootMoveNumber);
            transpositionTable.add(b, hashData, depth, searchParams->rootMoveNumber);
        }
    }

    return bestScore;
}


/* Quiescence search, which completes all capture and check lines (thus reaching
 * a "quiet" position.)
 * This diminishes the horizon effect and greatly improves playing strength.
 * Delta pruning and static-exchange evaluation are used to reduce the time
 * spent here.
 * The search is done within a fail-soft framework.
 */
int quiescence(Board &b, int plies, int alpha, int beta, int threadID) {
    SearchParameters *searchParams = &(searchParamsArray[threadID]);
    SearchStatistics *searchStats = &(searchStatsArray[threadID]);
    int color = b.getPlayerToMove();

    // If in check, we must consider all legal check evasions
    if (b.isInCheck(color))
        return checkQuiescence(b, plies, alpha, beta, threadID);

    if (b.isInsufficientMaterial())
        return 0;
    if (plies <= 2 && twoFoldPositions[threadID].find(b.getZobristKey()))
        return 0;

    // Qsearch hash table probe
    uint64_t hashEntry = transpositionTable.get(b);
    if (hashEntry != 0) {
        int hashScore = getHashScore(hashEntry);

        // Adjust the hash score to mate distance from root if necessary
        if (hashScore >= MATE_SCORE - MAX_DEPTH)
            hashScore -= searchParams->ply + plies;
        else if (hashScore <= -MATE_SCORE + MAX_DEPTH)
            hashScore += searchParams->ply + plies;

        uint8_t nodeType = getHashNodeType(hashEntry);
        // Only used a hashed score if the search depth was at least
        // the current depth
        if (getHashDepth(hashEntry) >= -plies) {
            // Check for the correct node type and bounds
            if ((nodeType == ALL_NODE && hashScore <= alpha)
             || (nodeType == CUT_NODE && hashScore >= beta)
             || (nodeType == PV_NODE))
                return hashScore;
        }
    }


    // Stand pat: if our current position is already way too good or way too bad
    // we can simply stop the search here.
    int standPat;
    // Probe the eval cache for a saved calculation
    searchStats->evalCacheProbes++;
    int ehe = evalCache.get(b);
    if (ehe != 0) {
        searchStats->evalCacheHits++;
        standPat = ehe - EVAL_HASH_OFFSET;
    }
    else {
        standPat = (color == WHITE) ? b.evaluate() : -b.evaluate();
        evalCache.add(b, standPat);
    }
    
    // The stand pat cutoff
    if (standPat >= beta || standPat < alpha - MAX_POS_SCORE - QUEEN_VALUE)
        return standPat;

    if (alpha < standPat)
        alpha = standPat;


    // Generate captures and order by MVV/LVA
    PieceMoveList pml = b.getPieceMoveList<PML_LEGAL_MOVES>(color);
    MoveList legalCaptures = b.getPseudoLegalCaptures(color, pml, false);
    ScoreList scores;
    for (unsigned int i = 0; i < legalCaptures.size(); i++) {
        scores.add(b.getMVVLVAScore(color, legalCaptures.get(i)));
    }
    
    int bestScore = -INFTY;
    int score = -INFTY;
    unsigned int i = 0;
    unsigned int j = 0; // separate counter only incremented when valid move is searched
    for (Move m = nextMove(legalCaptures, scores, i); m != NULL_MOVE;
              m = nextMove(legalCaptures, scores, ++i)) {
        // Delta prune
        if (standPat + b.valueOfPiece(b.getPieceOnSquare(color^1, getEndSq(m))) < alpha - MAX_POS_SCORE)
            continue;
        // Static exchange evaluation pruning
        if (b.getExchangeScore(color, m) < 0 && b.getSEEForMove(color, m) < -MAX_POS_SCORE)
            continue;
        

        Board copy = b.staticCopy();
        if (!copy.doPseudoLegalMove(m, color))
            continue;
        
        searchStats->nodes++;
        searchStats->qsNodes++;
        score = -quiescence(copy, plies+1, -beta, -alpha, threadID);
        
        if (score >= beta) {
            searchStats->qsFailHighs++;
            if (j == 0)
                searchStats->qsFirstFailHighs++;

            uint64_t hashData = packHashData(-plies, m,
                adjustHashScore(score, searchParams->ply + plies), CUT_NODE,
                searchParams->rootMoveNumber);
            transpositionTable.add(b, hashData, -plies, searchParams->rootMoveNumber);

            return score;
        }

        if (score > bestScore) {
            bestScore = score;
            if (score > alpha)
                alpha = score;
        }

        j++;
    }

    // Generate and search promotions
    MoveList legalPromotions = b.getPseudoLegalPromotions(color);
    for (unsigned int i = 0; i < legalPromotions.size(); i++) {
        Move m = legalPromotions.get(i);

        // Static exchange evaluation pruning
        if (b.getSEEForMove(color, m) < 0)
            continue;

        Board copy = b.staticCopy();
        if (!copy.doPseudoLegalMove(m, color))
            continue;
        
        searchStats->nodes++;
        searchStats->qsNodes++;
        score = -quiescence(copy, plies+1, -beta, -alpha, threadID);
        
        if (score >= beta) {
            searchStats->qsFailHighs++;
            if (j == 0)
                searchStats->qsFirstFailHighs++;

            uint64_t hashData = packHashData(-plies, m,
                adjustHashScore(score, searchParams->ply + plies), CUT_NODE,
                searchParams->rootMoveNumber);
            transpositionTable.add(b, hashData, -plies, searchParams->rootMoveNumber);

            return score;
        }

        if (score > bestScore) {
            bestScore = score;
            if (score > alpha)
                alpha = score;
        }

        j++;
    }

    // Checks: only on the first two plies of q-search
    if (plies <= 1) {
        MoveList legalMoves = b.getPseudoLegalChecks(color);

        for (unsigned int i = 0; i < legalMoves.size(); i++) {
            Move m = legalMoves.get(i);

            // Static exchange evaluation pruning
            if (b.getSEEForMove(color, m) < 0)
                continue;

            Board copy = b.staticCopy();
            if (!copy.doPseudoLegalMove(m, color))
                continue;
            
            searchStats->nodes++;
            searchStats->qsNodes++;
            twoFoldPositions[threadID].push(b.getZobristKey());

            int score = -checkQuiescence(copy, plies+1, -beta, -alpha, threadID);
            
            twoFoldPositions[threadID].pop();

            if (score >= beta) {
                searchStats->qsFailHighs++;
                if (j == 0)
                    searchStats->qsFirstFailHighs++;

                uint64_t hashData = packHashData(-plies, m,
                    adjustHashScore(score, searchParams->ply + plies), CUT_NODE,
                    searchParams->rootMoveNumber);
                transpositionTable.add(b, hashData, -plies, searchParams->rootMoveNumber);

                return score;
            }

            if (score > bestScore) {
                bestScore = score;
                if (score > alpha)
                    alpha = score;
            }

            j++;
        }
    }
Dann Corbit
Posts: 12870
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Dull propellers at work

Post by Dann Corbit »

Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

Re: Dull propellers at work

Post by velmarin »

Guenther wrote:
velmarin wrote:
Exactly this project is clone of that engine?
I does not recognize the code.

Code: Select all

jeffreyan11/uci-chess-engine
Code
Issues 0
Pull requests 0
Pulse
Graphs
uci-chess-engine/search.cpp
e8dee97 on 12 Apr
@jeffreyan11 jeffreyan11 Adjusted aspiration window parameters.
@jeffreyan11
@man4
1535 lines (1286 sloc) 54.3 KB
/*
    Laser, a UCI chess engine written in C++11.
    Copyright 2015-2016 Jeffrey An and Michael An
    Laser is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    Laser is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Laser.  If not, see <http://www.gnu.org/licenses/>.
*/
I thought I have asked politely.

Then the answer is this, not to lack all the code.
I seemed to see interesting things to learn.

Thanks a lot. :D
tmokonen
Posts: 1367
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: Dull propellers at work

Post by tmokonen »

Maybe one day he'll figure out that all of his so-called 32 bit compiles are actually 64 bit executables.
jeffreyan11
Posts: 46
Joined: Sat Sep 12, 2015 5:23 am
Location: United States

Re: Dull propellers at work

Post by jeffreyan11 »

Thanks for pointing this out, Guenther.

I don't know whether to be flattered that they copied our engine, sad/disgusted that they gave no credit and tried to hide the fact that they copied, or amused by what they changed... (evalhash.cpp -> zobrist.c ????)