59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <cmath>
|
|
#include <string>
|
|
|
|
#include "DLASystem.h"
|
|
|
|
using std::cout;
|
|
using std::endl;
|
|
|
|
/*
|
|
* In a proper project I would write a better argument parser, don't care here, just exit with an error if it is wrong.
|
|
* */
|
|
Config::Config(int argc, char **argv) {
|
|
if (argc != 4) {
|
|
exit(1);
|
|
} else {
|
|
this->seed = std::stoi(argv[1]);
|
|
this->stickProbability = std::stod(argv[2]);
|
|
this->maxParticles = std::stoi(argv[3]);
|
|
|
|
if (stickProbability <= 0 || stickProbability > 1) {
|
|
exit(1);
|
|
}
|
|
|
|
std::stringstream str;
|
|
// Ensure the output file name contains all information required to replicate data
|
|
str << "./out-" << seed << '-' << stickProbability << "-" << maxParticles << ".csv";
|
|
std::ofstream csv_out(str.str());
|
|
this->csv = std::move(csv_out);
|
|
|
|
// Add headers to csv output
|
|
this->csv << "frame" << "," << "x" << "," << "y" << std::endl;
|
|
|
|
cout <<
|
|
"seed: " << seed << ", " <<
|
|
"stickProbability: " << stickProbability << ", " <<
|
|
"maxParticles: " << maxParticles <<
|
|
endl;
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
Config config(argc, argv);
|
|
|
|
// Create the system
|
|
auto *sys = new DLASystem(std::move(config));
|
|
sys->setRunning();
|
|
|
|
/*
|
|
* NOTE: We run at max speed as rendering is handled by a different engine so we don't need to care.
|
|
* */
|
|
while (sys->running) {
|
|
sys->Update();
|
|
}
|
|
|
|
return 0;
|
|
}
|