MVP work with ml-agents python library
This commit is contained in:
27
Assets/Prefabs/Bot.prefab
generated
Executable file → Normal file
27
Assets/Prefabs/Bot.prefab
generated
Executable file → Normal file
@ -50,6 +50,7 @@ GameObject:
|
||||
- component: {fileID: 2756943273076691504}
|
||||
- component: {fileID: 6638271233700792696}
|
||||
- component: {fileID: 5988018701276467001}
|
||||
- component: {fileID: 1547882613481475944}
|
||||
m_Layer: 8
|
||||
m_Name: Bot
|
||||
m_TagString: Defender
|
||||
@ -210,8 +211,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SensorName: BufferSensor
|
||||
m_ObservableSize: 0
|
||||
m_MaxNumObservables: 0
|
||||
m_ObservableSize: 5
|
||||
m_MaxNumObservables: 10
|
||||
--- !u!114 &2756943273076691504
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -225,19 +226,19 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 1
|
||||
VectorObservationSize: 14
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 0
|
||||
BranchSizes: 01000000
|
||||
VectorActionSize: 01000000
|
||||
BranchSizes: 010000000100000001000000
|
||||
VectorActionSize: 010000000100000001000000
|
||||
VectorActionDescriptions: []
|
||||
VectorActionSpaceType: 0
|
||||
hasUpgradedBrainParametersWithActionSpec: 1
|
||||
m_Model: {fileID: 0}
|
||||
m_InferenceDevice: 0
|
||||
m_BehaviorType: 0
|
||||
m_BehaviorName: My Behavior
|
||||
m_BehaviorName: npc
|
||||
TeamId: 0
|
||||
m_UseChildSensors: 1
|
||||
m_UseChildActuators: 1
|
||||
@ -272,3 +273,17 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
navMeshAgent: {fileID: 8774702625908438859}
|
||||
flag: {fileID: 6818223691859422291, guid: 1685c1d9ce4ab174f95c646b1826010b, type: 3}
|
||||
--- !u!114 &1547882613481475944
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6171680323948707524}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3a5c9d521e5ef4759a8246a07d52221e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DecisionPeriod: 5
|
||||
TakeActionsBetweenDecisions: 0
|
||||
|
2
Assets/Prefabs/Player.prefab.meta
generated
Executable file → Normal file
2
Assets/Prefabs/Player.prefab.meta
generated
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80f6c1c85e5daed4c96c70205ed5503d
|
||||
guid: a7480b77908b042d8adcdd84e8c2c15e
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
@ -73,6 +73,7 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
{
|
||||
// Debug.Log("Collect observations called!");
|
||||
navPointIdDict = MapManager.Instance.IDToNavPoint;
|
||||
if (navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
@ -88,6 +89,7 @@ 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);
|
||||
@ -95,6 +97,7 @@ 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)
|
||||
@ -112,11 +115,14 @@ public class NPC : Agent, ICharacter
|
||||
point.Position).ToInt()
|
||||
});
|
||||
}
|
||||
// Debug.Log("Done collect observations!");
|
||||
}
|
||||
|
||||
public override void OnActionReceived(ActionBuffers actions)
|
||||
{
|
||||
// Debug.Log("Actions recieved!");
|
||||
var result = actions.DiscreteActions;
|
||||
// Debug.Log(result[0] + " " + result[1]);
|
||||
if (result[0] == 0)
|
||||
{
|
||||
if (navPointIdDict[moveController.PointStartID].navType != NavPointType.Cover)
|
||||
@ -132,18 +138,26 @@ public class NPC : Agent, ICharacter
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
}
|
||||
}
|
||||
// Debug.Log(result[0] == 1);
|
||||
if (result[0] == 1)
|
||||
{
|
||||
// Debug.Log("BEFORE SOme shitty if >:(");
|
||||
if (navPointIdDict[moveController.PointStartID].navType != NavPointType.Direction)
|
||||
{
|
||||
// Debug.Log("SOme shitty if >:(");
|
||||
return;
|
||||
}
|
||||
// Debug.Log("FUCK");
|
||||
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: moveController.GoToNextNavPoint(navPointIdDict[result[2]]);
|
||||
NpcState = RunningState; break;
|
||||
NpcState = RunningState; Debug.Log("Go to point " + result[2]);break;
|
||||
case 1: NpcState = DirectState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
}
|
||||
}
|
||||
|
||||
if (result[0] == 2)
|
||||
{
|
||||
if (moveController.PointStartID == moveController.PointEndID && moveController.PointEndID != -1)
|
||||
@ -155,6 +169,7 @@ public class NPC : Agent, ICharacter
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
}
|
||||
}
|
||||
// Debug.Log("Actions processed!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
0
Assets/Settings/Game Settings.asset
generated
Executable file → Normal file
0
Assets/Settings/Game Settings.asset
generated
Executable file → Normal file
Reference in New Issue
Block a user