浏览代码

cleaned up sampler

/sampler-refactor-copy
Andrew Cohen 5 年前
当前提交
36bd94b6
共有 1 个文件被更改,包括 5 次插入8 次删除
  1. 13
      com.unity.ml-agents/Runtime/Sampler.cs

13
com.unity.ml-agents/Runtime/Sampler.cs


using System;
using System.Linq;
using Unity.MLAgents;
using UnityEngine;
namespace Unity.MLAgents
{

public Func<float> CreateUniformSampler(float min, float max, int seed)
{
System.Random distr = new System.Random(seed);
Random distr = new Random(seed);
return () => min + (float)distr.NextDouble() * (max - min);
}

public Func<float> CreateMultiRangeUniformSampler(IList<float> intervals, int seed)
{
//RNG
System.Random distr = new System.Random(seed);
Random distr = new Random(seed);
int numIntervals = (int)(intervals.Count()/2);
int numIntervals = (int)(intervals.Count/2);
// List that will store interval lengths
float[] intervalSizes = new float[numIntervals];
// List that will store uniform distributions

for(int i = 0; i < numIntervals; i++)
{
var min = intervals.ElementAt(2 * i);
var max = intervals.ElementAt(2 * i + 1);
var min = intervals[2 * i];
var max = intervals[2 * i + 1];
var intervalSize = max - min;
sumIntervalSizes += intervalSize;
intervalSizes[i] = intervalSize;

正在加载...
取消
保存