Import multithreaded simulation core
This commit is contained in:
1 parent
c72c388fe9
commit
65686db1a1
4 files changed
+2239
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "settlement/core/deterministic_rng.hpp"
|
||||
#include "settlement/core/world.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace settlement {
|
||||
|
||||
std::unique_ptr<World> make_first_colony(std::size_t workers) {
|
||||
constexpr auto size = first_colony_map_size;
|
||||
auto world = std::make_unique<World>(2026, size, size, workers);
|
||||
DeterministicRng terrain_rng(0x534554544C454D45ULL);
|
||||
for (int y = 2; y < size - 2; ++y) {
|
||||
for (int x = 2; x < size - 2; ++x) {
|
||||
const int distance = std::abs(x - size / 2) + std::abs(y - size / 2);
|
||||
if (distance > 7 && terrain_rng.bounded(100) < 5) world->set_blocked({x, y});
|
||||
}
|
||||
}
|
||||
for (const auto position : {GridPosition{16, 16}, {17, 15}, {15, 15}}) {
|
||||
static_cast<void>(world->spawn_agent(position));
|
||||
}
|
||||
static_cast<void>(world->add_storage({15, 16}, 9));
|
||||
static_cast<void>(world->add_storage({16, 13}, 15, StorageKind::Pantry));
|
||||
const auto provisions = world->add_storage({18, 16}, 18);
|
||||
world->stock_storage(provisions, ItemType::Cloth, 12);
|
||||
world->stock_storage(provisions, ItemType::Stone, 6);
|
||||
static_cast<void>(world->add_resource_node({12, 16}, ItemType::Wood, 12));
|
||||
static_cast<void>(world->add_resource_node({13, 17}, ItemType::Wood, 12));
|
||||
for (const auto position : {GridPosition{13, 14}, {14, 12}, {18, 12}, {19, 14}}) {
|
||||
static_cast<void>(world->add_resource_node(position, ItemType::Berries, 16));
|
||||
}
|
||||
world->start_scenario({15, 14});
|
||||
return world;
|
||||
}
|
||||
|
||||
} // namespace settlement
|
||||
Reference in new issue
Block a user