-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.h
36 lines (27 loc) · 1.15 KB
/
helpers.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
#ifndef HELPERS_H
#define HELPERS_H
#include <vector>
#include <string>
// Normalizes a grid of numbers.
std::vector< std::vector<float> > normalize(std::vector< std::vector <float> > grid);
/**
Blurs (and normalizes) a grid of probabilities by spreading
probability from each cell over a 3x3 "window" of cells. This
function assumes a cyclic world where probability "spills
over" from the right edge to the left and bottom to top.
*/
std::vector < std::vector <float> > blur(std::vector < std::vector < float> > grid, float blurring);
/**
Determines when two grids of floating point numbers
are "close enough" that they should be considered
equal. Useful for battling "floating point errors".
*/
bool close_enough(std::vector < std::vector <float> > g1, std::vector < std::vector <float> > g2);
bool close_enough(float v1, float v2);
// Helper function for reading in map data
std::vector <char> read_line(std::string s);
// Helper function for reading in map data
std::vector < std::vector <char> > read_map(std::string file_name);
// Creates a grid of zeros
std::vector < std::vector <float> > zeros(int height, int width);
#endif /* HELPERS_H */