File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
#include " map.hpp"
2
2
3
+ #include < algorithm>
4
+ #include < random>
5
+
3
6
Map::Map () {
4
- // TODO
7
+ std::vector<unsigned int > posX (maxX);
8
+ std::vector<unsigned int > posY (maxY);
9
+
10
+ std::iota (posX.begin (), posX.end (), posX.begin ());
11
+ std::iota (posY.begin (), posY.end (), posY.begin ());
12
+
13
+ std::mt19937 gen (std::random_device{}());
14
+ std::shuffle (posX.begin (), posX.end (), gen);
15
+ std::shuffle (posY.begin (), posY.end (), gen);
16
+
17
+ vecOfIslandOnMap_.reserve (initialAmountOfIsland);
18
+
19
+ std::transform (posX.begin (),
20
+ posX.end (),
21
+ posY.begin (),
22
+ std::back_inserter (vecOfIslandOnMap_),
23
+ [](int x, int y) {
24
+ return std::make_pair (x, y);
25
+ });
5
26
}
Original file line number Diff line number Diff line change 4
4
5
5
#include " island.hpp"
6
6
7
+ constexpr int initialAmountOfIsland = 10 ;
8
+ constexpr int maxX = 10 ;
9
+ constexpr int maxY = 10 ;
10
+
7
11
class Map {
8
12
private:
9
13
std::vector<Island> vecOfIslandOnMap_;
You can’t perform that action at this time.
0 commit comments