kirill loh
This commit is contained in:
@ -1 +1 @@
|
|||||||
{"count":1,"self":16.677081599999998,"total":16.6850819,"children":{"InitializeActuators":{"count":1,"self":0.0020011,"total":0.0020011,"children":null},"InitializeSensors":{"count":1,"self":0.0019998,"total":0.0019998,"children":null},"AgentSendState":{"count":1,"self":0.0020001,"total":0.0030001,"children":{"CollectObservations":{"count":1,"self":0.001,"total":0.001,"children":null}}}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1650121997","unity_version":"2019.4.35f1","command_line_arguments":"C:\\Program Files\\unityeditorfolder\\2019.4.35f1\\Editor\\Unity.exe -projectpath F:\\SigmaRiskManagment\\real shooter Git Version -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-BipJTP5Uk-fN-2Lss2TUJ -hubSessionId a1fe6f50-bcbd-11ec-b648-df8ff5c97a4c -accessToken K_G64_ace_5LgpX3riGrgGS92ESag4RH04Ti1lswMX8009f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Greatest_map_ever","end_time_seconds":"1650122013"}}
|
{"count":1,"self":16.593504,"total":17.166309,"children":{"InitializeActuators":{"count":2,"self":0.0019996,"total":0.0019996,"children":null},"InitializeSensors":{"count":2,"self":0.0030004,"total":0.0030004,"children":null},"AgentSendState":{"count":612,"self":0.016998,"total":0.549809,"children":{"CollectObservations":{"count":1224,"self":0.0230042,"total":0.0230042,"children":null},"WriteActionMask":{"count":1224,"self":0.0060088,"total":0.0060088,"children":null},"RequestDecision":{"count":1224,"self":0.503798,"total":0.503798,"children":null}}},"DecideAction":{"count":612,"self":0.0089991,"total":0.0089991,"children":null},"AgentAct":{"count":612,"self":0.006997,"total":0.006997,"children":null}},"gauges":{"My Behavior.CumulativeReward":{"count":14,"max":0,"min":0,"runningAverage":0,"value":0,"weightedAverage":0}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1650253950","unity_version":"2019.4.35f1","command_line_arguments":"C:\\Program Files\\unityeditorfolder\\2019.4.35f1\\Editor\\Unity.exe -projectpath F:\\SigmaRiskManagment\\real shooter Git Version -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-1IWpvtxiu_rvPpHhMWpzt -hubSessionId b1d8b690-be9f-11ec-92bc-6fd1276b6775 -accessToken D1AF5mitRE4Vh3s6p7rpmGuqcqvTsZJKmoGtSNfyNNs009f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Greatest_map_ever","end_time_seconds":"1650253967"}}
|
17
Assets/Prefabs/Bot.prefab
generated
17
Assets/Prefabs/Bot.prefab
generated
@ -17,6 +17,7 @@ GameObject:
|
|||||||
- component: {fileID: 2676446634235362783}
|
- component: {fileID: 2676446634235362783}
|
||||||
- component: {fileID: 8656710265340117963}
|
- component: {fileID: 8656710265340117963}
|
||||||
- component: {fileID: 778652956973742106}
|
- component: {fileID: 778652956973742106}
|
||||||
|
- component: {fileID: 1208561866453126566}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Bot
|
m_Name: Bot
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -115,7 +116,6 @@ MonoBehaviour:
|
|||||||
maxStep: 0
|
maxStep: 0
|
||||||
hasUpgradedFromAgentParameters: 1
|
hasUpgradedFromAgentParameters: 1
|
||||||
MaxStep: 100
|
MaxStep: 100
|
||||||
moveController: {fileID: 778652956973742106}
|
|
||||||
--- !u!114 &7805954453358028498
|
--- !u!114 &7805954453358028498
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -195,3 +195,18 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
navMeshAgent: {fileID: 8656710265340117963}
|
navMeshAgent: {fileID: 8656710265340117963}
|
||||||
|
--- !u!114 &1208561866453126566
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2988578997639256874}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: dd8012d5925524537b27131fef517017, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_SensorName: BufferSensor
|
||||||
|
m_ObservableSize: 5
|
||||||
|
m_MaxNumObservables: 512
|
||||||
|
@ -12,7 +12,8 @@ public class CharacterFactory : MonoBehaviour
|
|||||||
[SerializeField] private GameObject AIPrefab;
|
[SerializeField] private GameObject AIPrefab;
|
||||||
[SerializeField] private GameObject PlayerPrefab;
|
[SerializeField] private GameObject PlayerPrefab;
|
||||||
|
|
||||||
private List<GameObject> Players;
|
private List<GameObject> Bots = new List<GameObject>();
|
||||||
|
private GameObject Player;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@ -44,6 +45,8 @@ public class CharacterFactory : MonoBehaviour
|
|||||||
if (humanDef == 1)
|
if (humanDef == 1)
|
||||||
InstanciateEntity(Team.Defenders, TypeAI.HumanAI,
|
InstanciateEntity(Team.Defenders, TypeAI.HumanAI,
|
||||||
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
||||||
|
|
||||||
|
GameManager.OnResetScene += ResetCharacters;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InstanciateEntity(Team team, TypeAI typeAi, NavPoint spawnPoint)
|
private void InstanciateEntity(Team team, TypeAI typeAi, NavPoint spawnPoint)
|
||||||
@ -52,8 +55,40 @@ public class CharacterFactory : MonoBehaviour
|
|||||||
typeAi == TypeAI.HumanAI ? PlayerPrefab : AIPrefab,
|
typeAi == TypeAI.HumanAI ? PlayerPrefab : AIPrefab,
|
||||||
spawnPoint.position,
|
spawnPoint.position,
|
||||||
Quaternion.identity);
|
Quaternion.identity);
|
||||||
|
gameobject.SetActive(true);
|
||||||
|
|
||||||
var character = gameObject.GetComponent<ICharacter>();
|
if (typeAi == TypeAI.HumanAI)
|
||||||
character.GetCharacter.Team = team;
|
{
|
||||||
|
gameobject.GetComponent<Player>().GetCharacter.Team = team;
|
||||||
|
Player = gameobject;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gameobject.GetComponent<NPC>().GetCharacter.Team = team;
|
||||||
|
gameobject.GetComponent<MovementController>().currentPosition = spawnPoint;
|
||||||
|
Bots.Add(gameobject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetCharacters()
|
||||||
|
{
|
||||||
|
foreach (var bot in Bots)
|
||||||
|
{
|
||||||
|
var npc = bot.GetComponent<NPC>();
|
||||||
|
npc.ResetCharacter();
|
||||||
|
if (npc.GetCharacter.Team == Team.Attackers)
|
||||||
|
bot.transform.position = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)].position;
|
||||||
|
else
|
||||||
|
bot.transform.position = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)].position;
|
||||||
|
}
|
||||||
|
var player = Player.GetComponent<Player>();
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.ResetCharacter();
|
||||||
|
if (player.GetCharacter.Team == Team.Attackers)
|
||||||
|
Player.transform.position = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)].position;
|
||||||
|
else
|
||||||
|
Player.transform.position = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)].position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,13 +7,9 @@ public class Character
|
|||||||
|
|
||||||
public Character()
|
public Character()
|
||||||
{
|
{
|
||||||
|
Debug.Log("init");
|
||||||
Condition = new CharacterCondition();
|
Condition = new CharacterCondition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetCharacter()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ICharacter
|
public interface ICharacter
|
||||||
|
@ -6,7 +6,7 @@ using UnityEngine.AI;
|
|||||||
[RequireComponent(typeof(NavMeshAgent))]
|
[RequireComponent(typeof(NavMeshAgent))]
|
||||||
public class MovementController : MonoBehaviour
|
public class MovementController : MonoBehaviour
|
||||||
{
|
{
|
||||||
public NavPoint currentPosition { get; private set; }
|
public NavPoint currentPosition { get; set; }
|
||||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
@ -23,7 +23,7 @@ public class MovementController : MonoBehaviour
|
|||||||
public List<NavPoint> getPointsCandidate()
|
public List<NavPoint> getPointsCandidate()
|
||||||
{
|
{
|
||||||
return MapManager.navPoints
|
return MapManager.navPoints
|
||||||
.Where(point => (currentPosition.position - point.position).magnitude <= SettingsReader.Instance.GetSettings.movementSpeed)
|
.Where(point => (currentPosition.position - point.position).magnitude < SettingsReader.Instance.GetSettings.movementSpeed)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,21 +32,21 @@ public class NPC : Agent, ICharacter
|
|||||||
|
|
||||||
AgentCharacter = new Character();
|
AgentCharacter = new Character();
|
||||||
Condition = AgentCharacter.Condition;
|
Condition = AgentCharacter.Condition;
|
||||||
}
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
AgentCharacter = new Character();
|
|
||||||
Condition = AgentCharacter.Condition;
|
|
||||||
|
|
||||||
moveController = gameObject.GetComponent<MovementController>();
|
moveController = gameObject.GetComponent<MovementController>();
|
||||||
bufferSensor = gameObject.GetComponent<BufferSensorComponent>();
|
bufferSensor = gameObject.GetComponent<BufferSensorComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
GameManager.OnResetScene += AgentCharacter.ResetCharacter;
|
|
||||||
|
public void ResetCharacter()
|
||||||
|
{
|
||||||
|
Condition = new CharacterCondition();
|
||||||
|
EndEpisode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEpisodeBegin()
|
public override void OnEpisodeBegin()
|
||||||
{
|
{
|
||||||
|
NPC_State = DirectState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CollectObservations(VectorSensor sensor)
|
public override void CollectObservations(VectorSensor sensor)
|
||||||
@ -56,12 +56,9 @@ public class NPC : Agent, ICharacter
|
|||||||
sensor.AddObservation(Condition.Ammunition);
|
sensor.AddObservation(Condition.Ammunition);
|
||||||
sensor.AddObservation((int)NPC_State.State);
|
sensor.AddObservation((int)NPC_State.State);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var candidates = moveController.getPointsCandidate();
|
var candidates = moveController.getPointsCandidate();
|
||||||
foreach (var point in candidates)
|
foreach (var point in candidates)
|
||||||
{
|
{
|
||||||
|
|
||||||
bufferSensor.AppendObservation(new float[] {
|
bufferSensor.AppendObservation(new float[] {
|
||||||
//1 position in navpointId
|
//1 position in navpointId
|
||||||
(float)moveController.currentPosition.PointId,
|
(float)moveController.currentPosition.PointId,
|
||||||
|
2
Assets/Scripts/Character/NPC.cs.meta
generated
2
Assets/Scripts/Character/NPC.cs.meta
generated
@ -4,7 +4,7 @@ MonoImporter:
|
|||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 200
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
|
@ -9,11 +9,15 @@ public class Player : MonoBehaviour, ICharacter
|
|||||||
|
|
||||||
public Character GetCharacter => PlayerCharacter;
|
public Character GetCharacter => PlayerCharacter;
|
||||||
|
|
||||||
private void Start()
|
private void Awake()
|
||||||
{
|
{
|
||||||
PlayerCharacter = new Character();
|
PlayerCharacter = new Character();
|
||||||
Condition = PlayerCharacter.Condition;
|
Condition = PlayerCharacter.Condition;
|
||||||
GameManager.OnResetScene += PlayerCharacter.ResetCharacter;
|
}
|
||||||
|
|
||||||
|
public void ResetCharacter()
|
||||||
|
{
|
||||||
|
Condition = new CharacterCondition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action<object> OnKilledEvent;
|
public event Action<object> OnKilledEvent;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Unity.MLAgents;
|
using Unity.MLAgents;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour
|
public class GameManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -19,6 +20,8 @@ public class GameManager : MonoBehaviour
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
Academy.Instance.OnEnvironmentReset += ResetScene;
|
||||||
|
|
||||||
GlobalEventManager.onCaptureFlag += flagCaptured;
|
GlobalEventManager.onCaptureFlag += flagCaptured;
|
||||||
GlobalEventManager.onTimeLeft += timeOut;
|
GlobalEventManager.onTimeLeft += timeOut;
|
||||||
|
|
||||||
@ -77,4 +80,11 @@ public class GameManager : MonoBehaviour
|
|||||||
GlobalEventManager.onCaptureFlag -= flagCaptured;
|
GlobalEventManager.onCaptureFlag -= flagCaptured;
|
||||||
GlobalEventManager.onTimeLeft -= timeOut;
|
GlobalEventManager.onTimeLeft -= timeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static event Action OnResetScene;
|
||||||
|
private void ResetScene()
|
||||||
|
{
|
||||||
|
Debug.Log("Scene Reset");
|
||||||
|
OnResetScene?.Invoke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class AmmoPickUp : MonoBehaviour, IPickable
|
|||||||
|
|
||||||
public void PickObject(GameObject obj)
|
public void PickObject(GameObject obj)
|
||||||
{
|
{
|
||||||
obj.GetComponent<CharacterCondition>()?.TakeAmmo(SettingsReader.Instance.GetSettings.ammunitionPickupAmount);
|
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.TakeAmmo(SettingsReader.Instance.GetSettings.ammunitionPickupAmount);
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class ArmourPickUp : MonoBehaviour, IPickable
|
|||||||
|
|
||||||
public void PickObject(GameObject obj)
|
public void PickObject(GameObject obj)
|
||||||
{
|
{
|
||||||
obj.GetComponent<CharacterCondition>()?.GiveArmour(SettingsReader.Instance.GetSettings.armourPickupAmount);
|
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.GiveArmour(SettingsReader.Instance.GetSettings.armourPickupAmount);
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class HealthPickUp : MonoBehaviour, IPickable
|
|||||||
|
|
||||||
public void PickObject(GameObject obj)
|
public void PickObject(GameObject obj)
|
||||||
{
|
{
|
||||||
obj.GetComponent<CharacterCondition>()?.GiveHealth(SettingsReader.Instance.GetSettings.healthPickupAmount);
|
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.GiveHealth(SettingsReader.Instance.GetSettings.healthPickupAmount);
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user