private Dictionary<Fact, IProposition> _propositions; // An archive of Propositions, indexed by name #endregion Fields #region Constructors public PropNetConverter(IComponentFactory componentFactory) { _componentFactory = componentFactory; _doesProcessor = new RelationNameProcessor("does", GameContainer.SymbolTable); _trueProcessor = new RelationNameProcessor("true", GameContainer.SymbolTable); _anonFact = new GroundFact(GameContainer.SymbolTable, "anon"); }
static OptimizingPropNetFactory() { DoesProcessor = new RelationNameProcessor("does", GameContainer.SymbolTable); TrueProcessor = new RelationNameProcessor("true", GameContainer.SymbolTable); TempFact = new GroundFact(GameContainer.SymbolTable, "temp"); }
private Dictionary<IProposition, IProposition> MakeLegalInputMap() { var doesProcessor = new RelationNameProcessor(GameContainer.Parser.TokDoes); var inputMap = new Dictionary<IProposition, IProposition>(); var inputPropsByBody = new Dictionary<Fact, IProposition>(); // Create a mapping from Body->Input. foreach (IProposition inputProp in InputPropositions.Values) inputPropsByBody[inputProp.Name] = inputProp; // Use that mapping to map Input->Legal and Legal->Input // based on having the same Body proposition. foreach (HashSet<IProposition> legalProps in LegalPropositions.Values) { foreach (IProposition legalProp in legalProps) { Fact legalPropBody = doesProcessor.ProcessBaseFact(legalProp.Name); IProposition inputProp; if (inputPropsByBody.TryGetValue(legalPropBody, out inputProp)) { inputMap[inputProp] = legalProp; inputMap[legalProp] = inputProp; } } } return inputMap; }