-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreactor_cli.cpp
More file actions
52 lines (44 loc) · 937 Bytes
/
Copy pathreactor_cli.cpp
File metadata and controls
52 lines (44 loc) · 937 Bytes
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
#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <string>
#include <thread>
#include <vector>
struct Neutron {
int x;
int y;
int life;
bool thermal;
};
struct StepStats {
int startNeutrons = 0;
int endNeutrons = 0;
int fissions = 0;
int born = 0;
int absorbed = 0;
int escaped = 0;
double kEff = 0.0;
};
class ReactorSim {
public:
static constexpr int W = 48;
static constexpr int H = 20;
static constexpr int MAX_NEUTRONS = 3000;
ReactorSim()
: fuel(H, std::string(W, '.')),
rng(std::random_device{}())
{
initFuel();
for(int i = 0; i < 8; i++) {
spawnNeutron(W / 2, H / 2, false);
}
}
void run() {
bool running = true,
while(running) {
draw();
std::cout << "\nCommands: [Enter]=step, r=run 25 ticks, +=insert rods, -=withdraw rods, n=inject neutron, q=quit\n";
}
}
}