diff options
| author | tslil clingman <tslil@posteo.de> | 2022-10-20 23:17:19 +0200 |
|---|---|---|
| committer | tslil clingman <tslil@posteo.de> | 2022-10-20 23:20:12 +0200 |
| commit | 1fa7552c3018d541b617b5ceebc6abeaba013eaa (patch) | |
| tree | 7cdc73a4057ff395694c6a72817167d02280efce /srchr/src/config.rs | |
| parent | aa55ddbbf13ea8b2a259ad7a07490efe9dda57f5 (diff) | |
penalise pinky columns with too high usage
even though we don't technically know which columns they are, we do
know they will be the two lowest ultimately when the prelayout becomes
a layout
Diffstat (limited to 'srchr/src/config.rs')
| -rw-r--r-- | srchr/src/config.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/srchr/src/config.rs b/srchr/src/config.rs index 5bb35c5..c9ca302 100644 --- a/srchr/src/config.rs +++ b/srchr/src/config.rs @@ -33,10 +33,10 @@ pub const MAX_NUM_TRANSPOSITIONS: usize = 12; // Fitness parameters pub const DESIRED_INDEX_USAGE_PERCENT: f32 = 0.12; +pub const MAX_PINKY_USAGE_PERCENT: f32 = 0.09; pub const STANDARD_DSFB_WEIGHT: f32 = 1.0 / 8.0; pub const INDEX_DSFB_WEIGHT: f32 = 1.0 / 8.0; -pub fn index_usage_fitness(total_count: u32, index_count: u32) -> f32 { - let index_perc = index_count as f32 / total_count as f32; +pub fn index_usage_fitness(index_perc: f32) -> f32 { if index_perc < DESIRED_INDEX_USAGE_PERCENT { DESIRED_INDEX_USAGE_PERCENT - index_perc } else { @@ -44,6 +44,18 @@ pub fn index_usage_fitness(total_count: u32, index_count: u32) -> f32 { } } +pub fn pinky_col_penalty(lesser_perc: f32, greater_perc: f32) -> f32 { + if greater_perc > MAX_PINKY_USAGE_PERCENT { + if lesser_perc > MAX_PINKY_USAGE_PERCENT { + lesser_perc + greater_perc - MAX_PINKY_USAGE_PERCENT * 2.0 + } else { + greater_perc - MAX_PINKY_USAGE_PERCENT + } + } else { + 0.0 + } +} + // ----------------------------------------------------------------------------- // Do not change the following, the code makes assumptions about these // ----------------------------------------------------------------------------- |
