CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Util
RandomEngine.cpp
浏览该文件的文档.
1
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#include "
Carla.h
"
8
#include "
RandomEngine.h
"
9
10
#include <limits>
11
12
uint64
URandomEngine::GenerateRandomId
()
13
{
14
// Tuned to be fast as this function might get called relatively often.
15
static
thread_local
std::mt19937_64
Engine
((std::random_device())());
16
std::uniform_int_distribution<uint64> Distribution(
17
std::numeric_limits<uint64>::lowest(),
18
std::numeric_limits<uint64>::max());
19
return
Distribution(
Engine
);
20
}
21
22
int32
URandomEngine::GenerateRandomSeed
()
23
{
24
std::random_device RandomDevice;
25
std::uniform_int_distribution<int32> Distribution(
26
std::numeric_limits<int32>::lowest(),
27
std::numeric_limits<int32>::max());
28
return
Distribution(RandomDevice);
29
}
30
31
int32
URandomEngine::GenerateSeed
()
32
{
33
return
GetUniformIntInRange
(
34
std::numeric_limits<int32>::lowest(),
35
std::numeric_limits<int32>::max());
36
}
Carla.h
RandomEngine.h
URandomEngine::Engine
std::minstd_rand Engine
Definition
RandomEngine.h:158
URandomEngine::GetUniformIntInRange
int32 GetUniformIntInRange(int32 Minimum, int32 Maximum)
Definition
RandomEngine.h:68
URandomEngine::GenerateRandomId
static uint64 GenerateRandomId()
Generate a non-deterministic random id.
Definition
RandomEngine.cpp:12
URandomEngine::GenerateRandomSeed
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.
Definition
RandomEngine.cpp:22
URandomEngine::GenerateSeed
int32 GenerateSeed()
Generate a seed derived from previous seed.
Definition
RandomEngine.cpp:31
制作者
1.10.0