-
Notifications
You must be signed in to change notification settings - Fork 37
/
mapgen.h
150 lines (122 loc) · 3.08 KB
/
mapgen.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// START A3HEADER
//
// This source file is part of the Atlantis PBM game program.
// Copyright (C) 2022 Valdis Zobēla
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program, in the file license.txt. If not, write
// to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// See the Atlantis Project web page for details:
// http://www.prankster.com/project
//
// END A3HEADER
#pragma once
#include "graphs.h"
#include <vector>
#include <functional>
#define B_UNKNOWN 0
#define B_TUNDRA 1
#define B_MOUNTAINS 2
#define B_SWAMP 3
#define B_FOREST 4
#define B_PLAINS 5
#define B_JUNGLE 6
#define B_DESERT 7
#define B_WATER 8
#define B_COUNT 9
struct Vapor {
int echelon;
double amount;
};
struct Edge {
int dx;
int dy;
double weight;
};
struct Range {
int min;
int max;
bool in(const int value) const;
};
struct Cell {
int index;
int x;
int y;
int biome;
int elevation;
int temperature;
int saturation;
int evoparation;
int rainfall;
// int moistureIn;
// int moistureOut;
// double saturation;
// std::vector<Vapor> moistureIn;
// std::vector<Vapor> moistureOut;
};
struct Biome {
int name;
double feritality;
Range temp;
Range rainfall;
bool match(const Cell* cell) const;
};
class CellMap {
public:
CellMap(int width, int height);
~CellMap();
int width;
int height;
std::vector<Cell*> items;
Cell* get(int x, int y);
int index(int x, int y);
void coords(int index, int& x, int& y);
bool normalize(int& x, int& y);
};
struct Blob {
std::vector<Cell*> items;
int biome;
bool includes(Cell* cell);
bool add(Cell* cell);
void add(Blob* blob);
};
using CellInclusionFunction = std::function<bool(Cell*, Cell*)>;
class CellGraph : public graphs::Graph<int, Cell*> {
public:
CellGraph(CellMap* map);
~CellGraph();
Cell* get(int id);
std::vector<int> neighbors(int id);
double cost(int current, int next);
void setInclusion(CellInclusionFunction includeFn);
private:
CellInclusionFunction includeFn;
CellMap* map;
void addCell(Cell* current, int dx, int dy, std::vector<int>& list);
};
class Map {
public:
Map(int width, int height);
int minTemp;
int maxTemp;
double evoparation;
double redistribution;
double frequency;
double amplitude;
double waterPercent;
double mountainPercent;
CellMap map;
void Generate();
};