public static void AssertGenericType(this TicNode node, StatePrimitive desc, StatePrimitive anc, bool isComparable = false) { var generic = node.State as ConstrainsState; Assert.IsNotNull(generic); if (desc == null) { Assert.IsFalse(generic.HasDescendant); } else { Assert.AreEqual(desc, generic.Descedant); } if (anc == null) { Assert.IsFalse(generic.HasAncestor); } else { Assert.AreEqual(anc, generic.Ancestor); } Assert.AreEqual(isComparable, generic.IsComparable, "IsComparable claim missed"); }
public bool Apply(ConstrainsState ancestor, StatePrimitive descendant, TicNode ancestorNode, TicNode descendantNode) { if (ancestor.Fits(descendant)) { ancestorNode.State = descendant; } return(true); }
public bool Apply(ConstrainsState ancestor, StatePrimitive descendant, TicNode ancestorNode, TicNode descendantNode) { if (!ancestor.HasAncestor) { return(true); } return(descendant.CanBeImplicitlyConvertedTo(ancestor.Ancestor)); }
public void GetLastCommonAncestor(PrimitiveTypeName a, PrimitiveTypeName b, PrimitiveTypeName expected) { var result = new StatePrimitive(a).GetLastCommonPrimitiveAncestor(new StatePrimitive(b)).Name; Assert.AreEqual(expected, result); var revresult = new StatePrimitive(b).GetLastCommonPrimitiveAncestor(new StatePrimitive(a)).Name; Assert.AreEqual(expected, revresult); }
public void GetFirstCommonDescedant(PrimitiveTypeName a, PrimitiveTypeName b, PrimitiveTypeName expected) { var result = new StatePrimitive(a).GetFirstCommonDescendantOrNull(new StatePrimitive(b))?.Name; Assert.AreEqual(expected, result); var revresult = new StatePrimitive(b).GetFirstCommonDescendantOrNull(new StatePrimitive(a))?.Name; Assert.AreEqual(expected, revresult); }
public void GetFirstCommonDescendantToAnyReturnsSelf(PrimitiveTypeName type) { var result = new StatePrimitive(type).GetFirstCommonDescendantOrNull(StatePrimitive.Any).Name; Assert.AreEqual(type, result); var reversed = StatePrimitive.Any.GetFirstCommonDescendantOrNull(new StatePrimitive(type)).Name; Assert.AreEqual(type, reversed); }
public void GetFirstCommonDescedant_returnsNull(PrimitiveTypeName a, PrimitiveTypeName b) { var result = new StatePrimitive(a).GetFirstCommonDescendantOrNull(new StatePrimitive(b)); Assert.IsNull(result); var revresult = new StatePrimitive(b).GetFirstCommonDescendantOrNull(new StatePrimitive(a)); Assert.IsNull(revresult); }
public static TicNode AssertAndGetSingleGeneric(this ITicResults result, StatePrimitive desc, StatePrimitive anc, bool isComparable = false) { Assert.AreEqual(1, result.GenericsCount, "Incorrect generics count"); var genericNode = result.GenericNodes.Single(); AssertGenericType(genericNode, desc, anc, isComparable); return(genericNode); }
public static void SetCall(this GraphBuilder builder, StatePrimitive ofTheCall, params int[] argumentsThenResult) { var types = new ITicNodeState[argumentsThenResult.Length]; for (int i = 0; i < types.Length; i++) { types[i] = ofTheCall; } builder.SetCall(types, argumentsThenResult); }
public bool Apply(StatePrimitive ancestor, ConstrainsState descendant, TicNode _, TicNode descendantNode) { descendant.AddAncestor(ancestor); var result = descendant.GetOptimizedOrNull(); if (result == null) { return(false); } descendantNode.State = result; return(true); }
public Player() { avatarID = new StatePrimitive <string>(); networkID = new StatePrimitive <string>(); roleID = new StatePrimitive <string>(); ownedItemIDs = new StatePrimitiveList <string>(); healthLevel = new StatePrimitive <float>(); hungryLevel = new StatePrimitive <float>(); thirstLevel = new StatePrimitive <float>(); temperature = new StatePrimitive <float>(); }
public bool Apply(StatePrimitive ancestor, ConstrainsState descendant, TicNode ancestorNode, TicNode descendantNode) { if (descendant.Fits(ancestor)) { if (descendant.Prefered != null && descendant.Fits(descendant.Prefered)) { descendantNode.State = descendant.Prefered; } else { descendantNode.State = ancestor; } } return(true); }
public void GetLastCommonAncestorToSelfReturnsSelf(PrimitiveTypeName type) { var result = new StatePrimitive(type).GetLastCommonPrimitiveAncestor(new StatePrimitive(type)).Name; Assert.AreEqual(type, result); }
public GenericConstrains(StatePrimitive ancestor = null, StatePrimitive descendant = null, bool isComparable = false) { Ancestor = ancestor; Descendant = descendant; IsComparable = isComparable; }
public void GetLastCommonAncestorToAnyReturnsAny(PrimitiveTypeName type) { var result = new StatePrimitive(type).GetLastCommonPrimitiveAncestor(StatePrimitive.Any); Assert.AreEqual(StatePrimitive.Any, result); }
public bool Apply(ConstrainsState ancestor, StatePrimitive descendant, TicNode ancestorNode, TicNode descendantNode) => ApplyAncestorConstrains(ancestorNode, ancestor, descendant);
public bool Apply(ICompositeState ancestor, StatePrimitive descendant, TicNode _, TicNode __) => false;
public Item() { modelID = new StatePrimitive <string>(); }
public bool Apply(StatePrimitive ancestor, StatePrimitive descendant, TicNode _, TicNode __) => descendant.CanBeImplicitlyConvertedTo(ancestor);
public bool Apply(StatePrimitive ancestor, StatePrimitive descendant, TicNode _, TicNode __) => true;
public bool Apply(StatePrimitive ancestor, ConstrainsState descendant, TicNode _, TicNode __) => !descendant.HasDescendant || descendant.Descedant.CanBeImplicitlyConvertedTo(ancestor);