More styling
This commit is contained in:
+31
-7
@@ -298,7 +298,7 @@ impl CardStatistics {
|
||||
let time = Utc::now() - self.last_open;
|
||||
let days = time.num_days();
|
||||
let multiplier = FADE_PER_DAY.powi(days as i32);
|
||||
self.score as f32 * multiplier
|
||||
(self.score as f32 * multiplier).max(1.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,17 +574,30 @@ impl SemiRandomSRSModule {
|
||||
#[derive(Clone)]
|
||||
struct WorstWordsSRSModule {
|
||||
initialized: bool,
|
||||
rounds: u8,
|
||||
pool: Vec<u32>
|
||||
pool_size: usize,
|
||||
rounds_remaining: u8,
|
||||
pool: Vec<usize>,
|
||||
queue: Vec<usize>,
|
||||
rounds_count: u8,
|
||||
}
|
||||
|
||||
impl SRSModule for WorstWordsSRSModule {
|
||||
fn next(&mut self, _: &mut CardSet) -> usize {
|
||||
todo!()
|
||||
fn next(&mut self, set: &mut CardSet) -> usize {
|
||||
if self.rounds_remaining == 0 {
|
||||
self.fill_pool(set);
|
||||
self.rounds_remaining = self.rounds_count;
|
||||
}
|
||||
|
||||
if self.queue.is_empty() {
|
||||
self.queue.append(&mut self.pool.clone());
|
||||
self.rounds_remaining -= 1;
|
||||
}
|
||||
|
||||
self.queue.pop().unwrap()
|
||||
}
|
||||
|
||||
|
||||
fn open(&mut self, _: WordOpenMode, _: usize, _: CardStatistics) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn init(&mut self, _: &mut CardSet) {
|
||||
@@ -596,8 +609,19 @@ impl WorstWordsSRSModule {
|
||||
fn new() -> WorstWordsSRSModule {
|
||||
WorstWordsSRSModule {
|
||||
initialized: false,
|
||||
rounds: 0,
|
||||
pool_size: 15,
|
||||
rounds_count: 2,
|
||||
rounds_remaining: 0,
|
||||
pool: vec![],
|
||||
queue: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn fill_pool(&mut self, set: &CardSet) {
|
||||
let mut sorted = set.set.clone().into_iter().zip(0..set.set.len()).collect::<Vec<_>>();
|
||||
sorted.sort_by_key(|c| c.0.score);
|
||||
let mut worst = sorted[0..self.pool_size].iter().map(|(_, index)| *index).collect::<Vec<usize>>();
|
||||
worst.shuffle(&mut rand::rng());
|
||||
self.pool = worst;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user