From 6db23c417ea59dd9b9b928f022d40e20b80d2e67 Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Sun, 23 Oct 2022 00:45:29 +0200 Subject: start from colemak, attempt to rebalance ring columns if using lsb --- srchr/src/config.rs | 6 +++--- srchr/src/layout.rs | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'srchr/src') diff --git a/srchr/src/config.rs b/srchr/src/config.rs index 9726108..9ed98d3 100644 --- a/srchr/src/config.rs +++ b/srchr/src/config.rs @@ -8,9 +8,9 @@ pub const STATS_FILE_NAME: &str = "shai.json"; pub const LOAD_STATS: bool = true; pub const STARTING_LAYOUT_STRING: &str = " -V L O M Q W F U H . -S R A T K Y C E N I -X J ' D Z G P / B , +Q W F P B J L U Y ' +A R S T G M N E I O +Z X C D V K H , . / "; // Tournament parameters diff --git a/srchr/src/layout.rs b/srchr/src/layout.rs index 2b8cf05..bc519c1 100644 --- a/srchr/src/layout.rs +++ b/srchr/src/layout.rs @@ -142,7 +142,7 @@ impl Layout { (wcol.into_iter().map(|(k, _)| k as u8).collect(), weight) }) .collect::, f32)>>(); - result.sort_by(|(_, l), (_, r)| my_f32_compare(*r, *l)); + result.sort_by(|(_, l), (_, r)| my_f32_compare(*l, *r)); result } @@ -151,8 +151,8 @@ impl Layout { let mut right_col: usize = 9; let mut keys = ['x'; NUM_KEYS]; - let mut w_standard_columns = weight_function(&pl.standard_columns, corpus); - while let Some((col, weight)) = w_standard_columns.pop() { + let w_standard_columns = weight_function(&pl.standard_columns, corpus); + for (col, weight) in w_standard_columns.iter() { let left: bool = ((balance >= 0.0) && (left_col <= 2)) || (right_col <= 6); let ind = if left { left_col } else { right_col }; for i in 0..3 { @@ -163,7 +163,7 @@ impl Layout { } else { right_col -= 1; } - balance += if left { -weight } else { weight }; + balance += if left { -weight } else { *weight }; } let w_index_columns = weight_function(&pl.index_columns, corpus); @@ -194,7 +194,16 @@ impl Layout { + corpus.get_bigram_perc(m3, i3); } } - (left_ind, right_ind) = if lsbs[0] < lsbs[1] { (0, 1) } else { (1, 0) } + (left_ind, right_ind) = if lsbs[0] < lsbs[1] { (0, 1) } else { (1, 0) }; + // if this disagrees with the balancing order, let's consider ring + // column swaps + if balance >= 0.0 && left_ind == 0 && w_standard_columns[2].0[0] == keys[1] as u8 { + for i in 0..3 { + let t = keys[8 + 10 * i]; + keys[8 + 10 * i] = keys[1 + 10 * i]; + keys[1 + 10 * i] = t; + } + } } else { (left_ind, right_ind) = if balance >= 0.0 { (0, 1) } else { (1, 0) } } -- cgit v1.3.1