major algo improvements again

This commit is contained in:
2025-02-08 14:14:05 -05:00
parent 41bc93276e
commit 325ac75c31
3 changed files with 38 additions and 4 deletions

View File

@@ -32,7 +32,10 @@ impl Move {
fn value(&self, agent_color: Piece, depth: usize) -> i64 {
let mut captured_value = self.captured as i64;
if agent_color != self.color {
if self.board.game_over() && self.board.get_winner() != Some(!agent_color) {
// if this board results in the opponent winning, MAJORLY negatively weigh this move
captured_value = i64::MIN;
} else if agent_color != self.color {
captured_value = -captured_value;
}
@@ -133,6 +136,8 @@ impl Agent for ComplexAgent {
.into_iter()
.max_by_key(|m| m.value(self.color, 1));
assert!(self.curr_move.is_some(), "ComplexAgent didn't make a move");
self.curr_move.as_ref().map(Move::coords)
}