-
Notifications
You must be signed in to change notification settings - Fork 4
/
Grid.h
60 lines (50 loc) · 1.45 KB
/
Grid.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
//
// Grid.h
// Fission
//
// Created by C0deH4cker on 2/23/14.
// Copyright (c) 2014 C0deH4cker. All rights reserved.
//
#ifndef FSN_GRID_H
#define FSN_GRID_H
#include <istream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <memory>
#include "Atom.h"
#include "Point.h"
#include "Token.h"
#include "Teleporter.h"
#include "Skipper.h"
#include "DynamicComponent.h"
namespace fsn {
class Fission;
class Grid {
public:
int width, height;
Grid(std::istream& src, bool skipShebang = false);
void tick(Fission& mgr, bool trace = false);
void spawn(const Atom& atom);
void teleport(Atom& atom, int channel, int from);
std::shared_ptr<Teleporter> addTeleporter(Token type, Point pt);
std::shared_ptr<Skipper> addSkipper(Token type, Point pt);
void addDynamic(std::shared_ptr<DynamicComponent> dyn);
void removeDynamic(std::shared_ptr<DynamicComponent> dyn);
void terminate(int status);
private:
std::vector<std::vector<std::shared_ptr<Component>>> cells;
std::priority_queue<Atom, std::vector<Atom>, std::greater<Atom>> atoms;
std::vector<Point> teleporters[36];
std::unordered_map<int, std::map<int, std::shared_ptr<Skipper>>> skipRows;
std::unordered_map<int, std::map<int, std::shared_ptr<Skipper>>> skipCols;
std::unordered_set<std::shared_ptr<DynamicComponent>> dynamics;
int telcount[36];
bool stop;
int status;
};
}
#endif /* FSN_GRID_H */