eis/TestProject/RNG/model/BoolRandomModel.h
2026-05-13 15:13:31 +08:00

15 lines
390 B
C

#pragma once
#include <TestProject/RNG/model/IModel.h>
#include <nlohmann/json.hpp>
#include <cstdlib>
using json = nlohmann::json;
struct BoolRandomModel : IModel {
float prob_true;
BoolRandomModel(const json& params, float defaultVal)
: prob_true(params.value("prob_true", 0.5f)) {}
bool evaluateBool(size_t) override {
return (double)rand() / RAND_MAX < prob_true;
}
};