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.  The patch is divided into two parts.

The first is a rename that does not involve any functional changes:
it changes the existing GtkAdjustment *aapwRates[2][2]; to
GtkAdjustment *aapadjRates[2][2];.
This was done to align with existing code that uses the “aapadj”
prefix for GtkAdjustment.

The second change is the addition of a checkbox. By performing this
rename first, we can store the spin button itself as
GtkWidget *aapwRates[2][2];, making it easier to distinguish between the
names of the Adjustment and the Widget.

In this case, the checkbox simply treats the rate as 0 immediately
before the Market Window calculation; it does not make any changes to
the rate evaluation process itself.

If it’s okay to merge this into master as is, I’ll merge it and push it.

Please let me know if you have any suggestions, such as whether the
label should be changed to "Non gammon Adjusted".

Best regards,
-- 
TAKAHASHI Kaoru
>From f5573b24ab6427d6094a060a90e4cf79d13b53ba Mon Sep 17 00:00:00 2001
From: TAKAHASHI Kaoru <[email protected]>
Date: Sat, 5 Sep 2026 19:18:42 +0900
Subject: [PATCH] gtktheory.c: Rename aapwRates to aapadjRates

Use the aapadj prefix for GtkAdjustment array, consistent with existing
GTK naming conventions.
---
 gtktheory.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gtktheory.c b/gtktheory.c
index 96796c63..e2666c1b 100644
--- a/gtktheory.c
+++ b/gtktheory.c
@@ -48,7 +48,7 @@ typedef struct {
 
     /* gammon/backgammon rates widgets */
 
-    GtkAdjustment *aapwRates[2][2];
+    GtkAdjustment *aapadjRates[2][2];
 
     /* score */
 
@@ -145,7 +145,7 @@ ResetTheory(GtkWidget * UNUSED(pw), theorywidget * ptw)
 
         for (j = 0; j < 2; j++)
             /* gammon/backgammon rates */
-            gtk_adjustment_set_value(GTK_ADJUSTMENT(ptw->aapwRates[i][j]), aarRates[i][j] * 100.0f);
+            gtk_adjustment_set_value(GTK_ADJUSTMENT(ptw->aapadjRates[i][j]), aarRates[i][j] * 100.0f);
 
     }
 
@@ -163,7 +163,7 @@ TheoryGetValues(theorywidget * ptw, cubeinfo * pci, float aarRates[2][2])
 
     for (i = 0; i < 2; i++)
         for (j = 0; j < 2; j++)
-            aarRates[i][j] = 0.01f * (float) gtk_adjustment_get_value(ptw->aapwRates[i][j]);
+            aarRates[i][j] = 0.01f * (float) gtk_adjustment_get_value(ptw->aapadjRates[i][j]);
 
 
     /* money game or match play */
@@ -348,7 +348,7 @@ TheoryUpdated(GtkWidget * UNUSED(pw), theorywidget * ptw)
     /* 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]));
+        gtk_adjustment_set_upper(ptw->aapadjRates[i][1], 100.0 - gtk_adjustment_get_value(ptw->aapadjRates[i][0]));
 
     SetCubeInfo(&ci, ci.nCube, 0, 0, ci.nMatchTo, ci.anScore, ci.fCrawford, ci.fJacoby, ci.fBeavers, ms.bgv);
 
@@ -644,7 +644,7 @@ PlyClicked(GtkWidget * pw, theorywidget * ptw)
 
     for (i = 0; i < 2; ++i)
         for (j = 0; j < 2; ++j)
-            gtk_adjustment_set_value(GTK_ADJUSTMENT(ptw->aapwRates[i][j]), dd.aarRates[i][j] * 100.0f);
+            gtk_adjustment_set_value(GTK_ADJUSTMENT(ptw->aapadjRates[i][j]), dd.aarRates[i][j] * 100.0f);
 
     TheoryUpdated(NULL, ptw);
 
@@ -978,8 +978,8 @@ 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));
-            pwsb = gtk_spin_button_new(ptw->aapwRates[i][j], 0.01, 2);
+            ptw->aapadjRates[i][j] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 0.01, 1.0, 0));
+            pwsb = gtk_spin_button_new(ptw->aapadjRates[i][j], 0.01, 2);
 
 #if GTK_CHECK_VERSION(3,0,0)
             gtk_grid_attach(GTK_GRID(pwGrid), pwsb, j + 1, i + 1, 1, 1);
@@ -997,7 +997,7 @@ GTKShowTheory(const int fActivePage)
                              j + 1, j + 2, i + 1, i + 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 4, 0);
 #endif
 
-            g_signal_connect(G_OBJECT(ptw->aapwRates[i][j]), "value-changed", G_CALLBACK(TheoryUpdated), ptw);
+            g_signal_connect(G_OBJECT(ptw->aapadjRates[i][j]), "value-changed", G_CALLBACK(TheoryUpdated), ptw);
 
         }
 
-- 
2.47.3

>From 2c52ab2260c8f940fc90a287fd73da92bb54296f Mon Sep 17 00:00:00 2001
From: TAKAHASHI Kaoru <[email protected]>
Date: Sat, 5 Sep 2026 19:29:00 +0900
Subject: [PATCH] Add checkbox to ignore gammon rates in market window

The rate fields are made insensitive while the option is enabled,
but their values are preserved and can still be recalculated by
changing the evaluation ply.
---
 gtktheory.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gtktheory.c b/gtktheory.c
index e2666c1b..d701189c 100644
--- a/gtktheory.c
+++ b/gtktheory.c
@@ -49,6 +49,8 @@ typedef struct {
     /* gammon/backgammon rates widgets */
 
     GtkAdjustment *aapadjRates[2][2];
