Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizer: single frame/bulk refactor #75

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions src/modules/tas_optimizer/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,34 +497,6 @@ fn mutate_frame<R: Rng>(rng: &mut R, hltas: &mut HLTAS, frame: usize) {
}

fn mutate_frame_bulk<R: Rng>(rng: &mut R, frame_bulk: &mut FrameBulk) {
let p = rng.gen::<f32>();
let strafe_type = if p < 0.01 {
StrafeType::MaxDeccel
} else if p < 0.1 {
StrafeType::MaxAngle
} else {
StrafeType::MaxAccel
};
frame_bulk.auto_actions.movement = Some(AutoMovement::Strafe(StrafeSettings {
type_: strafe_type,
dir: if strafe_type == StrafeType::MaxDeccel {
StrafeDir::Best
} else if rng.gen::<bool>() {
StrafeDir::Left
} else {
StrafeDir::Right
},
}));

mutate_action_keys(rng, frame_bulk);
mutate_auto_actions(rng, frame_bulk);
}

fn mutate_single_frame_bulk<R: Rng>(hltas: &mut HLTAS, rng: &mut R) -> usize {
let count = hltas.frame_bulks().count();
let index = rng.gen_range(0..count);
let frame_bulk = hltas.frame_bulks_mut().nth(index).unwrap();

if let Some(AutoMovement::Strafe(StrafeSettings { type_, dir, .. })) =
frame_bulk.auto_actions.movement.as_mut()
{
Expand Down Expand Up @@ -594,6 +566,14 @@ fn mutate_single_frame_bulk<R: Rng>(hltas: &mut HLTAS, rng: &mut R) -> usize {

mutate_action_keys(rng, frame_bulk);
mutate_auto_actions(rng, frame_bulk);
}

fn mutate_single_frame_bulk<R: Rng>(hltas: &mut HLTAS, rng: &mut R) -> usize {
let count = hltas.frame_bulks().count();
let index = rng.gen_range(0..count);
let frame_bulk = hltas.frame_bulks_mut().nth(index).unwrap();

mutate_frame_bulk(rng, frame_bulk);

// Mutate frame count.
if index + 1 < count {
Expand Down