using MLAgents.Sensor; using System.Collections.Generic; using System; namespace MLAgents { /// /// The Heuristic Policy uses a hards coded Heuristic method /// to take decisions each time the RequestDecision method is /// called. /// public class HeuristicPolicy : IPolicy { Func m_Heuristic; Action m_ActionFunc; /// public HeuristicPolicy(Func heuristic) { m_Heuristic = heuristic; } /// public void RequestDecision(AgentInfo info, List sensors, Action action) { m_ActionFunc = action; } /// public void DecideAction() { if (m_ActionFunc != null) { m_ActionFunc.Invoke(new AgentAction { vectorActions = m_Heuristic.Invoke() }); m_ActionFunc = null; } } public void Dispose() { } } }