-
Notifications
You must be signed in to change notification settings - Fork 9
/
map_loader.h
34 lines (30 loc) · 1.18 KB
/
map_loader.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
#pragma once
#include "common.h"
class MapLoader {
public:
bool* my_map; // true means a cell is blocked
int rows;
int cols;
int start_loc;
int goal_loc;
std::string name;
enum valid_moves_t { NORTH, EAST, SOUTH, WEST, WAIT_MOVE, MOVE_COUNT }; // MOVE_COUNT is the enum's size
int* moves_offset;
MapLoader(){}
MapLoader(std::string fname); // load map from file
MapLoader(int rows, int cols); // initialize new [rows x cols] empty map
inline bool is_blocked (int row, int col) const { return my_map[row * this->cols + col]; }
inline bool is_blocked (int loc) const { return my_map[loc]; }
inline size_t map_size() const { return rows * cols; }
void printMap ();
void printMap (char* mapChar);
void printHeuristic (const double* mapH, const int agent_id);
char* mapToChar();
bool* copy_map () const; // return a deep-copy of my_map
inline int linearize_coordinate(int row, int col) const { return ( this->cols * row + col); }
inline int row_coordinate(int id) const { return id / this->cols; }
inline int col_coordinate(int id) const { return id % this->cols; }
void printPath (std::vector<int> path);
void saveToFile(std::string fname);
~MapLoader();
};