Download Agent/AgentBase.cs from ewdlop/AIMA-CSharp: direct link, hf CLI and curl.
- Browser
- Download file 829 Bytes
-
https://huggingface.co/ewdlop/AIMA-CSharp/resolve/refs%2Fpr%2F1/Agent/AgentBase.cs
- Command line
-
hf download hf://ewdlop/AIMA-CSharp@refs/pr/1/Agent/AgentBase.cs
-
curl -L -o AgentBase.cs https://huggingface.co/ewdlop/AIMA-CSharp/resolve/refs%2Fpr%2F1/Agent/AgentBase.cs
829 Bytes
| using AIMA.Agent.Action; | |
| using AIMA.Agent.Percept; | |
| using AIMA.Agent.Program; | |
| namespace AIMA.Agent | |
| { | |
| public abstract class AgentBase<T1,T2> : IAgent<T1,T2> where T1: IAction where T2: IPercept | |
| { | |
| protected readonly IAgentProgram<T1,T2> _agentProgram; | |
| protected AgentBase(IAgentProgram<T1, T2> agentProgram) | |
| { | |
| _agentProgram = agentProgram; | |
| } | |
| private bool Alive { get; set; } | |
| public virtual T1 Execute(T2 percept) | |
| { | |
| if(_agentProgram is not null) | |
| { | |
| return _agentProgram.Execute(percept); | |
| } | |
| return (T1)(NoOpAction.NO_OPERATION as IAction); | |
| } | |
| public bool IsAlive() => Alive; | |
| public virtual void SetAlive(bool alive) => Alive = alive; | |
| } | |
| } | |