-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,54 @@ | ||
using CommandTerminal; | ||
using Unity.MLAgents; | ||
using Unity.MLAgents.Actuators; | ||
using Unity.MLAgents.Sensors; | ||
using UnityEngine; | ||
|
||
public class WormSimpleAgent : Agent | ||
namespace DialogosEngine | ||
{ | ||
public override void Initialize() | ||
public class WormSimpleAgent : Agent | ||
{ | ||
// | ||
} | ||
CommandLogger Logger; | ||
bool _IsInitialized = false; | ||
|
||
public override void OnEpisodeBegin() | ||
{ | ||
// | ||
} | ||
public override void Initialize() | ||
{ | ||
Logger = new CommandLogger("WormSimpleAgent_log.txt", 1000); | ||
Logger.Log($"[{StepCount}] Initialize"); | ||
} | ||
|
||
public override void CollectObservations(VectorSensor sensor) | ||
{ | ||
sensor.AddObservation(Random.value); | ||
} | ||
public override void OnEpisodeBegin() | ||
{ | ||
Logger.Log($"[{StepCount}] OnEpisodeBegin"); | ||
_IsInitialized = true; | ||
} | ||
|
||
public void TouchedTarget() | ||
{ | ||
AddReward(1f); | ||
} | ||
public override void CollectObservations(VectorSensor sensor) | ||
{ | ||
var obs = Random.value; | ||
sensor.AddObservation(obs); | ||
Logger.Log($"[{StepCount}] CollectObservations: {obs}"); | ||
} | ||
|
||
public override void OnActionReceived(ActionBuffers actionBuffers) | ||
{ | ||
public override void OnActionReceived(ActionBuffers actionBuffers) | ||
{ | ||
|
||
var i = -1; | ||
var continuousActions = actionBuffers.ContinuousActions; | ||
var output = continuousActions[++i]; | ||
Debug.Log(output); | ||
} | ||
var i = -1; | ||
var continuousActions = actionBuffers.ContinuousActions; | ||
var output = continuousActions[++i]; | ||
Logger.Log($"[{StepCount}] OnActionReceived: {output}"); | ||
} | ||
|
||
void FixedUpdate() | ||
{ | ||
AddReward(Random.value); | ||
void FixedUpdate() | ||
{ | ||
if(!_IsInitialized) | ||
{ | ||
return; | ||
} | ||
|
||
var reward = Random.value; | ||
AddReward(reward); | ||
Logger.Log($"[{StepCount}] FixedUpdate.reward: {reward}"); | ||
} | ||
} | ||
} | ||
} |