Ajout des arguments pour le benchmark
This commit is contained in:
parent
38302bd43d
commit
e5dd9cc89b
1 changed files with 32 additions and 21 deletions
41
src/main.cpp
41
src/main.cpp
|
@ -1,30 +1,45 @@
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "../includes/univers.hpp"
|
#include "../includes/univers.hpp"
|
||||||
#include "../includes/evenement.hpp"
|
#include "../includes/evenement.hpp"
|
||||||
|
|
||||||
|
void erreurArguments(char const * nom_programme) {
|
||||||
|
std::cerr << "Arguments mal renseignés." << std::endl;
|
||||||
|
std::cout << "Usage : " << nom_programme << " m n nb_moutons nb_loups" << std::endl;
|
||||||
|
std::cout << "Usage : " << nom_programme << " -b/--benchmark m n [e]" << std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// m x n = taille de l'univers
|
// m x n = taille de l'univers
|
||||||
// nb_moutons = nombre de moutons
|
// nb_moutons = nombre de moutons
|
||||||
// nb_loups = nombre de loups
|
// nb_loups = nombre de loups
|
||||||
int main(int argc, char const *argv[]) {
|
int main(int argc, char const * argv[]) {
|
||||||
if(argc > 1 && argc != 5) {
|
if(argc != 1 && argc != 4 && argc != 5) {
|
||||||
std::cerr << "Arguments non renseignés." << std::endl;
|
erreurArguments(argv[0]);
|
||||||
std::cout << "Usage : " << argv[0] << " m n nb_moutons nb_loups" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
int m, n, nb_moutons, nb_loups;
|
int m, n, nb_moutons, nb_loups;
|
||||||
|
if(argc == 1) { // valeurs par défaut
|
||||||
|
m = 5;
|
||||||
|
n = 6;
|
||||||
|
nb_moutons = 9;
|
||||||
|
nb_loups = 4;
|
||||||
|
} else {
|
||||||
|
if(strcmp(argv[1], "-b") == 0 || strcmp(argv[1], "--benchmark") == 0) {
|
||||||
|
std::cout << "Benchmark pas encore implanté." << std::endl;
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
if(argc == 5) { // renseigné par l'utilisateur
|
if(argc == 5) { // renseigné par l'utilisateur
|
||||||
m = std::stoi(argv[1]);
|
m = std::stoi(argv[1]);
|
||||||
n = std::stoi(argv[2]);
|
n = std::stoi(argv[2]);
|
||||||
nb_moutons = std::stoi(argv[3]);
|
nb_moutons = std::stoi(argv[3]);
|
||||||
nb_loups = std::stoi(argv[4]);
|
nb_loups = std::stoi(argv[4]);
|
||||||
} else { // valeurs par défaut
|
} else { // argc = 4 et pourtant pas de "-b"
|
||||||
m = 5;
|
erreurArguments(argv[0]);
|
||||||
n = 6;
|
}
|
||||||
nb_moutons = 9;
|
}
|
||||||
nb_loups = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Univers * univers = nullptr;
|
Univers * univers = nullptr;
|
||||||
try {
|
|
||||||
Evenement::creationSimulation(&univers, m, n, nb_moutons, nb_loups);
|
Evenement::creationSimulation(&univers, m, n, nb_moutons, nb_loups);
|
||||||
|
|
||||||
Evenement::affichage(univers);
|
Evenement::affichage(univers);
|
||||||
|
@ -34,10 +49,6 @@ int main(int argc, char const *argv[]) {
|
||||||
Evenement::affichage(univers);
|
Evenement::affichage(univers);
|
||||||
|
|
||||||
Evenement::arreterSimulation(univers);
|
Evenement::arreterSimulation(univers);
|
||||||
} catch(const std::exception& e) {
|
|
||||||
std::cerr << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue