diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e372a30ea15ad471cc07948d724419de7a41f6e9 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# Cellulut LO21 + +Application développée dans le cadre de l’UV LO21 permet de répondre à la problématique de simulation d’automates. + +## Sommaire + + - [Pour commencer](#pour-commencer) + - [Installation](#installation) + - [](#) + - [](#) + - [](#) + - [](#) + - [](#) + - [](#) + - [](#) + - [](#) + - [](#) + - [](#) + - [Glossaire](#glossaire) +## Pour commencer + +Avoir une version de **QtCreator** d'au moins 5.12. + + +### Installation + +Dans votre répétoire faire: `$ git clone https://gitlab.utc.fr/lo21_pin_noir_boucher_bouri_detree/cellulutlo21.git` + +## Démarrage + +Dites comment faire pour lancer votre projet + +## Fabriqué avec + +Entrez les programmes/logiciels/ressources que vous avez utilisé pour développer votre projet + +_exemples :_ +* [Materialize.css](http://materializecss.com) - Framework CSS (front-end) +* [Atom](https://atom.io/) - Editeur de textes + +## Contributing + +Si vous souhaitez contribuer, lisez le fichier [CONTRIBUTING.md](https://example.org) pour savoir comment le faire. + +## Versions +Listez les versions ici +_exemple :_ +**Dernière version stable :** 5.0 +**Dernière version :** 5.1 +Liste des versions : [Cliquer pour afficher](https://github.com/your/project-name/tags) +_(pour le lien mettez simplement l'URL de votre projets suivi de ``/tags``)_ + +## Auteurs +Listez le(s) auteur(s) du projet ici ! +* **Jhon doe** _alias_ [@outout14](https://github.com/outout14) + +Lisez la liste des [contributeurs](https://github.com/your/project/contributors) pour voir qui à aidé au projet ! + +_(pour le lien mettez simplement l'URL de votre projet suivi de ``/contirubors``)_ + +## License + +Ce projet est sous licence ``exemple: WTFTPL`` - voir le fichier [LICENSE.md](LICENSE.md) pour plus d'informations + diff --git a/include/grid.h b/include/grid.h index 7964252292f1426a6e2d5ac2e7364728f1c3785e..520f5441ff64a047e94cf64f5711110992f310ff 100644 --- a/include/grid.h +++ b/include/grid.h @@ -107,7 +107,7 @@ public: Grid& operator=(const Grid& g); //! \brief Vérifie si deux grilles sont identiques - bool operator==(const Grid&); + bool operator==(const Grid&) const; //! \brief Retourne une structure représentant le contenu non-nul de la Grid (les cellules d'état != 0), pour un enregistrement dans un fichier par exemple. Structure to_structure() const; diff --git a/include/simulation.hpp b/include/simulation.hpp index 1bc710e443c8400d7fbb9421a16b9fea0e8febfa..2176ca4e511495cb09d5657a2b0ee36c226bfaf0 100644 --- a/include/simulation.hpp +++ b/include/simulation.hpp @@ -18,7 +18,7 @@ class Simulation { private: bool canRun; unsigned int time; - unsigned int period; + int period; Automaton automaton; Grid startGrid; History hist; @@ -89,8 +89,9 @@ public: //! \brief Donne la période de la simulation //! //! Si elle n'est pas encore obtenue : vaut 0 + //! Si elle ne pourra jamais l'être : vaut -1 (s'il y a eu une modification de la grille en cours d'éxécution) //! \return période de la simulation - unsigned int getPeriod() {return period;} + int getPeriod() {return period;} //! \brief Indique l'étape actuelle de la simulation //! \return nombre de pas depuis le début diff --git a/src/grid.cpp b/src/grid.cpp index 63111a19f8bee97f4b82d22940e846b54bf7acb0..4134229ebb1fdd1c77717f6e83baaa7a159e5e03 100644 --- a/src/grid.cpp +++ b/src/grid.cpp @@ -44,7 +44,7 @@ Grid& Grid::operator=(const Grid& g){ return *this; } -bool Grid::operator==(const Grid & G) { +bool Grid::operator==(const Grid & G) const { return nb_rows==G.nb_rows && nb_col==G.nb_col && matrix==G.matrix; } diff --git a/src/interface.cpp b/src/interface.cpp index 63678b38a5fc09fc0eca16cfc3dc9e9c51c41841..a8b6df7aee45f65d3161af9451fd8ab67983e7fc 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -945,7 +945,7 @@ void MainWindow::on_nextButton_clicked() simulation.setGrid(ui->grid_view->get_grid()); simulation.step(); ui->grid_view->copy_grid(simulation.getGrid()); - ui->stepsPeriodLabel->setText(QString::number(simulation.getPeriod())+" steps"); + ui->stepsPeriodLabel->setText(simulation.getPeriod()!=-1?QString::number(simulation.getPeriod())+" steps":"none"); ui->nbStepsLabel->setText(QString::number(simulation.getTime())+" steps"); if(simulation.frozen()) { ui->simStatusLabel->setText("Status : frozen"); @@ -958,7 +958,7 @@ void MainWindow::on_prevButton_clicked() QMessageBox::warning(this, "Unable to step back", "Empty history : unable to step back"); } ui->grid_view->copy_grid(simulation.getGrid()); - ui->nbStepsLabel->setText(QString::number(simulation.getTime())+" steps"); + ui->nbStepsLabel->setText(simulation.getPeriod()!=-1?QString::number(simulation.getPeriod())+" steps":"none"); } void MainWindow::on_playPauseButton_clicked() diff --git a/src/simulation.cpp b/src/simulation.cpp index 04c06be681f4f6fad7a593c4d276352e24b559d4..897827fe6a4745cecad15c21515fed3d85a7a260 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -34,6 +34,8 @@ void Simulation::setGrid(const Grid & grid) { hist = History(hist.get_nbMax()); } else if((grid.get_col() != automaton.getGrid().get_col())&&(grid.get_rows() != automaton.getGrid().get_rows())) { return; + } else if(!(automaton.getGrid() == grid)) { //S'il y a modification manuelle de la grille pendant la simulation + period = -1; } automaton.setGrid(grid); } @@ -65,7 +67,6 @@ void Simulation::resize(size_t l,size_t c) { hist = History(hist.get_nbMax()); } -#include <QElapsedTimer> void Simulation::step() { if(!canRun) { return; @@ -73,13 +74,10 @@ void Simulation::step() { ++time; hist.pushGrid(automaton.getGrid()); - QElapsedTimer t; - t.start(); automaton.runOnce(); - qDebug() << t.elapsed(); automaton.getNeighborhoodRule()->update_generation(time); - if(!period && startGrid == automaton.getGrid()) { + if(period==0 && startGrid == automaton.getGrid()) { period = time; } }