Don't add PV moves on board clicking in AnalyzeMode
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 18 Feb 2013 09:29:17 +0000 (10:29 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 18 Feb 2013 10:39:39 +0000 (11:39 +0100)
Playing PV moves by right-clicking the PV was only intended for clicks
in the engine Output window, selecting from multi-PV analysis output,
where by default it plays only the first move. PV walkig by right-clicking
the board, however, would start the walk at the end even in AnalyzeMode,
and thus add the entire PV. Which is probably not useful. So adding moves
in that case has now completely been suppressed, so it can be used for
harmless viewing of the latest PV.
 The behavior has also been made subject to a persistent Boolean option
-appendPV, configured to true, with a checkbox in General Options.
 A checkbox has also been added there for controlling the -variations option,
which is now also configured to true.

args.h
backend.c
common.h
dialogs.c
xboard.conf.in
xboard.texi

diff --git a/args.h b/args.h
index dac7250..4634031 100644 (file)
--- a/args.h
+++ b/args.h
@@ -196,6 +196,7 @@ ArgDescriptor argDescriptors[] = {
   { "secondDirectory", ArgFilename, (void *) &appData.secondDirectory, FALSE, (ArgIniType) SECOND_DIRECTORY },
   { "sd", ArgFilename, (void *) &appData.secondDirectory, FALSE, INVALID },
   { "variations", ArgBoolean, (void *) &appData.variations, TRUE, (ArgIniType) FALSE },
+  { "appendPV", ArgBoolean, (void *) &appData.autoExtend, TRUE, (ArgIniType) FALSE },
   { "theme", ArgString, (void *) &theme, FALSE, (ArgIniType) "" },
 
   /* some options only used by the XBoard front end, and ignored in WinBoard         */
index f61c15c..61a9f1e 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -5492,6 +5492,8 @@ MultiPV (ChessProgramState *cps)
        return -1;
 }
 
+Boolean extendGame; // signals to UnLoadPV() if walked part of PV has to be appended to game
+
 Boolean
 LoadMultiPV (int x, int y, char *buf, int index, int *start, int *end, int pane)
 {
@@ -5523,6 +5525,7 @@ LoadMultiPV (int x, int y, char *buf, int index, int *start, int *end, int pane)
        }
        ParsePV(buf+startPV, FALSE, gameMode != AnalyzeMode);
        *start = startPV; *end = index-1;
+       extendGame = (gameMode == AnalyzeMode && appData.autoExtend);
        return TRUE;
 }
 
@@ -5552,6 +5555,7 @@ LoadPV (int x, int y)
   int which = gameMode == TwoMachinesPlay && (WhiteOnMove(forwardMostMove) == (second.twoMachinesColor[0] == 'w'));
   lastX = x; lastY = y;
   ParsePV(lastPV[which], FALSE, TRUE); // load the PV of the thinking engine in the boards array.
+  extendGame = FALSE;
   return TRUE;
 }
 
@@ -5562,7 +5566,7 @@ UnLoadPV ()
   if(endPV < 0) return;
   if(appData.autoCopyPV) CopyFENToClipboard();
   endPV = -1;
