diff options
| author | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
|---|---|---|
| committer | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
| commit | 9fe033ea88c2f705ec18c232873d056e0c229d72 (patch) | |
| tree | 0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h | |
Initial commit
Diffstat (limited to 'sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h')
| -rw-r--r-- | sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h b/sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h new file mode 100644 index 0000000..2ba155c --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/population-vivante-v2.h @@ -0,0 +1,60 @@ +#ifndef __POPULATION_VIVANTE_H +#define __POPULATION_VIVANTE_H +#include "cellule.h" + +#define NMAX 10000 + +class PopulationVivante { + private: + Cellule T[NMAX]; + size_t alive; + size_t N; + float probability; + + // retourne le nbr de voisins vivants de la cellule à (i,j) + size_t nb_voisins_vivants(size_t, size_t) const; + + // access to cell at (i,j) if not alive get NULL + const Cellule* at(size_t i, size_t j)const; + Cellule* at(size_t i, size_t j); + // Mise à jour des couleurs des cellules mourantes + void updateColors(); + + size_t nb_cellules(Cellule::Couleur c) const; + + public: + + // construction d'une n-population avec une probabilité fixée. + PopulationVivante(size_t n, float prob); + + // accesseurs en interrogation + size_t nb_vivants() const; + size_t nb_deces() const; + size_t nb_morts() const; + size_t nb_naissances() const; + size_t getDimension() const; + float getProbability() const; + + + // accesseurs en lecture d'une cellule + Cellule getCelluleCopie(size_t i, size_t j) const; + + // accesseurs en modification + void kill(size_t i, size_t j); + void birth(size_t i, size_t j); + void setDimension(size_t n); + void setProbability(float p); + + // affichage d'une cellule + void printCell(size_t i, size_t j) const; + // affichage de la population + void print() const; + + // Re-création de la population + void reset(); + + // calcul de la population suivante + PopulationVivante next() const; +}; + +#endif |
