add coward

This commit is contained in:
mehbark 2023-03-29 16:43:14 -04:00
parent 5bb2040a5b
commit 4479dfdec5
2 changed files with 36 additions and 21 deletions

12
main.js
View file

@ -462,8 +462,8 @@ const generous = board => {
}; };
return min_move_by(board, generous_score); return min_move_by(board, generous_score);
}; };
const no_i_insist = board => { const coward = board => min_move_by(board, sum_of_possible_capture_value);
let no_i_insist_score = (b) => { function no_i_insist_score(b) {
if (b.isCheckmate()) { if (b.isCheckmate()) {
return 612; return 612;
} }
@ -472,7 +472,8 @@ const no_i_insist = board => {
} }
let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR); let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR);
return -(sum_of_possible_capture_value(b) / b.moves().length); return -(sum_of_possible_capture_value(b) / b.moves().length);
}; }
const no_i_insist = board => {
return min_move_by(board, no_i_insist_score); return min_move_by(board, no_i_insist_score);
}; };
const pacifist = board => { const pacifist = board => {
@ -543,6 +544,11 @@ const players = [
name: "no_i_insist", 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", 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, f: reverse_starting,
name: "reverse_starting", name: "reverse_starting",

15
main.ts
View file

@ -549,8 +549,10 @@ const generous: Player = board => {
return min_move_by(board, generous_score); return min_move_by(board, generous_score);
}; };
const no_i_insist: Player = board => { const coward: Player = board =>
let no_i_insist_score = (b: Chess) => { min_move_by(board, sum_of_possible_capture_value);
function no_i_insist_score(b: Chess) {
if (b.isCheckmate()) { if (b.isCheckmate()) {
return 612; return 612;
} }
@ -559,8 +561,9 @@ const no_i_insist: Player = board => {
} }
let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR); let prev_value = value_of_pieces_of_color(b, ROBOT_COLOR);
return -(sum_of_possible_capture_value(b) / b.moves().length); 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); return min_move_by(board, no_i_insist_score);
}; };
@ -644,6 +647,12 @@ const players = [
description: 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", "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, f: reverse_starting,
name: "reverse_starting", name: "reverse_starting",