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

26
main.js
View file

@ -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",

31
main.ts
View file

@ -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",