20 lines
476 B
C++
20 lines
476 B
C++
#pragma once
|
|
|
|
#include "grid.hpp"
|
|
#include <random>
|
|
|
|
namespace detail {
|
|
template <int W, int H, typename URNG, size_t... I>
|
|
auto random_field(URNG&& r, std::index_sequence<I...>){
|
|
std::uniform_int_distribution<int> dis(1, 2);
|
|
return create_rectangular_field<W, H>({
|
|
((void)I, dis(r))...
|
|
});
|
|
}
|
|
}
|
|
|
|
template <int W, int H, typename URNG>
|
|
auto random_field(URNG&& r){
|
|
using Indices = std::make_index_sequence<W*H>;
|
|
return detail::random_field<W, H>(r, Indices{});
|
|
}
|