On 11/01/2010 07:45 AM, Steven wrote:

Hi!

Thanks for the the pointers as to what is happening, and good luck with it.

I did have one idea today for a quick *hack* to fix the initial bug... Since using a book seems to work around the issue, perhaps we can quietly , always "use book", but once in the use book code, we can check a new var (for eg "phonybook", or setting "::wentOutOfBook" to -1), and only *report* out of book if we really want to.


Lol. Please....


Steven



Attached a second attempt, with test results :-)

The pgn contains 4 sets of the three pgn games with some variations added.

Set 1 (games 1..3) are the original games put into analysis.
Set 2 is after annotation of all moves without book
Set 3 is after annotation of all moves with book
Set 4 is atter annotation of blunders (0.2) only, without book

This one looks really promising. I hope it works alright. Please confirm.

Improved:
* implemented state machinery as suggested in earlier posting
* Book analysis is done in real user time and before the engine is started (no clueless thinking at the initial position to only swiftly enter book analysis after that!)
* Added engine thinking time to the annotator string

Remaining stuff to be done, but only after this bit of work is done (!)
* Last move in any variation is analysed but not annotated. This is/was explicitly excluded in the code, but I see no reason for it, except that the current implementation meets some trouble with inserting the variation (and only once). Should be analyzed and corrected. Will do so. * With book annotation enabled, variations in the game that happen before the game goes out of book are not annotated (not even analyzed). I am not completely sure whether such analysis would actually be desirable (and if so, by book as well?). In any case, with the current ~design~ this is hardly possible to correct.

Cheers,
Joost.
Index: tcl/main.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/main.tcl,v
retrieving revision 1.48
diff -U3 -r1.48 main.tcl
--- tcl/main.tcl        30 Jun 2010 20:41:45 -0000      1.48
+++ tcl/main.tcl        1 Nov 2010 23:06:22 -0000
@@ -1641,11 +1641,13 @@
 #
 
