From 471ae7b6ec6d33fdf8cf204ca6ed0afc46ebe36f Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Fri, 11 Jun 2021 18:54:12 +0200 Subject: [PATCH 1/2] Initialize when click on grid --- src/autocell.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/autocell.cpp b/src/autocell.cpp index 1a2420f..5d9a0c9 100644 --- a/src/autocell.cpp +++ b/src/autocell.cpp @@ -336,6 +336,9 @@ void AutoCell::modifierCellule(const QModelIndex& index) { grid->item(i,j)->setText(str_indice); //réitnitialiser l'automate ou modif du buffer d + Automate::getInstance().reset(); + Automate::getInstance().setReseauInit(*Grille); + Automate::getInstance().initialiserBuffer(); } void AutoCell::sauvegarderGrille(){ -- GitLab From 7a8d5d0a0cd10d6c371a26e0ac4b97142f2a9892 Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Fri, 11 Jun 2021 19:43:17 +0200 Subject: [PATCH 2/2] Two dimensions were inverted --- src/Automate.cpp | 2 +- src/voisinage.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Automate.cpp b/src/Automate.cpp index b426cd4..9b6636f 100644 --- a/src/Automate.cpp +++ b/src/Automate.cpp @@ -12,7 +12,7 @@ void Automate::nextTimer() { for(size_t j = 0; j < l; ++j) { Voisinage voisinage(&(*(--buffer.end())).getReseau()[i][j]); regleVoisinage->calculVoisinage(voisinage, *(--buffer.end())); - const Etat e = fonction->getEtatSuivant(voisinage, r.getReseau()[i][j]); + const Etat e = fonction->getEtatSuivant(voisinage, (*(--buffer.end())).getReseau()[i][j]); while(r.getReseau()[i][j].getIndEtat() != e.getIndice()) r.getReseau()[i][j].incrementerEtat(); } diff --git a/src/voisinage.cpp b/src/voisinage.cpp index 8a3e3f1..a6d087d 100644 --- a/src/voisinage.cpp +++ b/src/voisinage.cpp @@ -20,7 +20,7 @@ void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) const int y = (cellX+j)%largeur; if (y < 0) y = hauteur + y; - v.voisinage.push_back(new Cellule(r.getReseau()[x][y])); + v.voisinage.push_back(new Cellule(r.getReseau()[y][x])); } } @@ -41,7 +41,7 @@ void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r) const { int y = (cellX+j)%largeur; if (y < 0) y = hauteur + y; - v.voisinage.push_back(new Cellule(r.getReseau()[x][y])); + v.voisinage.push_back(new Cellule(r.getReseau()[y][x])); } } -- GitLab