using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SpriteCompiler.AI { public static class IntrumentedParameters { public const string NODES_EXPANDED = "nodesExpanded"; } public class InstrumentedNodeExpander : NodeExpanderDelegator where T : ISearchNode where C : ICost { private readonly IDictionary metrics = new Dictionary(); private readonly INodeExpander expander; public InstrumentedNodeExpander(INodeExpander expander) : base(expander) { ClearMetrics(); } public override IEnumerable Expand(ISearchProblem problem, T node) { metrics[IntrumentedParameters.NODES_EXPANDED] += 1; return base.Expand(problem, node); } public int this[string key] { get { return metrics[key]; } } public void ClearMetrics() { metrics[IntrumentedParameters.NODES_EXPANDED] = 0; } } }