Skip to content

Commit

Permalink
feat: Branch if damage is a range to kill
Browse files Browse the repository at this point in the history
Adds a new feature to all generations (except gen1) that causes the
instruction generation to create a new branch if the damage being dealt
has a chance to kill and a chance to not kill. This is not added to gen1
because gen1 already branches in a similar way on critical hits due to
them being quite common.

This doesn't show a significant performance gain in self-play but there
are scenarios that I have observed where assuming the average damage
roll resulted in an endgame throw.

This feature is enabled during MCTS but only at the root node. I should
experiment with adding it to the first child as well. Beyond that, there
would be some serious performance hits - roughly 12% fewer MCTS
iterations if let run for the entire search.
  • Loading branch information
pmariglia committed Dec 4, 2024
1 parent 5d3b71d commit 11e8f32
Show file tree
Hide file tree
Showing 12 changed files with 902 additions and 330 deletions.
2 changes: 1 addition & 1 deletion poke-engine-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ fn gi(
}
}
let instructions =
generate_instructions_from_move_pair(&mut py_state.state, &s1_move, &s2_move);
generate_instructions_from_move_pair(&mut py_state.state, &s1_move, &s2_move, true);
let py_instructions = instructions
.iter()
.map(|i| PyStateInstructions::from_state_instructions(i.clone()))
Expand Down
6 changes: 6 additions & 0 deletions src/gen1/generate_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ pub fn generate_instructions_from_move(
attacking_side: SideReference,
mut incoming_instructions: StateInstructions,
mut final_instructions: &mut Vec<StateInstructions>,
_branch_if_roll_kills: bool,
) {
if state.use_damage_dealt {
reset_damage_dealt(
Expand Down Expand Up @@ -1496,6 +1497,7 @@ pub fn generate_instructions_from_move_pair(
state: &mut State,
side_one_move: &MoveChoice,
side_two_move: &MoveChoice,
branch_if_roll_kills: bool,
) -> Vec<StateInstructions> {
/*
- get Choice structs from moves
Expand Down Expand Up @@ -1556,6 +1558,7 @@ pub fn generate_instructions_from_move_pair(
SideReference::SideOne,
incoming_instructions,
&mut state_instructions_vec,
branch_if_roll_kills,
);
side_two_choice.first_move = false;
let mut i = 0;
Expand All @@ -1569,6 +1572,7 @@ pub fn generate_instructions_from_move_pair(
SideReference::SideTwo,
state_instruction,
&mut state_instructions_vec,
branch_if_roll_kills,
);
i += 1;
}
Expand All @@ -1581,6 +1585,7 @@ pub fn generate_instructions_from_move_pair(
SideReference::SideTwo,
incoming_instructions,
&mut state_instructions_vec,
branch_if_roll_kills,
);
side_one_choice.first_move = false;
let mut i = 0;
Expand All @@ -1594,6 +1599,7 @@ pub fn generate_instructions_from_move_pair(
SideReference::SideOne,
state_instruction,
&mut state_instructions_vec,
branch_if_roll_kills,
);
i += 1;
}
Expand Down
Loading

0 comments on commit 11e8f32

Please sign in to comment.