V2.1 Add spin penalty and reward adjust

Build-ParallelEnv-Target-OffPolicy-SingleStack-SideChannel-EndReward-Easy-V2.1
add spin penalty while agent keep spin will give a penalty reward.
lower Go target in area reward.
This commit is contained in:
Koha9 2022-12-04 08:40:23 +09:00
parent 0d60c857b7
commit fa90ac3bb6
6 changed files with 185 additions and 134 deletions

View File

@ -1 +1 @@
{"count":1,"self":29.5144064,"total":31.109803999999997,"children":{"InitializeActuators":{"count":16,"self":0.0020061,"total":0.0020061,"children":null},"InitializeSensors":{"count":16,"self":0.0015064,"total":0.0015064,"children":null},"AgentSendState":{"count":1300,"self":0.032629399999999996,"total":1.3793506,"children":{"CollectObservations":{"count":10400,"self":1.3266885,"total":1.3266885,"children":null},"WriteActionMask":{"count":10400,"self":0.0055122,"total":0.0055122,"children":null},"RequestDecision":{"count":10400,"self":0.014520499999999999,"total":0.014520499999999999,"children":null}}},"DecideAction":{"count":1300,"self":0.0246036,"total":0.0246036,"children":null},"AgentAct":{"count":1300,"self":0.18743069999999998,"total":0.18743069999999998,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1670056714","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 f236fc50-7039-11ed-847b-693e2468b0ed -accessToken 9ZtagkYCGQGJbz1h79OWqFnBSy12hJOOJ_slXKTD6NI00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"InGame","end_time_seconds":"1670056744"}} {"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"}}

View File

@ -2744,7 +2744,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -8228,13 +8228,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -8247,8 +8249,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -9550,13 +9552,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -9569,8 +9573,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -17322,7 +17326,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -19592,13 +19596,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -19611,8 +19617,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -25421,7 +25427,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -30251,7 +30257,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -30866,13 +30872,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -30885,8 +30893,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -33261,7 +33269,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -34532,7 +34540,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -35432,7 +35440,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -38454,13 +38462,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -38473,8 +38483,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -42051,7 +42061,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_BrainParameters: m_BrainParameters:
VectorObservationSize: 38 VectorObservationSize: 39
NumStackedVectorObservations: 1 NumStackedVectorObservations: 1
m_ActionSpec: m_ActionSpec:
m_NumContinuousActions: 1 m_NumContinuousActions: 1
@ -42937,13 +42947,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -42956,8 +42968,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -51336,13 +51348,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -51355,8 +51369,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5
@ -53598,13 +53612,15 @@ MonoBehaviour:
timeLimit: 30 timeLimit: 30
lockCameraX: 0 lockCameraX: 0
lockCameraY: 1 lockCameraY: 1
chartOn: 0 chartOn: 1
spinRecordMax: 40
spinPenaltyThreshold: 10
hitTargetRewardDefault: 100 hitTargetRewardDefault: 100
killTargetEnemyRewardDefault: 100 killTargetEnemyRewardDefault: 100
inAreaRewardDefault: 10 inAreaRewardDefault: 2
freeTimeBonusPerSec: 1 freeTimeBonusPerSec: 1
targetTimeBonusPerSec: 2 targetTimeBonusPerSec: 1
areaTimeBonusPerSec: 1 areaTimeBonusPerSec: 0.2
distanceReward: 20 distanceReward: 20
goWinRewardDefault: 999 goWinRewardDefault: 999
attackWinRewardDefault: 999 attackWinRewardDefault: 999
@ -53617,8 +53633,8 @@ MonoBehaviour:
killReward: 5 killReward: 5
shootWithoutReadyReward: -0.15 shootWithoutReadyReward: -0.15
killBonusReward: 0 killBonusReward: 0
speedPanalty: 0 speedPenalty: 0
viewPanalty: 0 spinPenalty: 0.04
hitTargetReward: 60 hitTargetReward: 60
killTargetEnemyReward: 80 killTargetEnemyReward: 80
inAreaReward: 5 inAreaReward: 5

View File