+    GtkWidget *aapwRates[2][2];
+    GtkWidget *pwIgnoreGammonRates;
 
     /* score */
 
@@ -133,8 +135,9 @@ ResetTheory(GtkWidget * UNUSED(pw), theorywidget * ptw)
 
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->pwBeavers), ptw->ci.fBeavers);
 
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->apwPly[ec.nPlies]), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->pwIgnoreGammonRates), FALSE);
 
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->apwPly[ec.nPlies]), TRUE);
 
     for (i = 0; i < 2; i++) {
 
@@ -337,6 +340,7 @@ TheoryUpdated(GtkWidget * UNUSED(pw), theorywidget * ptw)
     float aarRates[2][2];
 
     int i, j;
+    int fIgnoreGammonRates;
     gchar *pch;
     GtkTextBuffer *buffer;
     GtkTextIter iter;
@@ -345,6 +349,11 @@ TheoryUpdated(GtkWidget * UNUSED(pw), theorywidget * ptw)
 
     TheoryGetValues(ptw, &ci, aarRates);
 
+    fIgnoreGammonRates = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ptw->pwIgnoreGammonRates));
+    for (i = 0; i < 2; i++)
+        for (j = 0; j < 2; j++)
+            gtk_widget_set_sensitive(ptw->aapwRates[i][j], !fIgnoreGammonRates);
+
     /* set max on the gammon spinners */
 
     for (i = 0; i < 2; ++i)
@@ -399,6 +408,9 @@ TheoryUpdated(GtkWidget * UNUSED(pw), theorywidget * ptw)
      * update market window widgets
      */
 
+    if (fIgnoreGammonRates)
+        memset(aarRates, 0, sizeof(aarRates));
+
     remove_mw_rows(ptw);
     if (ci.nMatchTo)
         add_mw_match_rows(ptw, &ci, aarRates);
@@ -980,6 +992,7 @@ GTKShowTheory(const int fActivePage)
 
             ptw->aapadjRates[i][j] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 0.01, 1.0, 0));
             pwsb = gtk_spin_button_new(ptw->aapadjRates[i][j], 0.01, 2);
+            ptw->aapwRates[i][j] = pwsb;
 
 #if GTK_CHECK_VERSION(3,0,0)
             gtk_grid_attach(GTK_GRID(pwGrid), pwsb, j + 1, i + 1, 1, 1);
@@ -1003,6 +1016,10 @@ GTKShowTheory(const int fActivePage)
 
     }
 
+    ptw->pwIgnoreGammonRates = gtk_check_button_new_with_label(_("Ignore gammon and backgammon rates"));
+    gtk_box_pack_start(GTK_BOX(pwx), ptw->pwIgnoreGammonRates, FALSE, FALSE, 4);
+    g_signal_connect(G_OBJECT(ptw->pwIgnoreGammonRates), "toggled", G_CALLBACK(TheoryUpdated), ptw);
+
     /* radio buttons with plies */
 
 #if GTK_CHECK_VERSION(3,0,0)
-- 
2.47.3

Reply via email to