V2.1 Easier game!
Build-ParallelEnv-Target-OffPolicy-SingleStack-SideChannel-EndReward-Easy-V2.1 move remain time position after target state easier game reward get, while watching or shoot at target area u get reward(attack mode), watching enemy u also get reward(Freemode)
This commit is contained in:
@@ -1 +1 @@
|
||||
{"count":1,"self":10.5192528,"total":10.849220899999999,"children":{"InitializeActuators":{"count":16,"self":0.0015046,"total":0.0015046,"children":null},"InitializeSensors":{"count":16,"self":0.0015007,"total":0.0015007,"children":null},"AgentSendState":{"count":286,"self":0.0080161,"total":0.2672959,"children":{"CollectObservations":{"count":2288,"self":0.2547756,"total":0.2547756,"children":null},"WriteActionMask":{"count":2288,"self":0.0010035,"total":0.0010035,"children":null},"RequestDecision":{"count":2288,"self":0.0035007,"total":0.0035007,"children":null}}},"DecideAction":{"count":286,"self":0.0080269,"total":0.0080269,"children":null},"AgentAct":{"count":286,"self":0.0511388,"total":0.0511388,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1670110662","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-UCUNI -hubSessionId e96bd570-7311-11ed-acd6-8dc2264f2f57 -accessToken MoIZzq15aBLxocQuZONQNXLroHJT33mJvl_8kIgeC9I00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"InGame","end_time_seconds":"1670110673"}}
|
||||
{"count":1,"self":88.4663168,"total":93.048173699999992,"children":{"InitializeActuators":{"count":16,"self":0.0015,"total":0.0015,"children":null},"InitializeSensors":{"count":16,"self":0.0005015,"total":0.0005015,"children":null},"AgentSendState":{"count":4400,"self":0.078127,"total":3.6409806999999996,"children":{"CollectObservations":{"count":35200,"self":3.5124752,"total":3.5124754,"children":null},"WriteActionMask":{"count":35200,"self":0.015002399999999999,"total":0.015002399999999999,"children":null},"RequestDecision":{"count":35200,"self":0.0353759,"total":0.0353759,"children":null}}},"DecideAction":{"count":4400,"self":0.078818199999999991,"total":0.078818199999999991,"children":null},"AgentAct":{"count":4400,"self":0.86005639999999994,"total":0.86005639999999994,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":17,"max":1351.60059,"min":-5950.65674,"runningAverage":-3077.54785,"value":-1979.05139,"weightedAverage":-1586.92932}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1670219582","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-UCUNI -hubSessionId 17fd75c0-73f2-11ed-ae93-8b2766ae699b -accessToken xyv47LyYfxjrKoKJF2JxRySrgVkeGaEV5onFZkcJqLE00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"InGame","end_time_seconds":"1670219675"}}
|
||||
@@ -587,6 +587,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &14770079
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -6159,6 +6160,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &202817962
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -8249,6 +8251,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -9573,6 +9577,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -13439,6 +13445,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &482717377
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -16520,6 +16527,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &588745181
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -19617,6 +19625,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -28488,6 +28498,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1033213894
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -30893,6 +30904,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -38483,6 +38496,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -42968,6 +42983,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -43227,6 +43244,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1692325237
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -43296,6 +43314,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1692888382
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -51369,6 +51388,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -53633,6 +53654,8 @@ MonoBehaviour:
|
||||
killReward: 5
|
||||
shootWithoutReadyReward: -0.15
|
||||
killBonusReward: 0
|
||||
facingReward: 2
|
||||
shootTargetAreaReward: 5
|
||||
speedPenalty: 0
|
||||
spinPenalty: 0.04
|
||||
hitTargetReward: 60
|
||||
@@ -56197,6 +56220,7 @@ MonoBehaviour:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
targetPosition: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2071905738
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -10,6 +10,8 @@ using Unity.MLAgents;
|
||||
using Unity.MLAgents.Sensors;
|
||||
using Unity.MLAgents.Actuators;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using Color = UnityEngine.Color;
|
||||
|
||||
/*TODO:
|
||||
√tag 攻击排他
|
||||
@@ -235,7 +237,7 @@ public class AgentWithGun : Agent
|
||||
Vector3 point = new Vector3(thisCam.pixelWidth / 2, thisCam.pixelHeight / 2, 0);//发射位置
|
||||
Ray ray = thisCam.ScreenPointToRay(point);
|
||||
RaycastHit hit;
|
||||
Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue);
|
||||
// Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue);
|
||||
//按下鼠标左键
|
||||
if (shoot != 0 && gunReadyToggle == true)
|
||||
{
|
||||
@@ -245,27 +247,78 @@ public class AgentWithGun : Agent
|
||||
{
|
||||
if (hit.collider.tag != myTag && hit.collider.tag != "Wall")
|
||||
{
|
||||
// kill enemy
|
||||
GameObject gotHitObj = hit.transform.gameObject;//获取受到Ray撞击的对象
|
||||
gotHitObj.GetComponent<states>().ReactToHit(Damage, gameObject);
|
||||
shoot = 0;
|
||||
return targetCon.hitEnemyReward(gotHitObj.transform.position);
|
||||
}
|
||||
}
|
||||
if (targetCon.targetTypeInt == (int)TargetController.Targets.Attack)
|
||||
{
|
||||
// while if attack mode
|
||||
float targetDis = Vector3.Distance(blockContainer.thisBlock.transform.position, transform.position);
|
||||
if (targetDis <= rayScript.viewDistance)
|
||||
{
|
||||
// Debug.DrawRay(new Vector3(0,0,0), viewPoint, Color.red);
|
||||
if (Vector3.Distance(ray.origin + (ray.direction * targetDis), blockContainer.thisBlock.transform.position) <= blockContainer.thisBlock.firebasesAreaDiameter / 2)
|
||||
{
|
||||
// im shooting at target but didn't hit enemy
|
||||
// Debug.DrawRay(ray.origin, viewPoint-ray.origin, Color.blue);
|
||||
return paramContainer.shootTargetAreaReward;
|
||||
}
|
||||
}
|
||||
}
|
||||
shoot = 0;
|
||||
return paramContainer.shootReward;
|
||||
}
|
||||
else if (shoot != 0 && gunReadyToggle == false)
|
||||
{
|
||||
// shoot without ready
|
||||
shoot = 0;
|
||||
return paramContainer.shootWithoutReadyReward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// do not shoot
|
||||
shoot = 0;
|
||||
return paramContainer.nonReward;
|
||||
}
|
||||
}
|
||||
|
||||
float facingReward()
|
||||
{
|
||||
float thisReward = 0;
|
||||
Ray ray = thisCam.ScreenPointToRay(new Vector3(thisCam.pixelWidth / 2, thisCam.pixelHeight / 2, 0));
|
||||
if (targetCon.targetTypeInt == (int)TargetController.Targets.Free)
|
||||
{
|
||||
//free mode
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 100))
|
||||
{
|
||||
if (hit.collider.tag != myTag && hit.collider.tag != "Wall")
|
||||
{
|
||||
thisReward = paramContainer.facingReward;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(targetCon.targetTypeInt == (int)TargetController.Targets.Attack)
|
||||
{
|
||||
float targetDis = Vector3.Distance(blockContainer.thisBlock.transform.position, transform.position);
|
||||
if(targetDis <= rayScript.viewDistance)
|
||||
{
|
||||
// Debug.DrawRay(new Vector3(0,0,0), viewPoint, Color.red);
|
||||
if (Vector3.Distance(ray.origin + (ray.direction * targetDis), blockContainer.thisBlock.transform.position) <= blockContainer.thisBlock.firebasesAreaDiameter / 2)
|
||||
{
|
||||
// im watching target
|
||||
// Debug.DrawRay(ray.origin, viewPoint-ray.origin, Color.blue);
|
||||
thisReward = paramContainer.facingReward;
|
||||
}
|
||||
}
|
||||
}
|
||||
return thisReward;
|
||||
}
|
||||
|
||||
// getEnemyNum 获取现场除了自己以外的敌人数量
|
||||
int getEnemyNum()
|
||||
{
|
||||
@@ -322,6 +375,9 @@ public class AgentWithGun : Agent
|
||||
}
|
||||
// 射击动作reward判断
|
||||
epreward += ballistic() + sceneReward;
|
||||
// facing reward
|
||||
epreward += facingReward();
|
||||
// spin penalty
|
||||
spinRecord.Add(mouseX);
|
||||
if (spinRecord.Count >= paramContainer.spinRecordMax)
|
||||
{
|
||||
@@ -372,8 +428,8 @@ public class AgentWithGun : Agent
|
||||
|
||||
//sensor.AddObservation(allEnemyNum); // 敌人数量 int
|
||||
sensor.AddObservation(targetStates);// targettype, target x,y,z, firebasesAreaDiameter
|
||||
sensor.AddObservation(remainTime);
|
||||
sensor.AddObservation(targetCon.getInAreaState());
|
||||
sensor.AddObservation(remainTime);
|
||||
sensor.AddObservation(myObserve); // 自机位置xyz+朝向 float[](4,1)
|
||||
sensor.AddObservation(rayTagResult); // 探测用RayTag结果 float[](raySensorNum,1)
|
||||
sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
|
||||
@@ -70,6 +70,11 @@ public class ParameterContainer : MonoBehaviour
|
||||
public float shootWithoutReadyReward = -0.15f;
|
||||
[Tooltip("Kill bonus reward stack to nothing happend reward")]
|
||||
public float killBonusReward = 0.0f;
|
||||
[Tooltip("Facing to enemy's reward")]
|
||||
public float facingReward = 2.0f;
|
||||
[Tooltip("Shoot at target area but didn't hit enemy")]
|
||||
public float shootTargetAreaReward = 5.0f;
|
||||
|
||||
[Header("Penalty Rewards")]
|
||||
[Tooltip("Speed Penalty Reward")]
|
||||
public float speedPenalty = 0f;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TargetController : MonoBehaviour
|
||||
private float freeProb;
|
||||
private float sceneSize;
|
||||
private float lastDistance;
|
||||
private Vector3 targetPosition;
|
||||
public Vector3 targetPosition;
|
||||
private Vector3 targetLocalPosition;
|
||||
private bool firstRewardFlag = true;
|
||||
private bool targetEnemySpawnFinish = false;
|
||||
@@ -248,7 +248,8 @@ public class TargetController : MonoBehaviour
|
||||
(nowDistance, inArea) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position);
|
||||
envUICon.updateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
|
||||
float areaTargetReward = getDistanceReward(nowDistance, inArea);
|
||||
if (blockCont.thisBlock.firebasesBelong >= blockCont.thisBlock.belongMaxPoint)
|
||||
// if (blockCont.thisBlock.firebasesBelong >= blockCont.thisBlock.belongMaxPoint)
|
||||
if(inArea != 0)
|
||||
{
|
||||
// win
|
||||
// let the area belongs to me
|
||||
|
||||
Reference in New Issue
Block a user