-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simulate.h
63 lines (47 loc) · 1.65 KB
/
Simulate.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
//
// Created by botanic on 8/7/15.
//
#ifndef ICFP2015_SIMULATE_H
#define ICFP2015_SIMULATE_H
#include "Actions.h"
#include "RNGSeed.h"
#include "units.h"
#include "Field.h"
namespace icfp2015 {
enum class VerifyState {
Pass, Fail, Lock
};
class Simulate {
Field field;
const Units &units; // shared const
RNG gen;
Solution last;
Path unitPath;
Unit curUnit;
int uX, uY; // unit coords
const int nUnits;
int nCurUnit;
int curScore;
int lastLines;
public:
Simulate(const Field &f, const Units &u, RNG &g, int maxU) : field(f), units(u), gen(g), nCurUnit(0),
curScore(0),
lastLines(0), nUnits(maxU) { };
bool nextUnit(); // returns true if figure can be == is placed
VerifyState step(Actions a, bool verify = false); // returns true if action didn`t lock
const long score() { return curScore; }
long run(Solution &sol); // returns score, field not reset after.
const void print(const string ¬e) const { field.print(note); }
const long penalty() const { return field.penalty(); }
const void print() const {
char buf[120];
snprintf(buf, 120, "@(%i, %i %% %i) after", uX, uY, curUnit.Orient());
string rslt(buf);
rslt += ToString(last.code.back());
field.print(rslt, true);
}
const Solution getLast() const { return last; }
Solution Moves();
};
}
#endif //ICFP2015_SIMULATE_H