[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/games/draughts/src
From:       Piotr Banasiak <piotrbanasiak () onet ! pl>
Date:       2006-12-31 18:10:00
Message-ID: 1167588600.434276.28906.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 618247 by banasiak:

fixed bugs with using hash table, added more tests (all test passed).


 M  +22 -30    abstractenginet.h  


--- trunk/playground/games/draughts/src/abstractenginet.h #618246:618247
@@ -147,7 +147,7 @@
 {
    pH=0;
    pEI=new EngineInfo();
-   focusedAllowed=false;
+   focusedAllowed=true;
    randomness=0;//5
    
    focus1=800;
@@ -726,16 +726,23 @@
       hN.max = updateWinLoseScores(hN.max, -level);
     
       #ifdef test_on
-      int tmpBestMove=-1;
-      int correct=pureAlfaBeta( MoveList, tmpBestMove, pBoard, level, -INF, INF,  hN.depth );
-      if( correct<hN.min  or correct>hN.max  )
+      if ( hN.depth == Depth-level )//and level>pBoard->moveNr )//ourRequested Depth
       {
-          uint key = qHash(*pBoard);qDebug( "key %d", key);
-          Q_ASSERT( correct>=hN.min  and correct<=hN.max );
-      }
-      #endif
+          
+          int tmpBestMove=-1;
+          int correct=pureAlfaBeta( MoveList, tmpBestMove, pBoard, level, -INF, INF,  hN.depth+level );
+          if( correct<hN.min  or correct>hN.max  )
+          {
+              uint key = qHash(*pBoard);qDebug( "key %d", key);
+              qDebug("level %d hN.depth %d/%d min %d,max %d,correct %d",
+                      level,  hN.depth, Depth-level,hN.min,hN.max,correct);
+              Q_ASSERT( correct>=hN.min  and correct<=hN.max );
+          }
+      #else
       if ( hN.depth >= Depth-level )//and level>pBoard->moveNr )//ourRequested Depth
       {
+      #endif
+      
           if(hN.min>=beta)
           { 
              return hN.min;
@@ -802,30 +809,14 @@
   if( level>=newDepth )
      canOpCapt = canOpponentCapture( *pBoard );// check only when level>Depth
      
-//   {
-//     //debug code
-//     BoardT<T> b1(*pBoard);
-//     b1.moveNr++;
-//     
-//     QList<LegalMoveT<T> > newMoveList;
-//     genPossibleMoves( newMoveList , &b1 );
-//     LegalMoveT<T> *pLM= &(newMoveList[0]);
-//     bool opMustCapture = pLM->captured;
-//     if( opMustCapture!=canOpCapt )
-//     {
-//            printMoves( newMoveList );
-//            LegalMove xx;
-//            xx.debug();
-//            bool canOpCapt2 = canOpponentCapture( *pBoard );
-//     }
-//   }
+
+  int matScore=-INF;
   
-  int matScore=materialScore( pBoard );
-  
   // focused search 
   // current player is not in forced move , so perhaps opponent made unnecessary sacryfice
   if( focusedAllowed && (moves>2) && (!mustCapture)  )//&& (!canOpCapt)
   {
+    matScore=materialScore( pBoard );
     if( (matScore > beta+focus1 ) )
     {
          newDepth=Depth-1;
@@ -847,6 +838,7 @@
     {
       //qDebug( "leaf level:%d score:%d", level, matScore);
       //when calculate material score then does not return bestmove
+      matScore=materialScore( pBoard );
       if(pEI) pEI->leafNodes++;
       return matScore;
     }
@@ -988,7 +980,7 @@
     int correctScore=pureAlfaBeta( MoveList, tmpBestMove, pBoard, level, -INF, INF,  newDepth );
     qDebug("level %*d  newDepth %d, alfaBeta(%d,%d)bestScore %d correctScore %d",
             2*level+1,level,newDepth, alfa,beta, bestScore, correctScore);
-    Q_ASSERT( correctScore<=alfa  );
+    Q_ASSERT( correctScore<=hn.max  );
     #endif
     
     hn.min = updateWinLoseScores(hn.min, level);
@@ -1001,8 +993,8 @@
   {
     HashNode<LegalMoveT<T> > hn;
     hn.depth=Depth-level;
-    hn.min=bestScore;
-    hn.max=bestScore;
+    hn.min=alfa;
+    hn.max=alfa;
     hn.MoveList=MoveList;
     
     hn.min = updateWinLoseScores(hn.min, level);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic