public void ReloadObjectActions(Action[] actions) { Action[] aux = new Action[actions.Length + 1]; aux[0] = null; for (int i = 1; i <= actions.Length; i++) { aux[i] = actions[i - 1]; } currentObjectActions = new Action[actions.Length + 1]; aux.CopyTo(currentObjectActions, 0); }
public bool ReloadMappingActions() { //deletes the previous action list and names by forming them again from the visualization and object arrays currentActionList = new Action[currentObjectActions.Length + currentVisualizationActions.Length - 1]; //For this to work propperly, the first action (index 0) of every array of Visualization/Objects actions MUST BE NULL currentVisualizationActions.CopyTo(currentActionList, 0); int actionListLen = currentVisualizationActions.Length; Action[] aux = new Action[currentObjectActions.Length - 1]; for (int i = 1; i < currentObjectActions.Length; i++) { aux[i - 1] = currentObjectActions[i]; } aux.CopyTo(currentActionList, actionListLen); return(true); }
public Action ChooseAction() { var processedActions = 0; int currentDepth = 0; var startTime = Time.realtimeSinceStartup; Action[] actions = new Action[MAX_DEPTH]; while(currentDepth >= 0){ if (processedActions > MAX_PROCESSED_ACTIONS) { InProgress = true; return null; } float currentValue = Models[currentDepth].CalculateDiscontentment(Goals); if(currentDepth >= MAX_DEPTH){ if(currentValue < BestDiscontentmentValue){ BestDiscontentmentValue = currentValue; BestAction = actions[0]; BestDiscontentmentValue = BestDiscontentmentValue; actions.CopyTo(BestActionSequence,0); TotalProcessingTime = Time.realtimeSinceStartup - startTime; } processedActions++; TotalActionCombinationsProcessed++; currentDepth -= 1; continue; } Action nextAction = Models[currentDepth].GetNextAction(); if (nextAction != null){ Models[currentDepth+1] = Models[currentDepth].GenerateChildWorldModel(); nextAction.ApplyActionEffects(Models[currentDepth+1]); actions[currentDepth] = nextAction; currentDepth += 1; } else currentDepth -= 1; } InProgress = false; return BestAction; }
public Action ChooseAction() { var processedActions = 0; var startTime = Time.realtimeSinceStartup; Action[] actions = new Action[MAX_DEPTH]; while (this.CurrentDepth >= 0) { if(processedActions > this.ActionCombinationsProcessedPerFrame) { this.InProgress = true; return null; } float currentValue = this.Models[this.CurrentDepth].CalculateDiscontentment(this.Goals); if (this.CurrentDepth >= MAX_DEPTH) { if (currentValue < this.BestDiscontentmentValue) { this.BestDiscontentmentValue = currentValue; this.BestAction = actions[0]; actions.CopyTo(this.BestActionSequence,0); this.TotalActionCombinationsProcessed += processedActions; this.TotalProcessingTime += Time.realtimeSinceStartup - startTime; } this.CurrentDepth -= 1; continue; } Action nextAction = this.Models[this.CurrentDepth].GetNextAction(); processedActions++; if (nextAction != null) { this.Models[this.CurrentDepth + 1] = this.Models[this.CurrentDepth].GenerateChildWorldModel(); nextAction.ApplyActionEffects(this.Models[this.CurrentDepth + 1]); actions[CurrentDepth] = nextAction; this.CurrentDepth += 1; } else this.CurrentDepth -= 1; } this.InProgress = false; return this.BestAction; }