mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Never repeat an exercise within a mission; remove near-duplicate sentences (0.5.5)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,3 +23,24 @@ static func pick(
|
||||
pool = candidates
|
||||
|
||||
return pool[rng.randi_range(0, pool.size() - 1)]
|
||||
|
||||
|
||||
## Tire un exercice qui n'a pas encore ete vu pendant la mission : d'abord
|
||||
## parmi `preferred` (la difficulte visee), puis parmi `all` si tous les
|
||||
## preferes ont ete vus. Quand tout a ete vu (mission plus longue que le
|
||||
## contenu disponible), retombe sur `pick` en evitant au moins le dernier vu.
|
||||
static func pick_unseen(
|
||||
preferred: Array[Dictionary],
|
||||
all: Array[Dictionary],
|
||||
seen_ids: Array[String],
|
||||
rng: RandomNumberGenerator
|
||||
) -> Variant:
|
||||
for source in [preferred, all]:
|
||||
var pool: Array[Dictionary] = []
|
||||
for candidate: Dictionary in source:
|
||||
if not seen_ids.has(candidate["id"]):
|
||||
pool.append(candidate)
|
||||
if not pool.is_empty():
|
||||
return pool[rng.randi_range(0, pool.size() - 1)]
|
||||
var last := "" if seen_ids.is_empty() else seen_ids[seen_ids.size() - 1]
|
||||
return pick(preferred, last, rng)
|
||||
|
||||
Reference in New Issue
Block a user