Skip to content

Commit

Permalink
initial contempt implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rooklift committed Apr 25, 2024
1 parent 29730e2 commit fb44c2d
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 3 deletions.
274 changes: 274 additions & 0 deletions files/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,21 @@ function startup() {
case "tempdecaymoves": // Not so sketchy because it should be a string of an integer.
set_checks("Play", "TempDecayMoves", msg.val === "0" ? "Infinite" : msg.val);
break;

case "contempt":
set_checks("Engine", "Contempt", msg.val);
break;

case "wdlcalibrationelo":
set_checks("Engine", "WDLCalibrationElo", msg.val);
break;

case "contemptmode":
set_checks("Engine", "ContemptMode", msg.val);
break;

}

});

electron.Menu.setApplicationMenu(menu);
Expand Down Expand Up @@ -3342,6 +3356,266 @@ function menu_build() {
{
type: "separator"
},
{
label: "Contempt",
submenu: [
{
label: "250",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", 250]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "150",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", 150]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "100",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", 100]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "50",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", 50]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "0",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", 0]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "-50",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", -50]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "-100",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", -100]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "-150",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", -150]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "-250",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["Contempt", -250]
});
// Will receive an ack IPC which sets menu checks.
}
},
]
},
{
label: "WDLCalibrationElo",
submenu: [
{
label: "3600",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 3600]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "3400",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 3400]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "3200",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 3200]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "3000",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 3000]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "2800",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 2800]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "2500",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 2500]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "2000",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["WDLCalibrationElo", 2000]
});
// Will receive an ack IPC which sets menu checks.
}
},
]
},
{
label: "ContemptMode",
submenu: [
/*
{
label: "play", // Lc0's default, but doesn't work well with normal analysis.
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["ContemptMode", "play"]
});
// Will receive an ack IPC which sets menu checks.
}
},
*/
{
label: "white_side_analysis",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["ContemptMode", "white_side_analysis"]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "black_side_analysis",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["ContemptMode", "black_side_analysis"]
});
// Will receive an ack IPC which sets menu checks.
}
},
{
label: "disable",
type: "checkbox",
checked: false,
click: () => {
win.webContents.send("call", {
fn: "set_uci_option_permanent_and_cleartree",
args: ["ContemptMode", "disable"]
});
// Will receive an ack IPC which sets menu checks.
}
},
]
},
{
type: "separator"
},
{
label: "Custom scripts",
submenu: scriptlist_in_menu // Will be filled at the end, see below.
Expand Down
1 change: 1 addition & 0 deletions files/src/renderer/10_globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const standard_lc0_options = {
"SmartPruningFactor": 0,
"UCI_ShowWDL": true,
"VerboseMoveStats": true,
"ContemptMode": "disable",
};

const standard_ab_options = {
Expand Down
13 changes: 10 additions & 3 deletions files/src/renderer/95_hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ let hub_props = {
}

let overlist = document.querySelectorAll(":hover");

// Find what div we are over by looking for infoline_n

let div = null;
Expand Down Expand Up @@ -1278,7 +1278,7 @@ let hub_props = {
// ---------------------------------------------------------------------------------------------------------------------
// UCI options...

set_uci_option: function(name, val, save_to_cfg) {
set_uci_option: function(name, val, save_to_cfg = false, blue_text = true) {

// Note that all early returns from this function need to send an ack
// of the prevailing value to fix checkmarks in the main process.
Expand Down Expand Up @@ -1315,7 +1315,14 @@ let hub_props = {

this.set_behaviour("halt");
let sent = this.engine.setoption(name, val); // Will ack the new value.
this.set_special_message(sent, "blue");
if (blue_text) {
this.set_special_message(sent, "blue");
}
},

set_uci_option_permanent_and_cleartree: function(name, val) {
this.set_uci_option(name, val, true);
this.set_uci_option("ClearTree", true, false, false);
},

set_uci_option_permanent: function(name, val) {
Expand Down

0 comments on commit fb44c2d

Please sign in to comment.