-  if(gameMode == AnalyzeMode && currentMove > forwardMostMove) {
+  if(extendGame && currentMove > forwardMostMove) {
        Boolean saveAnimate = appData.animate;
        if(pushed) {
            if(shiftKey && storedGames < MAX_VARIATIONS-2) { // wants to start variation, and there is space
index 984efe0..755df78 100644 (file)
--- a/common.h
+++ b/common.h
@@ -553,6 +553,7 @@ typedef struct {
     Boolean showButtonBar;
     Boolean icsEngineAnalyze;
     Boolean variations;         /* [HGM] enable variation-tree walking */
+    Boolean autoExtend;         /* [HGM] enable playing move(s) of right-clicked PV in analysis mode */
 
     /* [AS] New properties (down to the "ZIPPY" part) */
     Boolean scoreIsAbsolute[ENGINES];  /* If true, engine score is always from white side */
index 02edc74..4aa6478 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -368,12 +368,14 @@ static Option generalOptions[] = {
 { 0,  0, 0, NULL, (void*) &appData.autoFlipView, "", NULL, CheckBox, N_("Auto Flip View") },
 { 0,  0, 0, NULL, (void*) &appData.blindfold, "", NULL, CheckBox, N_("Blindfold") },
 { 0,  0, 0, NULL, (void*) &appData.dropMenu, "", NULL, CheckBox, N_("Drop Menu") },
+{ 0,  0, 0, NULL, (void*) &appData.variations, "", NULL, CheckBox, N_("Enable Variation Trees") },
 { 0,  0, 0, NULL, (void*) &appData.hideThinkingFromHuman, "", NULL, CheckBox, N_("Hide Thinking from Human") },
 { 0,  0, 0, NULL, (void*) &appData.highlightLastMove, "", NULL, CheckBox, N_("Highlight Last Move") },
 { 0,  0, 0, NULL, (void*) &appData.highlightMoveWithArrow, "", NULL, CheckBox, N_("Highlight with Arrow") },
 { 0,  0, 0, NULL, (void*) &appData.oneClick, "", NULL, CheckBox, N_("One-Click Moving") },
 { 0,  0, 0, NULL, (void*) &appData.periodicUpdates, "", NULL, CheckBox, N_("Periodic Updates (in Analysis Mode)") },
 { 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" },
+{ 0,  0, 0, NULL, (void*) &appData.autoExtend, "", NULL, CheckBox, N_("Play Move(s) of Clicked PV (Analysis)") },
 { 0,  0, 0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, N_("Ponder Next Move") },
 { 0,  0, 0, NULL, (void*) &appData.popupExitMessage, "", NULL, CheckBox, N_("Popup Exit Messages") },
 { 0,  0, 0, NULL, (void*) &appData.popupMoveErrors, "", NULL, CheckBox, N_("Popup Move Errors") },
index 0e94d2c..38186c2 100644 (file)
@@ -56,6 +56,8 @@
 -delayBeforeQuit 0
 -delayAfterQuit 0
 -defaultTourneyName "Tourney_%y%M%d_%h%m.trn"
+-variations true
+-appendPV true
 ;
 ; PGN format & Game List
 ;
index 30d3bc5..069ecc6 100644 (file)
@@ -1097,6 +1097,13 @@ will pop up a menu to drop a piece on the clicked square
 (old, deprecated behavior)
 or allow you to step through an engine PV
 (new, recommended behavior).
+@itemx Enable Variation Trees
+@cindex Enable Variation Trees, Menu Item
+If this option is on, playing a move in Edit Game or Analyze mode
+while keeping the Shift key pressed will start a new variation.
+You can then recall the previous line through the @samp{Revert} menu item.
+When off, playing a move will truncate the game and append the move
+irreversibly.
 @itemx Hide Thinking
 @cindex Hide Thinking, Menu Item
 If this option is off, the chess engine's notion of the score and best
@@ -1148,6 +1155,14 @@ you are using a chess engine that does not support periodic updates),
 the analysis window
 will only be updated when the analysis changes. If this option is
 on, the Analysis Window will be updated every two seconds.
+@itemx Play Move(s) of Clicked PV
+@cindex Play Move(s) of Clicked PV, Menu Item
+If this option is on, right-clicking a PV in the Engine Output window
+during Analyze mode will cause the first move of that PV to be played.
+You could also play more than one (or no) PV move by moving the mouse
+to engage in the PV walk such a right-click will start,
+to seek out another position along the PV where you want to continue
+the analysis, before releasing the mouse button.
 @itemx Ponder Next Move
 @cindex Ponder Next Move, Menu Item
 If this option is off, the chess engine will think only when it is on
@@ -3243,6 +3258,12 @@ When this option is on, you can start new variations in Edit Game or
 Analyze mode by holding the Shift key down while entering a move.
 When it is off, the Shift key will be ignored.
 Default: False.
+@item -appendPV true|false
+@cindex appendPV, option
+When this option is on, right-clicking a PV in the Engine Output window
+will play the first move of that PV in Analyze mode,
+or as many moves as you walk through by moving the mouse.
+Default: False.
 @item -absoluteAnalysisScores true|false
 @cindex absoluteAnalysisScores, option
 When true, scores on the Engine Output window during analysis