forked from cyb0124/FissionOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFission.h
73 lines (63 loc) · 1.99 KB
/
Fission.h
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
#ifndef _FISSION_H_
#define _FISSION_H_
#include <xtensor/xtensor.hpp>
#include <string>
namespace Fission {
using Coords = std::vector<std::tuple<int, int, int>>;
constexpr int neutronReach(4);
constexpr double modPower(1.0), modHeat(2.0);
enum {
// Cooler
Water, Redstone, Quartz, Gold, Glowstone,
Lapis, Diamond, Helium, Enderium, Cryotheum,
Iron, Emerald, Copper, Tin, Magnesium, Active,
// Other
Cell = Active * 2, Moderator, Air
};
enum {
GoalPower,
GoalBreeder,
GoalEfficiency
};
struct Settings {
int sizeX, sizeY, sizeZ;
double fuelBasePower, fuelBaseHeat;
int limit[Air];
double coolingRates[Cell];
bool ensureActiveCoolerAccessible;
bool ensureHeatNeutral;
int goal;
bool symX, symY, symZ;
};
struct Evaluation {
// Raw
Coords invalidTiles;
double powerMult, heatMult, cooling;
int breed;
// Computed
double heat, netHeat, dutyCycle, avgMult, power, avgPower, avgBreed, efficiency;
void compute(const Settings &settings);
};
class Evaluator {
const Settings &settings;
xt::xtensor<int, 3> mults, rules;
xt::xtensor<bool, 3> isActive, isModeratorInLine, visited;
const xt::xtensor<int, 3> *state;
int compatibleTile;
int getTileSafe(int x, int y, int z) const;
int getMultSafe(int x, int y, int z) const;
bool countMult(int x, int y, int z, int dx, int dy, int dz);
int countMult(int x, int y, int z);
bool isActiveSafe(int tile, int x, int y, int z) const;
int countActiveNeighbors(int tile, int x, int y, int z) const;
bool isTileSafe(int tile, int x, int y, int z) const;
int countNeighbors(int tile, int x, int y, int z) const;
int countCasingNeighbors(int x, int y, int z) const;
bool checkAccessibility(int compatibleTile, int x, int y, int z);
bool checkAccessibility(int x, int y, int z);
public:
Evaluator(const Settings &settings);
void run(const xt::xtensor<int, 3> &state, Evaluation &result);
};
}
#endif