Compare commits
2 Commits
4a51ed72eb
...
aeb1d28672
| Author | SHA1 | Date | |
|---|---|---|---|
|
aeb1d28672
|
|||
|
27b6033625
|
@@ -99,6 +99,7 @@ class Grille implements ArrayAccess
|
||||
"verticales" => []
|
||||
];
|
||||
foreach($this->lignes as $y => $mots) {
|
||||
$mots = explode_pos(CASE_NOIRE, $this->get_ligne($y, $this->largeur));
|
||||
$this->definitions["horizontales"][$y] = [];
|
||||
foreach($mots as $fin => $mot) {
|
||||
$definitions = $this->dico[strlen($mot)][$mot];
|
||||
@@ -112,6 +113,7 @@ class Grille implements ArrayAccess
|
||||
}
|
||||
}
|
||||
foreach($this->colonnes as $x => $mots) {
|
||||
$mots = explode_pos(CASE_NOIRE, $this->get_colonne($x, $this->hauteur));
|
||||
$this->definitions["verticales"][$x] = [];
|
||||
foreach($mots as $fin => $mot) {
|
||||
$definitions = $this->dico[strlen($mot)][$mot];
|
||||
@@ -150,6 +152,7 @@ class Grille implements ArrayAccess
|
||||
$lettres_ligne->branches,
|
||||
$lettres_colonne->branches
|
||||
);
|
||||
// Sélection des candidats les plus fertiles
|
||||
foreach ($lettres_communes as $lettre => $_) {
|
||||
$lettres_communes[$lettre] = log(count($lettres_ligne->branches[$lettre])) * count($lettres_colonne->branches[$lettre]) * gaussienne(ECART_TYPE, ECART_TYPE);
|
||||
}
|
||||
@@ -181,8 +184,8 @@ class Grille implements ArrayAccess
|
||||
|
||||
// Omission des doublons
|
||||
$mots = [];
|
||||
if ($x == $this->largeur - 1) $mots = explode_pos(CASE_NOIRE, $this->get_ligne($y, $this->largeur));
|
||||
else if ($lettre == CASE_NOIRE) $mots = explode_pos(CASE_NOIRE, $this->get_ligne($y, $x));
|
||||
if ($x == $this->largeur - 1) $mots = explode(CASE_NOIRE, $this->get_ligne($y, $this->largeur));
|
||||
else if ($lettre == CASE_NOIRE) $mots = explode(CASE_NOIRE, $this->get_ligne($y, $x));
|
||||
else $mots = [];
|
||||
$this->lignes[$y] = array_filter($mots, function ($mot) {
|
||||
return strlen($mot) >= 2;
|
||||
@@ -194,7 +197,7 @@ class Grille implements ArrayAccess
|
||||
}
|
||||
|
||||
if ($y == $this->hauteur - 1) {
|
||||
$mots = explode_pos(CASE_NOIRE, $this->get_colonne($x, $this->hauteur));
|
||||
$mots = explode(CASE_NOIRE, $this->get_colonne($x, $this->hauteur));
|
||||
foreach ($mots as $rang => $mot) {
|
||||
if (strlen($mot) < 2) continue;
|
||||
if (strlen($mot > 2) && in_array($mot, array_merge(...$this->lignes, ...$this->colonnes))) continue 2;
|
||||
|
||||
16
index.php
16
index.php
@@ -145,14 +145,14 @@ function mot_courant($mots, $position) {
|
||||
<?php else: ?>
|
||||
<td class="case blanche">
|
||||
<?php
|
||||
$title = "";
|
||||
$title = [];
|
||||
$definition_horizontale = mot_courant($grille->definitions["horizontales"][$y], $x);
|
||||
$definition_verticale = mot_courant($grille->definitions["verticales"][$x], $y);
|
||||
if (isset($definition_horizontale[0])) $title .= "→ " . $definition_horizontale[0];
|
||||
if (isset($definition_horizontale[1])) $title .= " (" . $definition_horizontale[1] . ")";
|
||||
if (isset($definition_verticale[0])) $title .= "\n ↓ " . $definition_verticale[0];
|
||||
if (isset($definition_verticale[1])) $title .= " (" . $definition_verticale[1] . ")";
|
||||
$title = htmlspecialchars($title);
|
||||
if (isset($definition_horizontale[0])) $title[0] = "→ " . $definition_horizontale[0];
|
||||
if (isset($definition_horizontale[1])) $title[0] .= " (" . $definition_horizontale[1] . ")";
|
||||
if (isset($definition_verticale[0])) $title[1] = "↓ " . $definition_verticale[0];
|
||||
if (isset($definition_verticale[1])) $title[1] .= " (" . $definition_verticale[1] . ")";
|
||||
$title = htmlspecialchars(implode("\n", $title));
|
||||
?>
|
||||
<input id="<?= chr($x + 65) . ($y + 1) ?>" type="text" maxlength="1" size="1" pattern="[A-Z]"
|
||||
title="<?=$title?>" />
|
||||
@@ -174,7 +174,9 @@ function mot_courant($mots, $position) {
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($definitions as $definition) : ?>
|
||||
<?php if (isset($definition[0])): ?>
|
||||
<li><?= formatter_definition($definition) ?></li>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
<?php endif ?>
|
||||
@@ -194,7 +196,9 @@ function mot_courant($mots, $position) {
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($definitions as $definition) : ?>
|
||||
<?php if (isset($definition[0])): ?>
|
||||
<li><?= formatter_definition($definition) ?></li>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
<?php endif ?>
|
||||
|
||||
Reference in New Issue
Block a user