identifiant unique de grille

This commit is contained in:
2025-04-24 18:23:57 +02:00
parent ef49f35e2a
commit b9eb5b725f
4 changed files with 41 additions and 13 deletions

View File

@ -21,14 +21,28 @@ foreach ($dico as $mot => $definition) {
}
$mots_de_n_lettres[$n][] = $mot;
}
foreach ($mots_de_n_lettres as $n => $mots) {
shuffle($mots_de_n_lettres[$n]);
function fisherYatesShuffle(&$items, $seed)
{
@mt_srand($seed);
for ($i = count($items) - 1; $i > 0; $i--)
{
$j = @mt_rand(0, $i);
$tmp = $items[$i];
$items[$i] = $items[$j];
$items[$j] = $tmp;
}
}
function mots_espaces($max, $min=0) {
function mots_espaces($max, $min=0, $seed=0) {
global $mots_de_n_lettres;
global $dico;
if ($seed) {
fisherYatesShuffle($mots_de_n_lettres[$max], $seed);
} else {
shuffle($mots_de_n_lettres[$max]);
}
foreach($mots_de_n_lettres[$max] as $mot) {
yield $mot;
}