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"); }
public SentenceFormAdder(IComponentFactory componentFactory, RelationNameProcessor doesProcessor, RelationNameProcessor trueProcessor, GroundFact tempFact) { _componentFactory = componentFactory; _doesProcessor = doesProcessor; _trueProcessor = trueProcessor; _tempFact = tempFact; }
static OptimizingPropNetFactory() { DoesProcessor = new RelationNameProcessor("does", GameContainer.SymbolTable); TrueProcessor = new RelationNameProcessor("true", GameContainer.SymbolTable); TempFact = new GroundFact(GameContainer.SymbolTable, "temp"); }
private int GetScore(HashSet<Fact> context, GroundFact[] moves, int currentDepth) { // Create a new state, based on state and context // First, add the moves foreach (GroundFact move in moves) context.Add(move); // Figure out what is true in the new state var nexts = Prover.AskAll(QueryNext, context); var newContext = new HashSet<Fact>(); foreach (Fact next in nexts) newContext.Add(TrueProcessor.ProcessFact((GroundFact) next)); // Run the recursive search Pair<Term, int> result = MinimaxSearch(newContext, currentDepth + 1); // Remove the moves foreach (GroundFact move in moves) context.Remove(move); return result.second; }
private Dictionary<ISentenceForm, ISentenceFormDomain> GetCartesianDomainsFromModel() { var results = new Dictionary<ISentenceForm, ISentenceFormDomain>(); foreach (NameAndArity sentenceEntry in _sentencesModel.SentencesModel.Keys) { List<TermModel> bodyModels = _sentencesModel.SentencesModel[sentenceEntry]; // We'll end up taking the Cartesian product of the different types of terms we have available if (sentenceEntry.Arity == 0) { Fact sentence = new GroundFact(sentenceEntry.Name); var form = new SimpleSentenceForm(sentence); results[form] = new CartesianSentenceFormDomain(form, new MultiDictionary<int, TermObject>(false)); } else { IEnumerable<HashSet<Term>> sampleTerms = ToSampleTerms(bodyModels); foreach (IEnumerable<Term> terms in sampleTerms.CartesianProduct()) { Fact sentence = new VariableFact(true, sentenceEntry.Name, terms.ToArray()); var form = new SimpleSentenceForm(sentence); results[form] = GetDomain(form, sentence); } } } return results; }
/** * Change the name of the relation 'fact'. * * @param fact The relation to rename. */ public override GroundFact ProcessFact(GroundFact fact) { return fact.Clone(_relName); }
protected virtual void UpdateCurrentState(GroundFact[] previousMoves) { foreach (GroundFact prevMove in previousMoves) CurrentContext.Add(prevMove); HashSet<Fact> newFacts = Prover.AskAll(QueryNext, CurrentContext); CurrentContext = new HashSet<Fact>(); foreach (Fact newFact in newFacts) CurrentContext.Add(TrueProcessor.ProcessFact((GroundFact)newFact)); }
protected GroundFact[] ParsePreviousMoves(GdlList prevMoves) { if (prevMoves == null) return new GroundFact[0]; if (prevMoves.Size != Roles.Count) Logger.Error(GameId + ": Previous move list is not the same size as number of roles!"); var previousMoves = new GroundFact[prevMoves.Size]; for (int i = 0; i < prevMoves.Size; i++) { if (i >= Roles.Count) break; previousMoves[i] = new GroundFact(Parser.TokDoes, Roles[i], Term.BuildFromGdl(prevMoves[i])); } return previousMoves; }
public void GetNextState(GroundFact[] moves) { //TODO: This is where you must move the propnet into its next state. //Depending on the type of propnet is can be forward or backwards propagation throw new NotImplementedException(); }
internal void GetNextState(GroundFact[] moveFacts) { _stateMachine.GetNextState(moveFacts); }
public virtual GroundFact ProcessFact(GroundFact fact) { return fact; }
public override Expression ApplySubstitution(Substitution sigma) { var columns = new Term[Terms.Length]; bool vars = false; for (int i = 0; i < Terms.Length; i++) { columns[i] = Terms[i].ApplySubstitution(sigma); if (columns[i].HasVariables) vars = true; } if (vars) return new VariableFact(false, RelationName, columns); var newFact = new GroundFact(false, RelationName, columns); //if (factQuery != null && factQuery.Contains(newFact)) //{ // usedFacts.Add(new FactMapping { ground = newFact, variable = this }); //} return newFact; }
private void AddGround(int relation, GroundFact ground) { _groundFacts[relation].Add(ground); }