@ -38,6 +38,7 @@ public class AgentWithGun : Agent
public float yRotation = 0.1f;//定义一个浮点类型的量记录围绕X轴旋转的角度 public float yRotation = 0.1f;//定义一个浮点类型的量记录围绕X轴旋转的角度
[Header("Env")] [Header("Env")]
private List<float> spinRecord = new List<float>();
private bool lockMouse; private bool lockMouse;
private float Damage; private float Damage;
private float fireRate; private float fireRate;
@ -302,7 +303,7 @@ int enemyNumDiff()
// ------------Reward-------------- // ------------Reward--------------
// rewardCalculate 计算本动作的Reward // rewardCalculate 计算本动作的Reward
public float rewardCalculate(float sceneReward) public float rewardCalculate(float sceneReward,float mouseX)
{ {
float epreward = 0f; float epreward = 0f;
// 击杀reward判断 // 击杀reward判断
@ -321,6 +322,16 @@ public float rewardCalculate(float sceneReward)
} }
// 射击动作reward判断 // 射击动作reward判断
epreward += ballistic() + sceneReward; epreward += ballistic() + sceneReward;
spinRecord.Add(mouseX);
if (spinRecord.Count >= paramContainer.spinRecordMax)
{
spinRecord.RemoveAt(0);
}
float spinPenaltyReward = Math.Abs(spinRecord.ToArray().Sum() * paramContainer.spinPenalty);
if(spinPenaltyReward >= paramContainer.spinPenaltyThreshold)
{
epreward -= spinPenaltyReward;
}
return epreward; return epreward;
} }
@ -362,6 +373,7 @@ public override void CollectObservations(VectorSensor sensor)
//sensor.AddObservation(allEnemyNum); // 敌人数量 int //sensor.AddObservation(allEnemyNum); // 敌人数量 int
sensor.AddObservation(targetStates);// targettype, target x,y,z, firebasesAreaDiameter sensor.AddObservation(targetStates);// targettype, target x,y,z, firebasesAreaDiameter
sensor.AddObservation(remainTime); sensor.AddObservation(remainTime);
sensor.AddObservation(targetCon.getInAreaState());
sensor.AddObservation(myObserve); // 自机位置xyz+朝向 float[](4,1) sensor.AddObservation(myObserve); // 自机位置xyz+朝向 float[](4,1)
sensor.AddObservation(rayTagResult); // 探测用RayTag结果 float[](raySensorNum,1) sensor.AddObservation(rayTagResult); // 探测用RayTag结果 float[](raySensorNum,1)
sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1) sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1)
@ -393,7 +405,7 @@ public override void OnActionReceived(ActionBuffers actionBuffers)
float sceneReward = 0f; float sceneReward = 0f;
float endReward = 0f; float endReward = 0f;
(finishedState, sceneReward, endReward) = targetCon.checkOverAndRewards(); (finishedState, sceneReward, endReward) = targetCon.checkOverAndRewards();
float thisRoundReward = rewardCalculate(sceneReward+ endReward); float thisRoundReward = rewardCalculate(sceneReward+ endReward,Mouse_X);
if (paramContainer.chartOn) if (paramContainer.chartOn)
{ {
EnvUICon.updateChart(thisRoundReward); EnvUICon.updateChart(thisRoundReward);

View File

@ -22,6 +22,8 @@ public class ParameterContainer : MonoBehaviour
public bool lockCameraX = false; public bool lockCameraX = false;
public bool lockCameraY = true; public bool lockCameraY = true;
public bool chartOn = false; public bool chartOn = false;
public int spinRecordMax = 20;
public float spinPenaltyThreshold = 50;
[Header("Dynamic Defaut Rewards")] [Header("Dynamic Defaut Rewards")]
@ -70,9 +72,9 @@ public class ParameterContainer : MonoBehaviour
public float killBonusReward = 0.0f; public float killBonusReward = 0.0f;
[Header("Penalty Rewards")] [Header("Penalty Rewards")]
[Tooltip("Speed Penalty Reward")] [Tooltip("Speed Penalty Reward")]
public float speedPanalty = 0f; public float speedPenalty = 0f;
[Tooltip("view Panalty Reward")] [Tooltip("view Panalty Reward")]
public float viewPanalty = 0f; public float spinPenalty = 0f;
[Header("Dynamic Rewards")] [Header("Dynamic Rewards")]
[Tooltip("Free mode Hit Enemy reward")] [Tooltip("Free mode Hit Enemy reward")]

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Serialization;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
@ -46,6 +47,7 @@ public enum EndType { Win, Lose, Running, Num };
[System.NonSerialized] public int targetNum = 0; [System.NonSerialized] public int targetNum = 0;
private Dictionary<int, float[]> oneHotRarget = new Dictionary<int, float[]>(); private Dictionary<int, float[]> oneHotRarget = new Dictionary<int, float[]>();
private int inArea = 0;
private float freeProb; private float freeProb;
private float sceneSize; private float sceneSize;
private float lastDistance; private float lastDistance;
@ -238,7 +240,6 @@ public void moveAgentTo(Vector3 thisPosition)
int endTypeInt = 0; int endTypeInt = 0;
float thisReward = 0; float thisReward = 0;
float endReward = 0; float endReward = 0;
int inArea = 0;
float nowDistance = 0f; float nowDistance = 0f;
switch (targetTypeInt) switch (targetTypeInt)
{ {
@ -246,7 +247,7 @@ public void moveAgentTo(Vector3 thisPosition)
// goto // goto
(nowDistance, inArea) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position); (nowDistance, inArea) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position);
envUICon.updateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint); envUICon.updateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
float areaTargetReward = (paramCon.inAreaReward * inArea) + getDistanceReward(nowDistance); float areaTargetReward = getDistanceReward(nowDistance, inArea);
if (blockCont.thisBlock.firebasesBelong >= blockCont.thisBlock.belongMaxPoint) if (blockCont.thisBlock.firebasesBelong >= blockCont.thisBlock.belongMaxPoint)
{ {
// win // win
@ -363,7 +364,7 @@ public void moveAgentTo(Vector3 thisPosition)
} }
// caulculate sceneReward if close to target then get great reward // caulculate sceneReward if close to target then get great reward
public float getDistanceReward(float nowDistance) public float getDistanceReward(float nowDistance,int inarea)
{ {
if (firstRewardFlag) if (firstRewardFlag)
{ {
@ -371,7 +372,14 @@ public float getDistanceReward(float nowDistance)
firstRewardFlag = false; firstRewardFlag = false;
} }
float thisSceneReward = 0f; float thisSceneReward = 0f;
thisSceneReward = paramCon.distanceReward * (lastDistance - nowDistance); if (inarea != 0)
{
thisSceneReward = paramCon.inAreaReward;
}
else
{
thisSceneReward = paramCon.distanceReward * (lastDistance - nowDistance);
}
lastDistance = nowDistance; lastDistance = nowDistance;
return thisSceneReward; return thisSceneReward;
} }
@ -438,4 +446,17 @@ public float hitEnemyReward(Vector3 enemyPosition)
} }
return thisHitReward; return thisHitReward;
} }
// get in area state
public int getInAreaState()
{
if(targetTypeInt == (int)Targets.Go)
{
return inArea;
}
else
{
return 0;
}
}
} }

