Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

46 行
1.4 KiB

using System.Collections.Generic;
using UnityEngine;
using MLAgents;
public class Ball3DDecision : Decision
{
public float rotationSpeed = 2f;
public override float[] Decide(
List<float> vectorObs,
List<Texture2D> visualObs,
float reward,
bool done,
List<float> memory)
{
if (brainParameters.vectorActionSpaceType == SpaceType.continuous)
{
List<float> act = new List<float>();
// state[5] is the velocity of the ball in the x orientation.
// We use this number to control the Platform's z axis rotation speed,
// so that the Platform is tilted in the x orientation correspondingly.
act.Add(vectorObs[5] * rotationSpeed);
// state[7] is the velocity of the ball in the z orientation.
// We use this number to control the Platform's x axis rotation speed,
// so that the Platform is tilted in the z orientation correspondingly.
act.Add(-vectorObs[7] * rotationSpeed);
return act.ToArray();
}
// If the vector action space type is discrete, then we don't do anything.
return new float[1] { 1f };
}
public override List<float> MakeMemory(
List<float> vectorObs,
List<Texture2D> visualObs,
float reward,
bool done,
List<float> memory)
{
return new List<float>();
}
}