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
64
65
66
67
//! [`BestLeastRecentlyViewed`] - favour content not shown for the longest time.
use HashMap;
use ;
/// Picks the available candidate that was least recently selected.
///
/// Candidates that have never been shown are treated as if they were last shown at turn 0,
/// which gives them priority over candidates that have already been shown. Among candidates
/// with equal "last seen" turns the one with the lower index wins.
///
/// This strategy is ideal for NPC barks and variation lines where you want maximum
/// variety before repeating content.
///
/// # Example
///
/// ```rust
/// use bubbles::saliency::{BestLeastRecentlyViewed, Candidate, SaliencyStrategy};
///
/// let mut s = BestLeastRecentlyViewed::default();
/// let candidates = vec![
/// Candidate { id: "a", available: true },
/// Candidate { id: "b", available: true },
/// Candidate { id: "c", available: true },
/// ];
///
/// // First call - all unseen, picks index 0.
/// assert_eq!(s.select(&candidates), Some(0));
/// // Second call - "a" was just seen, picks "b" at index 1.
/// assert_eq!(s.select(&candidates), Some(1));
/// // Third call - picks "c" at index 2.
/// assert_eq!(s.select(&candidates), Some(2));
/// // Fourth call - all seen, wraps back to "a" (oldest).
/// assert_eq!(s.select(&candidates), Some(0));
/// ```