| using AIMA.Agent.Action;
|
| using AIMA.Agent.Percept;
|
| using System;
|
| using System.Collections.Generic;
|
|
|
| namespace AIMA.Agent.Environment
|
| {
|
| public abstract class EnvironmentBase<T1, T2> : IEnvironmentViewNotifier, IEnvironment<T1, T2>
|
| where T1 : IAction
|
| where T2 : IPercept
|
| {
|
|
|
|
|
|
|
|
|
|
|
|
|
| protected Dictionary<IAgent<T1, T2>, double> _performanceMeasures { get; init; } = new();
|
| public IReadOnlyDictionary<IAgent<T1, T2>, double> ReadOnlyPerformanceMeasures => _performanceMeasures;
|
| public abstract IEnvironmentState GetCurrentState();
|
| public abstract IEnvironmentState ExecuteAction(IAgent<T1, T2> agent, T1 action);
|
| public abstract T2 GetPerceptSeenBy(IAgent<T1, T2> agent);
|
| public virtual IList<IAgent<T1, T2>> GetAgents()
|
| {
|
|
|
|
|
| return null;
|
| }
|
|
|
| public virtual void AddAgent(IAgent<T1, T2> agent) => AddEnvironmentObject(agent);
|
|
|
| public virtual void RemoveAgent(IAgent<T1, T2> agent) => RemoveEnvironmentObject(agent);
|
| public virtual IList<IEnvironmentObject> GetEnvironmentObjects()
|
| {
|
|
|
|
|
| return null;
|
| }
|
|
|
| public virtual void AddEnvironmentObject(IEnvironmentObject environmentObject)
|
| {
|
|
|
| if (environmentObject is IAgent<T1, T2>)
|
| {
|
|
|
|
|
|
|
|
|
|
|
| }
|
| }
|
|
|
| public virtual void RemoveEnvironmentObject(IEnvironmentObject environmentObject)
|
| {
|
|
|
|
|
| }
|
|
|
| public virtual void Step()
|
| {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| CreateExogenousChange();
|
| }
|
|
|
| public virtual void Step(int n)
|
| {
|
| for (int i = 0; i < n; i++)
|
| {
|
| Step();
|
| }
|
| }
|
|
|
| public virtual void StepUntilDone()
|
| {
|
| while (!IsDone())
|
| {
|
| Step();
|
| }
|
| }
|
|
|
| public virtual bool IsDone()
|
| {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| return true;
|
| }
|
|
|
| public virtual double GetPerformanceMeasure(IAgent<T1, T2> agent)
|
| {
|
| double? performanceMeasures = _performanceMeasures[agent];
|
| if (!performanceMeasures.HasValue)
|
| {
|
| performanceMeasures = 0.0;
|
| _performanceMeasures[agent] = performanceMeasures.Value;
|
| }
|
| return performanceMeasures.Value;
|
| }
|
|
|
| public virtual void AddEnvironmentView(IEnvironmentView<T1, T2> environmentView)
|
| {
|
|
|
| }
|
|
|
| public virtual void RemoveEnvironmentView(IEnvironmentView<T1, T2> environmentView)
|
| {
|
|
|
| }
|
| public virtual void NotifyViews(string msg)
|
| {
|
| throw new NotImplementedException();
|
| }
|
| void CreateExogenousChange()
|
| {
|
|
|
| }
|
| void UpdatePerformanceMeasure(IAgent<T1, T2> forAgent, double addTo)
|
| {
|
|
|
| }
|
| void UdateEnvironmentViewsAgentAdded(IAgent<T1, T2> agent)
|
| {
|
|
|
| }
|
| protected virtual void UpdateEnvironmentViewsAgentActed(IAgent<T1, T2> agent, T1 action,
|
| IEnvironmentState state)
|
| {
|
|
|
| }
|
| }
|
| }
|
|
|