-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (62 loc) · 1.94 KB
/
main.cpp
File metadata and controls
80 lines (62 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// main.cpp
// Test Product
//
// Created by David Brown on 03/06/2017.
// Copyright © 2017 David Brown. All rights reserved.
//
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <iomanip>
#include <iostream>
#include <sstream>
#include "register.hpp"
#include "settings.hpp"
//#include "account.hpp"
int main(int argc, const char * argv[]) {
// Seed the random number generator
std::srand(42);
int iters = -1;
if (argc > 1) {
Settings::fname = std::string(argv[1]);
if (argc > 2) {
iters = atoi(argv[2]);
}
}
// TODO: Add a -v option eventually
// std::cout << "MicroSim Version 0.1\n\n";
// TODO: Add a -d option for this
// char the_path[256];
// getcwd(the_path, 255);
// std::cout << "\nWorking directory is " << the_path << "\n";
// Rgeister must be created before Settings
Register *reg = Register::Instance();
// Settings must be created before any accounts are created so that
// it can input the settings before they are needed.
Settings *settings = Settings::Instance();
if (iters == -1) {
iters = settings->getIters();
}
Statistics *stats = Statistics::Instance();
// Create the Government. This will automatically set up a single firm
// representing nationalised industries, civil service, and any other
// government owned business. Note that the Government itself is not
// a business and taxation is not a payment for goods or services.
Government *gov = Government::Instance();
for (int period = 1; period <= iters; period++)
{
// std::cout << ".";
Settings::period = period;
gov->trigger(period);
reg->trigger(period);
stats->next(period);
if (std::rand() % 100 < settings->getFCP()) {
reg->createFirm();
}
}
stats->report();
delete gov;
return 0;
}