################################################################################
 proc toggleAutoplay { } {
-    global autoplayMode
+    global autoplayMode autoplayDelay
     if {$autoplayMode == 0} {
         set autoplayMode 1
         .main.fbutton.button.autoplay configure -image autoplay_on -relief 
sunken
-        autoplay
+        # Start with an inital delay
+        # It gives the engine time to settle
+        after $autoplayDelay autoplay
     } else {
         cancelAutoplay
     }
@@ -1660,24 +1662,33 @@
     if {$autoplayMode == 0} { return }
     
     if {$annotateMode} {
-        if { ![sc_pos isAt start] } { addAnnotation }
+        addAnnotation
     }
     
     # stop game annotation when out of opening
     if { $::isBatch && $annotateMode && $::isBatchOpening && \
                 [sc_pos moveNumber] > $::isBatchOpeningMoves } {
         sc_game save [sc_game number]
+        # Stop the engine
+        toggleEngineAnalysis 1 1
         if {[sc_game number] < $::batchEnd} {
             sc_game load [expr [sc_game number] + 1]
             if {$::addAnnotatorTag} {
-                appendAnnotator " $analysis(name1)"
+                set _tmp [expr {$autoplayDelay / 1000.0}]
+                appendAnnotator " $analysis(name1) ($_tmp sec)"
             }
-            set ::wentOutOfBook 0
             updateMenuStates
             updateStatusBar
             updateTitle
             updateBoard -pgn
-            addAnnotation
+            # First do book analysis
+            set ::wentOutOfBook 0
+            bookAnnotation 1
+            # Start with initial assessment of the position
+            set ::initialAnalysis 1
+            # Start the engine
+            toggleEngineAnalysis 1 1
+            # And respawn
             after $autoplayDelay autoplay
             return
         } else  {
@@ -1706,17 +1717,26 @@
             }
             if {$::isBatch && [sc_game number] != 0} {
                 sc_game save [sc_game number]
+                # Stop the engine
+                toggleEngineAnalysis 1 1
                 if {[sc_game number] < $::batchEnd} {
                     sc_game load [expr [sc_game number] + 1]
                     if {$::addAnnotatorTag} {
-                        appendAnnotator " $analysis(name1)"
+                        set _tmp [expr {$autoplayDelay / 1000.0}]
+                        appendAnnotator " $analysis(name1) ($_tmp sec)"
                     }
-                    set ::wentOutOfBook 0
                     updateMenuStates
                     updateStatusBar
                     updateTitle
                     updateBoard -pgn
-                    addAnnotation
+                    # First do book analysis
+                    set ::wentOutOfBook 0
+                    bookAnnotation 1
+                    # Start with initial assessment of the position
+                    set ::initialAnalysis 1
+                    # Start the engine
+                    toggleEngineAnalysis 1 1
+                    # And respawn
                     after $autoplayDelay autoplay
                     return
                 } else  {
Index: tcl/tools/analysis.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/tools/analysis.tcl,v
retrieving revision 1.54
diff -U3 -r1.54 analysis.tcl
--- tcl/tools/analysis.tcl      31 May 2010 19:49:18 -0000      1.54
+++ tcl/tools/analysis.tcl      1 Nov 2010 23:06:22 -0000
@@ -20,6 +20,10 @@
 set analysisBookSlot 1
 set useAnalysisBookName ""
 set wentOutOfBook 0
+# State variable: 1 <=> engine is making an initial
+# assessment of the current position, before progressing
+# into the game
+set initialAnalysis 0
 
 set isBatch 0
 set batchEnd 1
@@ -797,14 +801,34 @@
         if {$tempdelay < 0.1} { set tempdelay 0.1 }
         set autoplayDelay [expr {int($tempdelay * 1000)}]
         destroy .configAnnotation
-        set annotateMode 1
-        if {! $analysis(analyzeMode1)} {
+        # Stop analyis if it is running
+        # We do not want initial super-accuracy
+        #
+        if { $analysis(analyzeMode1) } {
             toggleEngineAnalysis 1 1
         }
+        cancelAutoplay
+        set annotateMode 1
         if {$::addAnnotatorTag} {
-            appendAnnotator "$analysis(name1)"
+            set _tmp [expr {$autoplayDelay / 1000.0}]
+            appendAnnotator "$analysis(name1) ($_tmp sec)"
         }
-        if {$autoplayMode == 0} { toggleAutoplay }
+        # First do the book analysis (if this is configured)
+        # The latter condition is handled by the operation itself
+        set ::wentOutOfBook 0
+        # A hack needed to keep book annotation moving forward
+        # bypassing possible variations (if the variation selection
+        # popup is configured to appear)...
+        set autoplayMode 1
+        bookAnnotation 1
+        set autoplayMode 0
+        # Tell the analysis mode that we want an initial assessment of the
+        # position. So: no comments yet, please!
+        set ::initialAnalysis 1
+        # Start the engine
+        toggleEngineAnalysis 1 1
+        # And start the time slicer
+        toggleAutoplay
     }
     pack $f.buttons.cancel $f.buttons.ok -side right -padx 5 -pady 5
     focus $f.spDelay
@@ -858,7 +882,6 @@
         if { ![catch { sc_move back 1 } ] } {
             resetAnalysis
             updateBoard -pgn
-            for {set i 0} {$i<100} {incr i} { update ; after [expr 
$::autoplayDelay / 100] }
             set analysis(prevscore$n) $analysis(score$n)
             set analysis(prevmoves$n) $analysis(moves$n)
             updateBoard -pgn
@@ -959,9 +982,25 @@
 proc addAnnotation { {n 1} } {
     global analysis annotateMoves annotateBlunders annotateMode 
blunderThreshold
     
+    # Check if we only need to register an initial
+    # assessment of the position
+    # If so, we do not generate any annotation yet
+    if { $::initialAnalysis } {
+        set ::initialAnalysis 0
+        
+        set analysis(prevscore$n) $analysis(score$n)
+        set analysis(prevmoves$n) $analysis(moves$n)
+    
+        # Update score graph if it is open:
+        if {[winfo exists .sgraph]} { ::tools::graphs::score::Refresh }
+        
+        return
+    }
+            
     set exerciseMarked 0
     
     # First look in the book selected
+    # TODO: Is this dead code by now?
     if { ! $::wentOutOfBook && $::useAnalysisBook } {
         bookAnnotation
         return
@@ -971,6 +1010,7 @@
     if {[sc_pos isAt vstart]  &&  [sc_pos isAt vend]} { return }
     
     # Cannot (yet) add a variation at the end of the game or a variation:
+    # TODO: This is silly, and should be repaired
     if {[sc_pos isAt vend]} { return }
     
     set tomove [sc_pos side]
@@ -988,7 +1028,7 @@
     set moves $analysis(moves$n)
     
     # if next move is what engine guessed, do nothing (except if annotate mode 
is for all moves)
-    if { $analysis(prevmoves$n) != "" && ![sc_pos isAt vend] && 
$annotateBlunders != "allmoves"} {
+    if { $analysis(prevmoves$n) != "" && $annotateBlunders != "allmoves"} {
         set move2 [sc_game info previousMoveNT]
         
         sc_info preMoveCmd {}

Attachment: testres.pgn
Description: application/chess-pgn

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Scid-users mailing list
Scid-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scid-users

Reply via email to