// Start is called before the first frame update void Start() { agent = GetComponent <NavMeshAgent>(); seesPlayer = new SeesPlayer(this); isInMeleeRange = new IsInMeleeRange(this); hasSeenPlayer = new HasSeenPlayer(this); }
public virtual void DecisionTypeNotSupported(IExpression expression, IDecision decision) { LogInfo("001", string.Format( "The expression type '{0}' of the decision '{1}' is not supported. The decision will be ignored.", expression.GetType().Name, decision.Name)); }
public DecisionEvaluation(IDecision decision, IConcern concern, IForce force) { Decision = decision; Concern = concern; Force = force; var connector = GetConnector(Force.Element); if (connector == null) { Rating = string.Empty; Rationale = string.Empty; BackgroundColor = Color.White.ToArgb(); Changed = true; //this is new so it has changed PropertyChanged += OnPropertyChanged; return; } Rating = connector.GetTaggedValueByName(RatingTag); Rationale = connector.GetTaggedValueByName(RationaleTag); int temp; int.TryParse(connector.GetTaggedValueByName(ColorTag), out temp); BackgroundColor = temp; PropertyChanged += OnPropertyChanged; }
public void ReloadDecisionDetailView(IDecision decision) { IEAElement refreshedDecision = EAMain.Repository.GetElementByGUID(decision.GUID); CloseDecisionDetailView(decision); OpenDecisionDetailView(Decision.Load(refreshedDecision)); }
public WhereAmI(GameObject agent, Transform target, IDecision trueBranch, IDecision falseBranch) { this.agent = agent; this.target = target; this.trueBranch = trueBranch; this.falseBranch = falseBranch; }
private void Update() { totalBunnies = GameObject.FindGameObjectsWithTag("Bunny"); for (int i = 0; i < totalBunnies.Length; i++) { if (!totalBunnies[i].GetComponent <BunnyAI>().healthyBunny) { infectionMark++; } } if (infectionMark != totalBunnies.Length) { infectionMark = 0; currentDecision = BunnyAi; while (currentDecision != null) { currentDecision = currentDecision.MakeDecision(); } } else { SceneManager.LoadScene("gameover"); } }
public given_CTB_Assessment_when_Nationality_eq_UK_and_UkPart_eq_England() { // get a decisionTree with lambdas... _q = QuestionnaireFactory.GetCtbQuestionnaire(); // get the next question, which is the first question var d1 = _q.GetNext(_q) as NationalityDecision; // poke UK answer on the mutator d1.Mutator(d1, new NationalityDecision { NationalityEnum = NationalityEnum.UK, Amount = 0.0f, Result = 1 }); // get next question given the current state the assessment var d2 = _q.GetFollowOnDecisionBranch(_q.Result); // poke UK answer on the mutator d2.Mutator(d2, new UkPartDecision { UkPartEnum = UkPartEnum.England, Amount = 0.0f, Result = 1 }); // get next question given the current state the assessment nxt = d2.GetFollowOnDecisionBranch(_q.Result); ///////////////////////////////// // REFACTOR : asserting on d2 here but should be asserting on 1 ?.... }
void Start() { target = waypoints[0]; decisionTreeRoot = new WaypointReached(target, gameObject, // Additional Variables. new GetWaypoint(gameObject, waypoints, 0), // True Branch new MoveTowardsPatrolpoint(target, gameObject, speed)); // False Branch }
public WaypointReached(Transform target, GameObject agent, IDecision trueBranch, IDecision falseBranch) { this.target = target; this.agent = agent; this.trueBranch = trueBranch; this.falseBranch = falseBranch; }
/// <summary> /// Constructor for the vertex class, must have at least two nodes. /// </summary> /// <param name="Decision">The decision that determines which branch to go down.</param> /// <param name="FirstNode">The first branch, this will be used for: True if boolean and 0 if numeric.</param> /// <param name="SecondNode">The second branch, this will be used for: False if boolean and 1 if numeric.</param> /// <param name="AdditionalNodes">Any additional branches are put in here and will continue the numeric sequence.</param> public Vertex(IDecision Decision, INode FirstNode, INode SecondNode, params INode[] AdditionalNodes) { decision = Decision; Nodes.Add(FirstNode); Nodes.Add(SecondNode); Nodes.AddRange(AdditionalNodes); }
public StakeholderAction(IDecision decision, string action, IStakeholder stakeholder) { Stakeholder = stakeholder; Decision = decision; Action = action; PropertyChanged += OnPropertyChanged; }
public void SingleSolution() { CurrentState state = new CurrentState(); IDecision[] decisions = new IDecision[] { new MoveToFridge(state), new KillFridgeGuardian(state), new OpenFridgeDecision(state), new GetBananaFromFridge(state) }; Planner planner = new Planner(StateOffset.Heuristic); for (int i = 0; i < decisions.Length; i++) { planner.AddDecision(decisions[i]); } StateOffset goal = new StateOffset(); goal.Set("HasBanana", true); Queue<IDecision> plan = planner.CreatePlan(goal); Assert.Greater(plan.Count, 0); Assert.AreSame(decisions[0], plan.Dequeue()); // MoveToFridge Assert.AreSame(decisions[1], plan.Dequeue()); // KillFridgeGuardian Assert.AreSame(decisions[1], plan.Dequeue()); // KillFridgeGUardian Assert.AreSame(decisions[1], plan.Dequeue()); // KillFridgeGuardian Assert.AreSame(decisions[2], plan.Dequeue()); // OpenFridge Assert.AreSame(decisions[3], plan.Dequeue()); // GetBananaFromFridge }
/// <summary> /// Builds the code source. /// Depending on metadata type final class will implement different interfaces and thus will have different class body. /// 1. metadata is a DecisionMetadata - the final source class is going to implement IDecisionModule interface, /// 2. metadata is a LoopScopeMetadata - the final source class is going to implement ILoopDecisionModule interface /// </summary> /// <param name="metadata">The metadata.</param> /// <param name="typeDirectories">The type directories.</param> /// <param name="successorNodeLabelIdLookup">The successor node label id lookup.</param> /// <param name="predeccessorsOutputsNameTypeLookup">The predeccessors outputs name type lookup.</param> /// <param name="logger">The logger.</param> /// <param name="assembliesReferenceLocations">Output the list of assemblies locations that must be reference by DecisionCompilator</param> /// <returns></returns> public static string BuildCodeSource(IDecision metadata, List<string> typeDirectories, Dictionary<string, string> successorNodeLabelIdLookup, Dictionary<string, string> predeccessorsOutputsNameTypeLookup, ComponentLogger logger, out HashSet<string> assembliesReferenceLocations) { string bodyCode, moduleInterface; if (metadata is DecisionMetadata) { //parse the code written by user DecisionCodeParser codeParser = new DecisionCodeParser(metadata.DecisionCode, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup); string userDecisionCodeSnippet = codeParser.ParseCode(); bodyCode = String.Format(DECISION_MODULE_BODY, userDecisionCodeSnippet); moduleInterface = typeof(IDecisionModule).FullName; } else { //append ';' to the end just in case so that user condition can be simplified string decisionCode = (metadata.DecisionCode.EndsWith(";")) ? metadata.DecisionCode : metadata.DecisionCode + ";"; DecisionCodeParser codeParser = new DecisionCodeParser(decisionCode, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup); string userDecisionCodeSnippet = codeParser.ParseCode(); bodyCode = String.Format(LOOP_DECISION_MODULE_BODY, userDecisionCodeSnippet); moduleInterface = typeof(ILoopDecisionModule).FullName; } //build the string of all usings of all namespace found in types assemblies string usingsNamespacesCodeSnippet = ReferenceTypesAssemblies(typeDirectories, logger, out assembliesReferenceLocations); return BuildDecisionCodeSource(metadata.Classname, moduleInterface, bodyCode, usingsNamespacesCodeSnippet); }
/// <summary> /// Compiles all decision nodes code and loops code in the given experiment /// </summary> /// <param name="experiment">The experiment.</param> /// <param name="availableInputMappingsPerNode">The available input mappings per node.</param> /// <param name="workspaceTypesDirectories">The workspace types directories.</param> /// <param name="loggerNameRoot">The logger name root.</param> /// <returns> /// true if there were no errors, otherwise false /// </returns> public static bool CompileAllDecisionNodes(IExperiment experiment, InputMappings availableInputMappingsPerNode, List <string> workspaceTypesDirectories, LoggerNameRoot loggerNameRoot) { bool noErrors = true; foreach (ExperimentNode node in experiment.Vertices) { IDecision decisionMetadata = node.Data.Metadata as IDecision; if (decisionMetadata != null) { try { //build successor nodes label id lookup Dictionary <string, string> successorNodeLabelIdLookup = PrepareSuccessorNodesLabelIdLookup(node, experiment); Dictionary <string, string> predeccessorsOutputsNameTypeLookup = PreparePredeccessorsOutputsNameTypeLookup(node, availableInputMappingsPerNode); node.ClearError(); BuildSourceAndCompileDecisionModule(decisionMetadata, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup, workspaceTypesDirectories, loggerNameRoot); } catch (ArgumentException ex) { noErrors = false; node.SetError(ex.Message); } } } return(noErrors); }
public HistoryEntry(IDecision decision, string state, DateTime modified) { State = state; Modified = modified; TaggedValueGUID = ""; Decision = decision; }
void Options_NewDecision(IDecision decision) { pickPowerCard = decision as Select.PowerCard; // capture so we can display card-action this.options = pickPowerCard != null ? pickPowerCard.CardOptions : decision.Options.OfType <PowerCard>().ToArray(); choiceLocations.Clear(); foreach (var deck in decks) { if (deck.PowerCards.Intersect(options).Any()) { choiceLocations.Add(deck.Icon); } } // If there are cards to display but we aren't on them if (choiceLocations.Any() && !choiceLocations.Contains(CurrentLocation)) { CurrentLocation = choiceLocations.First(); // switch } else if (GetCardsForLocation(CurrentLocation).Count == 0) { CurrentLocation = Img.Deck_Hand; } this.Invalidate(); }
// listeners //////////////////////////////////////////////////////////////// protected internal virtual void NotifyTransformListeners(IDecision decision, IDmnDecision dmnDecision) { foreach (var transformListener in transformListeners) { transformListener.transformDecision(decision, dmnDecision); } }
/// <summary> /// Builds the code source. /// Depending on metadata type final class will implement different interfaces and thus will have different class body. /// 1. metadata is a DecisionMetadata - the final source class is going to implement IDecisionModule interface, /// 2. metadata is a LoopScopeMetadata - the final source class is going to implement ILoopDecisionModule interface /// </summary> /// <param name="metadata">The metadata.</param> /// <param name="typeDirectories">The type directories.</param> /// <param name="successorNodeLabelIdLookup">The successor node label id lookup.</param> /// <param name="predeccessorsOutputsNameTypeLookup">The predeccessors outputs name type lookup.</param> /// <param name="logger">The logger.</param> /// <param name="assembliesReferenceLocations">Output the list of assemblies locations that must be reference by DecisionCompilator</param> /// <returns></returns> public static string BuildCodeSource(IDecision metadata, List <string> typeDirectories, Dictionary <string, string> successorNodeLabelIdLookup, Dictionary <string, string> predeccessorsOutputsNameTypeLookup, ComponentLogger logger, out HashSet <string> assembliesReferenceLocations) { string bodyCode, moduleInterface; if (metadata is DecisionMetadata) { //parse the code written by user DecisionCodeParser codeParser = new DecisionCodeParser(metadata.DecisionCode, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup); string userDecisionCodeSnippet = codeParser.ParseCode(); bodyCode = String.Format(DECISION_MODULE_BODY, userDecisionCodeSnippet); moduleInterface = typeof(IDecisionModule).FullName; } else { //append ';' to the end just in case so that user condition can be simplified string decisionCode = (metadata.DecisionCode.EndsWith(";")) ? metadata.DecisionCode : metadata.DecisionCode + ";"; DecisionCodeParser codeParser = new DecisionCodeParser(decisionCode, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup); string userDecisionCodeSnippet = codeParser.ParseCode(); bodyCode = String.Format(LOOP_DECISION_MODULE_BODY, userDecisionCodeSnippet); moduleInterface = typeof(ILoopDecisionModule).FullName; } //build the string of all usings of all namespace found in types assemblies string usingsNamespacesCodeSnippet = ReferenceTypesAssemblies(typeDirectories, logger, out assembliesReferenceLocations); return(BuildDecisionCodeSource(metadata.Classname, moduleInterface, bodyCode, usingsNamespacesCodeSnippet)); }
public FindLocation(GameObject a, Transform t, IDecision tB, IDecision fB) { agent = a; target = t; tBranch = tB; fBranch = fB; }
/// <summary> /// Compiles the decision. /// </summary> /// <param name="node">The node.</param> /// <param name="experiment">The experiment.</param> /// <param name="workspaceTypesDirectories">The workspace types directories.</param> /// <param name="loggerNameRoot">The logger name root.</param> private static void CompileDecisionInternal(ExperimentNode node, IExperiment experiment, List <string> workspaceTypesDirectories, LoggerNameRoot loggerNameRoot, Dictionary <string, string> successorNodeLabelIdLookup) { InputMappings availableInputMappingsPerNode = new InputMappings(experiment); Dictionary <string, string> predeccessorsOutputsNameTypeLookup = PreparePredeccessorsOutputsNameTypeLookup(node, availableInputMappingsPerNode); IDecision decisionMetadata = (IDecision)node.Data.Metadata; try { if (decisionMetadata != null) { node.ClearError(); BuildSourceAndCompileDecisionModule(decisionMetadata, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup, workspaceTypesDirectories, loggerNameRoot); decisionMetadata.CompilationStatus = TraceLab.Core.Components.CompilationStatus.Successful; } } catch (ArgumentException ex) { decisionMetadata.CompilationStatus = TraceLab.Core.Components.CompilationStatus.Failed; node.SetError(ex.Message); } }
public TestCase(IDocument doc, string alias, string path) { Doc = doc; Alias = alias; Path = path; Decision = Doc.Allow(Alias, Path); }
public AmIInBush(IDecision _trueBranch, IDecision _falseBranch, Wanderer wanderer) // use radius { float minDistance = Mathf.Infinity; // setup distance float newDist; // challenger distance for (int i = 0; i < wanderer.bush.Count; i++) // could be .Count or .size for vectors { newDist = Vector3.Distance(wanderer.transform.position, wanderer.bush[i].transform.position); // Distance check if (newDist < minDistance) // if new distance is less than set distance { minDistance = newDist; // set dist becomes new dist } } if (minDistance < 0.6f) // distance check between the closest bush and the wanderer { wanderer.InBush = true; value = true; } else { wanderer.InBush = false; value = false; } trueBranch = _trueBranch; falseBranch = _falseBranch; }
public void Update() { if (!waitingForAction) { actor = NextOf(combatants, actor); IHealth <int> actorHealth = actor.GetComponent <IHealth <int> >(); FindViableTargets(actor.tag); // A dead actor can't make moves, so we'll simply return if (actorHealth.IsDead || targets.Count == 0) { return; } if (actor.tag == "Player") { decision = new PlayerDecision(actor, targets); } else { decision = new AIDecision(actor, targets); } waitingForAction = true; } if (decision.IsReady) { bsm.Change(BattleState.Execute, decision.Action); } }
public ForceEvaluation(IDecision decision, IForce force, IConcern concern, string result) { _decisionGUID = decision.GUID; Force = force; Concern = concern; Result = result; Decision = decision; }
private void Update() { curTarget = findNewTarget; while (curTarget.MakeDecision() != null) { curTarget = curTarget.MakeDecision(); } }
public StakeholderAction(IDecision decision, IEAConnector connector) { Stakeholder = Model.Stakeholder.Load(connector.GetClient()); Action = connector.Stereotype; ConnectorGUID = connector.GUID; Decision = decision; PropertyChanged += OnPropertyChanged; }
// Every frame makes a decision on what to do; private void Update() { curDec = enemCheck; while (curDec != null) { curDec = curDec.MakeDecision(); } }
public void InsertDecisionTable(IDecision decision) { ISlide detailSlide = new DetailSlide(_doc, _detailSlideTemplate, decision); detailSlide.Create(); detailSlide.FillContent(); detailSlide.Save(); detailSlide.Add(); }
public void OnDecisionChanged(int index, IDecision decision) { //TODO dit werkt denk ik niet met deletes //var column = dataGridView1.Columns[FirstDecisionColumnindex + index]; //column.HeaderCell.Value = decision.Name; //ColorCellAccordingToState(column.HeaderCell, decision.State); OnRevertedChanges(Topic); }
//Sets up your tree here, assigning additional decisions to the //left and right of the tree void Start() { BooleanDecision boolDecision = new BooleanDecision(true); boolDecision.trueDecision = new CustomPrintDecision("True"); //prints "true" if true boolDecision.falseDecision = new CustomPrintDecision("False"); //prints "false" if false boolDecision.falseDecision = new WaypointReachedDecision(); decisionTreeRoot = boolDecision; }
void Update() { IDecision currentDecision = decisionTreeRoot; while (currentDecision != null) { decisionTreeRoot.MakeDecision(); } }
void Action_NewWaitingDecision(IDecision decision) { // Decision currentDecision = decision; this.promptLabel.Text = decision.Prompt; islandControl.Invalidate(); NewDecision?.Invoke(decision); UpdateRewindMenu(); }
public IDecision EvaluateNextOneGetFollowOnBranch(IDecision questionnaire) { IDecision q = questionnaire; if (q.Result == 0) { q.Mutator(q, null); } var nxt = q.GetFollowOnDecisionBranch(q.Result); q = nxt; return q; }
public given_CTB_Assessment_when_Nationality_eq_UK() { // get a decisionTree with lambdas... _q = QuestionnaireFactory.GetCtbQuestionnaire(); // get the next question, which is the first question var d1 = _q.GetNext(_q) as NationalityDecision; // poke answer on the mutator d1.Mutator(d1, new NationalityDecision { NationalityEnum = NationalityEnum.UK, Amount = 0.0f, Result = 1 }); // get next question given the current state the assessment nxt = _q.GetFollowOnDecisionBranch(_q.Result); }
private static DecisionLoader ConstructDecisionModuleInComponentsAppDomain(IDecision decisionMetadata, IWorkspaceInternal workspaceWrapper, AppDomain componentsAppDomain) { // DecisionLoader must be MarshalByRef, otherwise the properties don't get filled out the // way that we want them to. DecisionLoader loader = (DecisionLoader)componentsAppDomain.CreateInstanceAndUnwrap( Assembly.GetExecutingAssembly().FullName, typeof(DecisionLoader).FullName, false, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance, null, new object[] { decisionMetadata.Classname, decisionMetadata.SourceAssembly, workspaceWrapper }, System.Globalization.CultureInfo.CurrentCulture, new object[] { }); // Perform the actual load by passing a reference to the Loader's Load function to the new // AppDomain to execute loader.Load(); return loader; }
private Planner BasicPlanner() { CurrentState state = new CurrentState(); IDecision[] decisions = new IDecision[] { new MoveToFridge(state), new KillFridgeGuardian(state), new OpenFridgeDecision(state), new GetBananaFromFridge(state) }; Planner planner = new Planner(StateOffset.Heuristic); for (int i = 0; i < decisions.Length; i++) { planner.AddDecision(decisions[i]); } return planner; }
/// <summary> /// Builds the source of decision module and compile decision module into the assembly /// </summary> /// <param name="metadata">The metadata.</param> /// <param name="successorNodeLabelIdLookup">The successor node label id lookup.</param> /// <param name="predeccessorsOutputsNameTypeLookup">The predeccessors outputs name type lookup.</param> /// <param name="workspaceTypesDirectories">The workspace types directories.</param> /// <param name="loggerNameRoot">The logger name root.</param> private static void BuildSourceAndCompileDecisionModule(IDecision metadata, Dictionary<string, string> successorNodeLabelIdLookup, Dictionary<string, string> predeccessorsOutputsNameTypeLookup, List<string> workspaceTypesDirectories, LoggerNameRoot loggerNameRoot) { metadata.FireRequestLatestCode(); //create local componentlogger (ComponentLoggerImplementation implements MarshalByRefObject, thanks to which it can pass logs between appdomains TraceLabSDK.ComponentLogger logger = LoggerFactory.CreateLogger(loggerNameRoot, metadata.UniqueDecisionID, metadata); //construct the final code, and collect types assemblies locations to be referenced by the compilator HashSet<string> assembliesReferenceLocations; string finalDecisionModuleSourceCode = DecisionCodeBuilder.BuildCodeSource(metadata, workspaceTypesDirectories, successorNodeLabelIdLookup, predeccessorsOutputsNameTypeLookup, logger, out assembliesReferenceLocations); // Create the new domain with whatever current security evidence we're running with using the library helper LibraryHelper helper = new LibraryHelper(workspaceTypesDirectories); AppDomain newDomain = helper.CreateDomain("DecisionModuleCompilation"); newDomain.Load(Assembly.GetExecutingAssembly().GetName()); helper.PreloadWorkspaceTypes(newDomain); //// Load our output assembly into the other domain. DecisionModuleCompilator compiler = (DecisionModuleCompilator)newDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(DecisionModuleCompilator).FullName, false, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance, null, new object[] { }, System.Globalization.CultureInfo.CurrentCulture, new object[] { }); compiler.CompileDecisionModule(finalDecisionModuleSourceCode, metadata.SourceAssembly, assembliesReferenceLocations); #if !MONO_DEV //when developing on mono in MonoDevelop application crashes when unloading appdomain. //it only happens from within of MonoDevelop with attached debugger. Running normally, works fine. AppDomain.Unload(newDomain); #endif }
public IDecision GetNext(IDecision d) { // Code if (d.Result == (int)DeeTree.BranchChoiceEnum.NotKnown) { return d; } else { return GetNext(this.GetFollowOnDecisionBranch(Result)); } }
public void AddDecision(IDecision decision) { _decisions.Add(decision); }
private void BeginInicio() { decision = new IniciarSatelite(_data); }
private void BeginEspera() { decision = new Esperar(_data); }
private void BeginCalculo() { decision = new CalcularValoresOrbitales(_data); }
private void FinalizaDecision() { switch (estado) { case state.inicio: EndInicio(); break; case state.calculoValores: EndCalculo(); break; case state.espera: EndEspera(); break; default: throw new ArgumentException("Estado no implementado"); } decision = null; }