From 4479dfdec58d532bbc8a84742c8a73c3ef6e1d89 Mon Sep 17 00:00:00 2001 From: mehbark Date: Wed, 29 Mar 2023 16:43:14 -0400 Subject: [PATCH] add coward --- main.js | 26 ++++++++++++++++---------- main.ts | 31 ++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/main.js b/main.js index 47028d7..b5bad1f 100644 --- a/main.js +++ b/main.js @@ -462,17 +462,18 @@ const generous = board => { }; return min_move_by(board, generous_score); }; +const coward = board => min_move_by(board, sum_of_possible_capture_value); +function no_i_insist_score(b) { + if (b.isCheckmate()) { + return 612; + } + if (b.isCheck()) { + return 413; + } + let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR); + return -(sum_of_possible_capture_value(b) / b.moves().length); +} const no_i_insist = board => { - let no_i_insist_score = (b) => { - if (b.isCheckmate()) { - return 612; - } - if (b.isCheck()) { - return 413; - } - let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR); - return -(sum_of_possible_capture_value(b) / b.moves().length); - }; return min_move_by(board, no_i_insist_score); }; const pacifist = board => { @@ -543,6 +544,11 @@ const players = [ name: "no_i_insist", description: "Maximizes the proportion of potential capture value of YOUR moves to the number of YOUR moves; very weird the way i've done it", }, + { + f: coward, + name: "coward", + description: "Surprisingly uncowardly, tries to avoid losing pieces, weighted by value", + }, { f: reverse_starting, name: "reverse_starting", diff --git a/main.ts b/main.ts index edf2340..75823aa 100644 --- a/main.ts +++ b/main.ts @@ -549,18 +549,21 @@ const generous: Player = board => { return min_move_by(board, generous_score); }; -const no_i_insist: Player = board => { - let no_i_insist_score = (b: Chess) => { - if (b.isCheckmate()) { - return 612; - } - if (b.isCheck()) { - return 413; - } - let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR); - return -(sum_of_possible_capture_value(b) / b.moves().length); - }; +const coward: Player = board => + min_move_by(board, sum_of_possible_capture_value); +function no_i_insist_score(b: Chess) { + if (b.isCheckmate()) { + return 612; + } + if (b.isCheck()) { + return 413; + } + let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR); + return -(sum_of_possible_capture_value(b) / b.moves().length); +} + +const no_i_insist: Player = board => { return min_move_by(board, no_i_insist_score); }; @@ -644,6 +647,12 @@ const players = [ description: "Maximizes the proportion of potential capture value of YOUR moves to the number of YOUR moves; very weird the way i've done it", }, + { + f: coward, + name: "coward", + description: + "Surprisingly uncowardly, tries to avoid losing pieces, weighted by value", + }, { f: reverse_starting, name: "reverse_starting",