I've written some changes to limit the upper bound of bg rate based on
the gammon rate and to adjust it in 1% increments.

If this looks good, I'll push it as a separate commit.

The variable names remain as they are in the master branch
(aapwRates). I haven't changed aapadjRates.

TAKAHASHI Kaoru <[email protected]> writes:
> I might have been influenced by the UI of XG2.
>
> Philippe Michel <[email protected]> writes:
>> On Sat, Sep 05, 2026 at 11:01:42PM +0900, TAKAHASHI Kaoru wrote:
>>
>>> I created a patch that adds a checkbox to the Market Window to enable
>>> calculations that ignore the gammon rate and backgammon rate.  When this
>>> checkbox is selected, the Market Window treats the gammon rate and
>>> backgammon rate as 0 in its calculations. The entered values themselves
>>> are retained, and you can still recalculate by switching between 0-ply
>>> and 4-ply. While this checkbox is selected, the rate input fields are
>>> made insensitive to indicate that they are not being used in the current
>>> calculation.
>>> 
>>> If the checkbox is unchecked, the calculation will be performed using
>>> the latest saved rates.
>>
>> I'm not familiar with the Market Window feature, but would it not be 
>> simpler to just set the four rates to 0 and rely on the Reset button to 
>> get back the initial values ?
>>
>> I'm aware that Reset resets everything: money vs. match, match score, 
>> etc... but is there really a use case for changing some non-rate 
>> parameters, then looking at what gammon rates at 0 do, then resetting 
>> the rates but not the other parameters before presumably experimenting 
>> with something else ?
>
> Ipetani, a Japanese GM3 YouTuber, sometimes uses it during YouTube live
> streams by checking and unchecking boxes in XG2 "Non Gammon Adjusted",
> with displays like, "If it were gammon-less at this score, the TP or CP
> would be this value, but for the current position, it is this value."
>
> I use it when checking the market window where both the gammon rate and
> BG rate are 0% at an arbitrary score, so once I check the "ignore gammon
> rate" box, I usually leave it checked for a while. I rarely uncheck
> it. In my case, I could just edit the position to be gammon-less and
> then check the market window, though.
>
> Also, it is a hassle that using reset button reverts it back to 0-ply.
>
>
>> By the way, there are other quirks in this feature (the market window 
>> analysis, not your proposed change):
>>
>> - it is possible to decrease a gammon rate and set it to a lower value 
>> than the backgammon rate (or to increase the backgammon rate above the 
>> gammon rate)
>
> The gammon rate is the percentage of winning chances that result in a
> gammon, and does not include backgammon wins. While
> bg rate + gammon rate > 100% would be invalid, there are no restrictions
> on the size relationship between the bg rate and the gammon rate.
>
> For example, with the board position set as
>   set xgid XGID=--BBBBBB----------------bC:4:1:1:12:57:1:0:63:7
>
> it is a guaranteed backgammon loss, so the correct behavior is for the
> opponent's gammon rate to be 0% and the bg rate to be 100%.
>
>
>> - the step increment for the rates is 0.01% and the page increment 1%. 
>> Who really adjusts them by 0.01 percents ?
>>
>>
>> Fixing the first one and using arguably more sensible values for the 
>> increments opens this possibility:
>>
>> - use a step increment of 1% (and round the value if used) and a page 
>> increment of 0
>>
>> - intercept the page down event and set the rate to 0 if it is used.
>>
>> That would allow to set all rates to 0 without an additional UI element 
>> (but admittedly two actions by the user rather than one)
>
> An increment step of 0.01% for the rate is indeed too granular.
> With a mouse, increments of 1% would be sufficient, or perhaps 10%
> increments might even be more convenient.  I believe that if fine-tuning
> is necessary, it would be fine as long as you can type the value in
> directly.

-- 
TAKAHASHI Kaoru
diff --git a/gtktheory.c b/gtktheory.c
index 96796c63..37fbe594 100644
--- a/gtktheory.c
+++ b/gtktheory.c
@@ -341,15 +341,24 @@ TheoryUpdated(GtkWidget * UNUSED(pw), theorywidget * ptw)
     GtkTextBuffer *buffer;
     GtkTextIter iter;
 
+    /* set max on the backgammon spinners */
+
+    for (i = 0; i < 2; ++i) {
+        GtkAdjustment *padj = ptw->aapwRates[i][1];
+        gdouble upper = 100.0 - gtk_adjustment_get_value(ptw->aapwRates[i][0]);
+
+        gtk_adjustment_set_upper(padj, upper);
+        if (gtk_adjustment_get_value(padj) > upper) {
+            g_signal_handlers_block_by_func(G_OBJECT(padj), (gpointer) G_CALLBACK(TheoryUpdated), ptw);
+            gtk_adjustment_set_value(padj, upper);
+            g_signal_handlers_unblock_by_func(G_OBJECT(padj), (gpointer) G_CALLBACK(TheoryUpdated), ptw);
+        }
+    }
+
     /* get values */
 
     TheoryGetValues(ptw, &ci, aarRates);
 
-    /* set max on the gammon spinners */
-
-    for (i = 0; i < 2; ++i)
-        gtk_adjustment_set_upper(ptw->aapwRates[i][1], 100.0 - gtk_adjustment_get_value(ptw->aapwRates[i][0]));
-
     SetCubeInfo(&ci, ci.nCube, 0, 0, ci.nMatchTo, ci.anScore, ci.fCrawford, ci.fJacoby, ci.fBeavers, ms.bgv);
 
     /* hide show widgets */
@@ -978,7 +987,7 @@ GTKShowTheory(const int fActivePage)
 
         for (j = 0; j < 2; j++) {
 
-            ptw->aapwRates[i][j] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 0.01, 1.0, 0));
+            ptw->aapwRates[i][j] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 1.0, 0));
             pwsb = gtk_spin_button_new(ptw->aapwRates[i][j], 0.01, 2);
 
 #if GTK_CHECK_VERSION(3,0,0)

Reply via email to