Fixed many things.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Animators.Leonid_Animator;
|
||||
using Animators.Leonid_Animator.Bot;
|
||||
using Unity.MLAgents;
|
||||
@ -74,7 +75,6 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
private void Update()
|
||||
{
|
||||
print(IsFiring);
|
||||
_botLocomotion.UpdateAnimatorValues();
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
{
|
||||
// Debug.Log("Collect observations called!");
|
||||
Debug.Log("Collect observations called!");
|
||||
_navPointIdDict = MapManager.Instance.IDToNavPoint;
|
||||
if (_navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
@ -105,7 +105,6 @@ public class NPC : Agent, ICharacter
|
||||
sensor.AddObservation(candidates.Count);
|
||||
sensor.AddObservation(_moveController.PointStartID);
|
||||
sensor.AddObservation(_moveController.PointEndID);
|
||||
// Debug.Log("Done common!");
|
||||
//state sensors
|
||||
sensor.AddObservation((int)NpcState.State);
|
||||
sensor.AddObservation((int)NpcBodyState.State);
|
||||
@ -113,7 +112,6 @@ public class NPC : Agent, ICharacter
|
||||
sensor.AddObservation(_navPointIdDict[_moveController.PointStartID].DeathAttr);
|
||||
sensor.AddObservation(_navPointIdDict[_moveController.PointEndID].DeathAttr);
|
||||
sensor.AddObservation(_moveController.FlagDistance);
|
||||
// Debug.Log("Done state sensors!");
|
||||
|
||||
//point sensors
|
||||
foreach (var point in candidates)
|
||||
@ -130,26 +128,25 @@ public class NPC : Agent, ICharacter
|
||||
GameManager.IsHaveSeenByEnemy(GetCharacter.Team.GetOppositeTeam(),
|
||||
point.Position).ToInt()
|
||||
});
|
||||
}
|
||||
// Debug.Log("Done collect observations!");
|
||||
} ;
|
||||
}
|
||||
|
||||
public override void OnActionReceived(ActionBuffers actions)
|
||||
{
|
||||
{
|
||||
var result = actions.DiscreteActions;
|
||||
print(result[0]);
|
||||
if (result[0] == 0)
|
||||
{
|
||||
if (_navPointIdDict[_moveController.PointStartID].navType != NavPointType.Cover)
|
||||
return;
|
||||
NpcState = _coverState;
|
||||
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: Peek(); break;
|
||||
case 1: Cover(); break;
|
||||
case 3: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
|
||||
case 4: NpcState = _directState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
case 2: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
if (result[0] == 1)
|
||||
@ -164,7 +161,9 @@ public class NPC : Agent, ICharacter
|
||||
case 0: _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]);
|
||||
NpcState = _runningState; Debug.Log("Go to point " + result[2]);break;
|
||||
case 1: NpcState = _directState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
case 2: break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +175,9 @@ public class NPC : Agent, ICharacter
|
||||
{
|
||||
case 0: _moveController.StopOnPath(); NpcState = _directState; break;
|
||||
case 1: _moveController.ReturnToStartPoint(); NpcState = _runningState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
case 2: break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user