View File

@ -14,12 +14,12 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_PixelRect: m_PixelRect:
serializedVersion: 2 serializedVersion: 2
x: 71 x: 70
y: 52 y: 37
width: 1840 width: 1840
height: 1019 height: 1019
m_ShowMode: 4 m_ShowMode: 4
m_Title: Hierarchy m_Title: Inspector
m_RootView: {fileID: 12} m_RootView: {fileID: 12}
m_MinSize: {x: 875, y: 542} m_MinSize: {x: 875, y: 542}
m_MaxSize: {x: 10000, y: 10000} m_MaxSize: {x: 10000, y: 10000}
@ -38,9 +38,9 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_PixelRect: m_PixelRect:
serializedVersion: 2 serializedVersion: 2
x: -1018 x: -1113
y: -689 y: -679
width: 1018 width: 1117
height: 630 height: 630
m_ShowMode: 0 m_ShowMode: 0
m_Title: Game m_Title: Game
@ -65,10 +65,10 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 1018 width: 1117
height: 630 height: 630
m_MinSize: {x: 100, y: 121} m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 16} m_ActualView: {fileID: 16}
m_Panes: m_Panes:
- {fileID: 16} - {fileID: 16}
@ -92,12 +92,12 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 1018 width: 1117
height: 630 height: 630
m_MinSize: {x: 100, y: 121} m_MinSize: {x: 100, y: 121}
m_MaxSize: {x: 4000, y: 4021} m_MaxSize: {x: 4000, y: 4021}
vertical: 0 vertical: 0
controlID: 162 controlID: 146
--- !u!114 &5 --- !u!114 &5
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -115,7 +115,7 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 585 y: 585
width: 1079 width: 1094
height: 384 height: 384
m_MinSize: {x: 231, y: 271} m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021} m_MaxSize: {x: 10001, y: 10021}
@ -144,12 +144,12 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 1079 width: 1094
height: 969 height: 969
m_MinSize: {x: 100, y: 200} m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192} m_MaxSize: {x: 8096, y: 16192}
vertical: 1 vertical: 1
controlID: 155 controlID: 17
--- !u!114 &7 --- !u!114 &7
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -167,10 +167,10 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 375 y: 375
width: 243 width: 229
height: 594 height: 594
m_MinSize: {x: 102, y: 121} m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 22} m_ActualView: {fileID: 22}
m_Panes: m_Panes:
- {fileID: 22} - {fileID: 22}
@ -193,14 +193,14 @@ MonoBehaviour:
- {fileID: 7} - {fileID: 7}
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 1079 x: 1094
y: 0 y: 0
width: 243 width: 229
height: 969 height: 969
m_MinSize: {x: 100, y: 200} m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192} m_MaxSize: {x: 8096, y: 16192}
vertical: 1 vertical: 1
controlID: 17 controlID: 114
--- !u!114 &9 --- !u!114 &9
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -218,7 +218,7 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 243 width: 229
height: 375 height: 375
m_MinSize: {x: 202, y: 221} m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4002, y: 4021}
@ -252,7 +252,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200} m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192} m_MaxSize: {x: 24288, y: 16192}
vertical: 0 vertical: 0
controlID: 67 controlID: 26
--- !u!114 &11 --- !u!114 &11
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -268,12 +268,12 @@ MonoBehaviour:
m_Children: [] m_Children: []
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 1322 x: 1323
y: 0 y: 0
width: 518 width: 517
height: 969 height: 969
m_MinSize: {x: 276, y: 71} m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 19} m_ActualView: {fileID: 19}
m_Panes: m_Panes:
- {fileID: 19} - {fileID: 19}
@ -367,7 +367,7 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 1079 width: 1094
height: 585 height: 585
m_MinSize: {x: 201, y: 221} m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4001, y: 4021}
@ -396,9 +396,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: -1018 x: -1113
y: -689 y: -679
width: 1018 width: 1117
height: 609 height: 609
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
@ -410,7 +410,7 @@ MonoBehaviour:
m_ShowGizmos: 0 m_ShowGizmos: 0
m_TargetDisplay: 0 m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0} m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
m_TargetSize: {x: 1018, y: 588} m_TargetSize: {x: 1117, y: 588}
m_TextureFilterMode: 0 m_TextureFilterMode: 0
m_TextureHideFlags: 61 m_TextureHideFlags: 61
m_RenderIMGUI: 1 m_RenderIMGUI: 1
@ -425,8 +425,8 @@ MonoBehaviour:
m_VRangeLocked: 0 m_VRangeLocked: 0
hZoomLockedByDefault: 0 hZoomLockedByDefault: 0
vZoomLockedByDefault: 0 vZoomLockedByDefault: 0
m_HBaseRangeMin: -509 m_HBaseRangeMin: -558.5
m_HBaseRangeMax: 509 m_HBaseRangeMax: 558.5
m_VBaseRangeMin: -294 m_VBaseRangeMin: -294
m_VBaseRangeMax: 294 m_VBaseRangeMax: 294
m_HAllowExceedBaseRangeMin: 1 m_HAllowExceedBaseRangeMin: 1
@ -446,23 +446,23 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 21 y: 21
width: 1018 width: 1117
height: 588 height: 588
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Translation: {x: 509, y: 294} m_Translation: {x: 558.5, y: 294}
m_MarginLeft: 0 m_MarginLeft: 0
m_MarginRight: 0 m_MarginRight: 0
m_MarginTop: 0 m_MarginTop: 0
m_MarginBottom: 0 m_MarginBottom: 0
m_LastShownAreaInsideMargins: m_LastShownAreaInsideMargins:
serializedVersion: 2 serializedVersion: 2
x: -509 x: -558.5
y: -294 y: -294
width: 1018 width: 1117
height: 588 height: 588
m_MinimalGUI: 1 m_MinimalGUI: 1
m_defaultScale: 1 m_defaultScale: 1
m_LastWindowPixelSize: {x: 1018, y: 609} m_LastWindowPixelSize: {x: 1117, y: 609}
m_ClearInEditMode: 1 m_ClearInEditMode: 1
m_NoCameraWarning: 1 m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000 m_LowResolutionForAspectRatios: 01000000000000000000
@ -516,9 +516,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 71 x: 70
y: 667 y: 652
width: 1078 width: 1093
height: 363 height: 363
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
@ -537,22 +537,22 @@ MonoBehaviour:
m_SkipHidden: 0 m_SkipHidden: 0
m_SearchArea: 1 m_SearchArea: 1
m_Folders: m_Folders:
- Assets/Prefeb/GoBlock - Assets
m_Globs: [] m_Globs: []
m_OriginalText: m_OriginalText:
m_ViewMode: 1 m_ViewMode: 1
m_StartGridSize: 16 m_StartGridSize: 16
m_LastFolders: m_LastFolders:
- Assets/Prefeb/GoBlock - Assets
m_LastFoldersGridSize: 16 m_LastFoldersGridSize: 16
m_LastProjectPath: C:\Users\UCUNI\OneDrive\Unity\ML-Agents\Aimbot-ParallelEnv m_LastProjectPath: C:\Users\UCUNI\OneDrive\Unity\ML-Agents\Aimbot-ParallelEnv
m_LockTracker: m_LockTracker:
m_IsLocked: 0 m_IsLocked: 0
m_FolderTreeState: m_FolderTreeState:
scrollPos: {x: 0, y: 34} scrollPos: {x: 0, y: 22}
m_SelectedIDs: 5a780000 m_SelectedIDs: 34780000
m_LastClickedID: 30810 m_LastClickedID: 30772
m_ExpandedIDs: 0000000030780000327800003478000036780000387800004e78000000ca9a3b m_ExpandedIDs: 000000003478000036780000387800003a7800003c78000000ca9a3b
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -580,7 +580,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 000000003078000032780000347800003678000038780000 m_ExpandedIDs: 000000003478000036780000387800003a7800003c780000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -657,8 +657,8 @@ MonoBehaviour:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 1393 x: 1393
y: 82 y: 67
width: 517 width: 516
height: 948 height: 948
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
@ -671,7 +671,7 @@ MonoBehaviour:
m_ControlHash: -371814159 m_ControlHash: -371814159
m_PrefName: Preview_InspectorPreview m_PrefName: Preview_InspectorPreview
m_LastInspectedObjectInstanceID: -1 m_LastInspectedObjectInstanceID: -1
m_LastVerticalScrollValue: 0 m_LastVerticalScrollValue: 257
m_GlobalObjectId: m_GlobalObjectId:
m_InspectorMode: 0 m_InspectorMode: 0
m_LockTracker: m_LockTracker:
@ -697,9 +697,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 1150 x: 1164
y: 82 y: 67
width: 241 width: 227
height: 354 height: 354
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
@ -708,9 +708,9 @@ MonoBehaviour:
m_SceneHierarchy: m_SceneHierarchy:
m_TreeViewState: m_TreeViewState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs: a8c40400aacb040018c10400aac00400bcd00400e6cf0400cec804005ecd0400
m_LastClickedID: 0 m_LastClickedID: 314718
m_ExpandedIDs: 32fbffff m_ExpandedIDs: 26bcf7ff84bcf7ff06bef7ff7cfaf7ffd8faf7ff5afcf7ff2cfbffff02680000fa6a00000e6b0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -754,9 +754,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 71 x: 70
y: 82 y: 67
width: 1078 width: 1093
height: 564 height: 564
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
@ -992,9 +992,9 @@ MonoBehaviour:
m_PlayAudio: 0 m_PlayAudio: 0
m_AudioPlay: 0 m_AudioPlay: 0
m_Position: m_Position:
m_Target: {x: 441.65314, y: -1602.1647, z: 1699.1226} m_Target: {x: -239.0546, y: -114.70053, z: -22.453913}
speed: 2 speed: 2
m_Value: {x: 441.65314, y: -1602.1647, z: 1699.1226} m_Value: {x: -239.0546, y: -114.70053, z: -22.453913}
m_RenderMode: 0 m_RenderMode: 0
m_CameraMode: m_CameraMode:
drawMode: 0 drawMode: 0
@ -1041,13 +1041,13 @@ MonoBehaviour:
m_GridAxis: 1 m_GridAxis: 1
m_gridOpacity: 0.5 m_gridOpacity: 0.5
m_Rotation: m_Rotation:
m_Target: {x: 0.34166846, y: 0.111866064, z: -0.04100156, w: 0.9322117} m_Target: {x: 0.40307263, y: 0.2750459, z: -0.1284353, w: 0.86333007}
speed: 2 speed: 2
m_Value: {x: -0.34166846, y: -0.11186606, z: 0.041001555, w: -0.93221164} m_Value: {x: 0.40308225, y: 0.2750525, z: -0.12843837, w: 0.8633507}
m_Size: m_Size:
m_Target: 1258.1323 m_Target: 122.92201
speed: 2 speed: 2
m_Value: 1258.1323 m_Value: 122.92201
m_Ortho: m_Ortho:
m_Target: 0 m_Target: 0
speed: 2 speed: 2
@ -1092,9 +1092,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 1150 x: 1164
y: 457 y: 442
width: 241 width: 227
height: 573 height: 573
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas: