aboutsummaryrefslogtreecommitdiff
path: root/srchr/src/config.rs
blob: 6409ef7c7618dc126d1fd010716f38c07ec8a997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// With the below parameters and the supplied corpus searches seem to converge on the following

// J , H G Q  B C O U '
// S A N T V  F D E I R
// X . L M K  P W / Y Z
//
// Percent per key:
//  0.1  1.8  6.0  1.9  0.1   1.5  2.3  7.4  2.8  1.0
//  6.0  7.7  6.6  8.6  0.9   2.1  4.3 11.9  6.6  5.5
//  0.1  1.2  4.0  2.6  0.8   1.6  2.3  0.2  2.0  0.1
//
// Finger usage:  6.29%, 10.70%, 16.56%, 14.88%, 14.05%, 19.47%, 11.45%,  6.60%
// Hand usage: 48.43% vs 51.57%
// Same finger bigrams:  0.000%,  0.029%,  0.092%,  0.032%,  0.042%,  0.096%,  0.113%,  0.031%
// Total sfb: 0.43% (43414)

// Search parameters
pub const CORPUS_FILE_NAME: &str = "corpus.txt";

pub const STARTING_LAYOUT_STRING: &str = "
Q W E R T  Y U I O P
A S D F G  H J K L '
Z X C V B  N M , . /
";

pub const NUM_CONTESTANTS: usize = 128;
pub const NUM_PERSIST: usize = 8;

pub const DESIRED_INDEX_USAGE_PERCENT: f32 = 0.15;
pub const fn index_usage_fitness(index_threshold: u32, index_count: u32) -> u32 {
    (index_threshold as i64 - index_count as i64).abs() as u32 / 64
}

// Do not change, code makes assumptions about these
pub const NUM_KEYS: usize = 30;
pub const ROW_LENGTH: usize = 10;

pub const KEY_CHARS: [char; NUM_KEYS] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '/', '.', ',', '\'',
];

pub const KEY_TO_FINGER: [usize; NUM_KEYS] = [
    0, 1, 2, 3, 3, 4, 4, 5, 6, 7, 0, 1, 2, 3, 3, 4, 4, 5, 6, 7, 0, 1, 2, 3, 3, 4, 4, 5, 6, 7,
];

pub fn canonicalise(inp: char) -> Option<char> {
    if inp.is_ascii_alphabetic() {
        return Some(inp.to_ascii_uppercase());
    } else {
        match inp {
            '.' => Some('.'),
            '>' => Some('.'),
            ',' => Some(','),
            '<' => Some(','),
            '/' => Some('/'),
            '?' => Some('/'),
            '\'' => Some('\''),
            '"' => Some('\''),
            _ => None,
        }
    }
}