Commit c0dded2c authored by Arnaud Bey's avatar Arnaud Bey
Browse files

add debug option to grid generation

parent 5971009c
......@@ -50,13 +50,12 @@ class DeleteLexiconCommand extends ContainerAwareCommand
foreach ($score->getActivities() as $activity) {
$em->remove($activity);
}
$output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
}
}
$em->flush();
$output->writeln('<comment>flush ok</comment>');
$output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
// delete games
$em->getRepository(Game::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression game ok</comment>');
......
......@@ -50,13 +50,12 @@ class DeleteGridCommand extends ContainerAwareCommand
foreach ($score->getActivities() as $activity) {
$em->remove($activity);
}
$output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
}
}
$em->flush();
$output->writeln('<comment>flush ok</comment>');
$output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
// delete games
$em->getRepository(Game::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression game ok</comment>');
......@@ -67,7 +66,7 @@ class DeleteGridCommand extends ContainerAwareCommand
$em->remove($grid);
}
$em->flush();
$output->writeln('<comment>Suppression grilles ok</comment>');
$output->writeln('<info>############ SUPPRESSION GRIDS OK #############</info>');
} else {
echo 'Argument missing';
}
......
......@@ -38,7 +38,7 @@ class GenerateGridCommand extends ContainerAwareCommand
while ($keptGrid < $number) {
$language = $em->getRepository('LexiconBundle:Language')->findOneByValue($languageName);
$timeStart = microtime(true);
$grid = $gridManager->generate($language);
$grid = $gridManager->generate($language, true);
$timeEnd = microtime(true);
$executionTime = round($timeEnd - $timeStart, 2);
$formCount = $grid->getFoundableForms()? count($grid->getFoundableForms()) : 0;
......
......@@ -48,11 +48,19 @@ class GridManager
}
public function generate(Language $language)
public function generate(Language $language, $debug = false)
{
$grid = $this->newGrid($language, 4);
$letters = $this->letterLangManager->lottery($language, 4);
$letters = $this->letterLangManager->lottery($language, 4, $debug);
if ($debug === true) {
echo "\nletters: ";
foreach ($letters as $letter) {
echo $letter;
}
echo "\n";
}
foreach ($letters as $letter) {
$square = $this->squareManager->create($letter, $grid);
......
......@@ -22,7 +22,7 @@ class LetterLanguageManager
$this->em = $entityManager;
}
public function lottery(Language $language, $side)
public function lottery(Language $language, $side, $debug = false)
{
$fileBigrams = $language->getDirectory().DIRECTORY_SEPARATOR."bigrams.txt";
// On crée un tableau de bigrammes
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment