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 ...@@ -50,13 +50,12 @@ class DeleteLexiconCommand extends ContainerAwareCommand
foreach ($score->getActivities() as $activity) { foreach ($score->getActivities() as $activity) {
$em->remove($activity); $em->remove($activity);
} }
$output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
} }
} }
$em->flush(); $em->flush();
$output->writeln('<comment>flush ok</comment>'); $output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
// delete games // delete games
$em->getRepository(Game::class)->deleteByLanguage($language); $em->getRepository(Game::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression game ok</comment>'); $output->writeln('<comment>Suppression game ok</comment>');
......
...@@ -50,13 +50,12 @@ class DeleteGridCommand extends ContainerAwareCommand ...@@ -50,13 +50,12 @@ class DeleteGridCommand extends ContainerAwareCommand
foreach ($score->getActivities() as $activity) { foreach ($score->getActivities() as $activity) {
$em->remove($activity); $em->remove($activity);
} }
$output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
} }
} }
$em->flush(); $em->flush();
$output->writeln('<comment>flush ok</comment>'); $output->writeln('<comment>Suppression activity ok</comment>');
$output->writeln('<comment>Suppression score ok</comment>');
// delete games // delete games
$em->getRepository(Game::class)->deleteByLanguage($language); $em->getRepository(Game::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression game ok</comment>'); $output->writeln('<comment>Suppression game ok</comment>');
...@@ -67,7 +66,7 @@ class DeleteGridCommand extends ContainerAwareCommand ...@@ -67,7 +66,7 @@ class DeleteGridCommand extends ContainerAwareCommand
$em->remove($grid); $em->remove($grid);
} }
$em->flush(); $em->flush();
$output->writeln('<comment>Suppression grilles ok</comment>'); $output->writeln('<info>############ SUPPRESSION GRIDS OK #############</info>');
} else { } else {
echo 'Argument missing'; echo 'Argument missing';
} }
......
...@@ -38,7 +38,7 @@ class GenerateGridCommand extends ContainerAwareCommand ...@@ -38,7 +38,7 @@ class GenerateGridCommand extends ContainerAwareCommand
while ($keptGrid < $number) { while ($keptGrid < $number) {
$language = $em->getRepository('LexiconBundle:Language')->findOneByValue($languageName); $language = $em->getRepository('LexiconBundle:Language')->findOneByValue($languageName);
$timeStart = microtime(true); $timeStart = microtime(true);
$grid = $gridManager->generate($language); $grid = $gridManager->generate($language, true);
$timeEnd = microtime(true); $timeEnd = microtime(true);
$executionTime = round($timeEnd - $timeStart, 2); $executionTime = round($timeEnd - $timeStart, 2);
$formCount = $grid->getFoundableForms()? count($grid->getFoundableForms()) : 0; $formCount = $grid->getFoundableForms()? count($grid->getFoundableForms()) : 0;
......
...@@ -48,11 +48,19 @@ class GridManager ...@@ -48,11 +48,19 @@ class GridManager
} }
public function generate(Language $language) public function generate(Language $language, $debug = false)
{ {
$grid = $this->newGrid($language, 4); $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) { foreach ($letters as $letter) {
$square = $this->squareManager->create($letter, $grid); $square = $this->squareManager->create($letter, $grid);
......
...@@ -22,7 +22,7 @@ class LetterLanguageManager ...@@ -22,7 +22,7 @@ class LetterLanguageManager
$this->em = $entityManager; $this->em = $entityManager;
} }
public function lottery(Language $language, $side) public function lottery(Language $language, $side, $debug = false)
{ {
$fileBigrams = $language->getDirectory().DIRECTORY_SEPARATOR."bigrams.txt"; $fileBigrams = $language->getDirectory().DIRECTORY_SEPARATOR."bigrams.txt";
// On crée un tableau de bigrammes // On crée un tableau de bigrammes
......
Markdown is supported
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