unity环境配置报错。。

KAila_Lucky 2018-12-11 08:47:17
求各位大佬帮忙看看,,,unity强化学习环境搭建过程出现如下错误。。。。
因为本人并不懂C#, 所以只能求各位帮忙了!不胜感激!

代码是这样的:
using System.Collections.Generic;
using UnityEngine;

public class RollerAgent : Agent
{
Rigidbody rBody;
void Start()
{
rBody = GetComponent<Rigidbody>();
}

public Transform Target;
public override void AgentReset()
{
if (this.transform.position.y < -1.0)
{
// agent 掉落
this.transform.position = Vector3.zero;
this.rBody.angularVelocity = Vector3.zero;
this.rBody.velocity = Vector3.zero;
}
else
{
// 将目标移动到新的位置
Target.position = new Vector3(Random.value * 8 - 4,
0.5f,
Random.value * 8 - 4);
}
}


public override void CollectObservations()
{
// 计算相对位置
Vector3 relativePosition = Target.position - this.transform.position;

// 相对位置
AddVectorObs(relativePosition.x / 5);
AddVectorObs(relativePosition.z / 5);

// 与平台边缘的距离
AddVectorObs((this.transform.position.x + 5) / 5);
AddVectorObs((this.transform.position.x - 5) / 5);
AddVectorObs((this.transform.position.z + 5) / 5);
AddVectorObs((this.transform.position.z - 5) / 5);

// Agent 速度
AddVectorObs(rBody.velocity.x / 5);
AddVectorObs(rBody.velocity.z / 5);
}

public float speed = 10;
private float previousDistance = float.MaxValue;

public override void AgentAction(float[] vectorAction, string textAction)
{
// 奖励
float distanceToTarget = Vector3.Distance(this.transform.position,
Target.position);

// 已到达目标
if (distanceToTarget < 1.42f)
{
Done();
AddReward(1.0f);
}

// 进一步接近
if (distanceToTarget < previousDistance)
{
AddReward(0.1f);
}

// 时间惩罚
AddReward(-0.05f);

// 掉下平台
if (this.transform.position.y < -1.0)
{
Done();
AddReward(-1.0f);
}
previousDistance = distanceToTarget;

// 动作,大小 = 2
Vector3 controlSignal = Vector3.zero;
controlSignal.x = Mathf.Clamp(vectorAction[0], -1, 1);
controlSignal.z = Mathf.Clamp(vectorAction[1], -1, 1);
rBody.AddForce(controlSignal * speed);
}

public float speed = 10;
private float previousDistance = float.MaxValue;

public override void AgentAction(float[] vectorAction, string textAction)
{
// Rewards
float distanceToTarget = Vector3.Distance(this.transform.position,
Target.position);

// Reached target
if (distanceToTarget < 1.42f)
{
AddReward(1.0f);
Done();
}

// Time penalty
AddReward(-0.05f);

// Fell off platform
if (this.transform.position.y < -1.0)
{
AddReward(-1.0f);
Done();
}

// Actions, size = 2
Vector3 controlSignal = Vector3.zero;
controlSignal.x = vectorAction[0];
controlSignal.z = vectorAction[1];
rBody.AddForce(controlSignal * speed);
}
}
...全文
257 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxy2847225301 2018-12-12
  • 打赏
  • 举报
回复
Agent这个类你没有复制吧
stherix 2018-12-12
  • 打赏
  • 举报
回复
RollerAgent 这个类,你复制了两次吧?
KAila_Lucky 2018-12-11
  • 打赏
  • 举报
回复
代码是我复制别人的,,哪里出问题了呀。。。

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