private void Awake() { // clone()을 만들어서 초기값을 저장해둠 InstantEffectInitialValue = InstantEffect.Clone(instantEffect); PersistEffectInitialValue = PersistEffect.Clone(persistEffect); ConditionalEffectInitialValue = ConditionalEffect.Clone(conditionalEffect); }
public ConditionalEffect Copy(ConditionalEffect origin) { conditionEffectId = origin.conditionEffectId; isRelationStack = origin.isRelationStack; stackBonusRate = origin.stackBonusRate; effect = origin.effect; return(this); }
public static ConditionalEffect Clone(ConditionalEffect origin) { return(new ConditionalEffect { conditionEffectId = origin.conditionEffectId, isRelationStack = origin.isRelationStack, stackBonusRate = origin.stackBonusRate, effect = origin.effect, }); }
public static CUseEffect Clone(CUseEffect origin) { return(new CUseEffect { IsUseEffectName = origin.IsUseEffectName, EffectName = origin.EffectName, instantEffect = InstantEffect.Clone(origin.instantEffect), persistEffect = PersistEffect.Clone(origin.persistEffect), conditionalEffect = ConditionalEffect.Clone(origin.conditionalEffect), }); }
public static CausualGraph computeCausualGraph(PAD.Planner.SAS.Problem problem) { CausualGraph result = new CausualGraph(); result.vertices = new List <int>(problem.Variables.Count); result.isEdge = new bool[problem.Variables.Count, problem.Variables.Count]; result.isMentionedInGoal = new bool[problem.Variables.Count]; for (int i = 0; i < problem.Variables.Count; i++) { result.vertices.Add(i); result.isMentionedInGoal[i] = problem.GoalConditions.Any(g => g.GetVariable() == i); } foreach (PAD.Planner.SAS.IOperator item in problem.Operators) { foreach (var precond in item.GetPreconditions()) { foreach (var eff in item.GetEffects()) { if (eff.GetAssignment().GetVariable() != precond.GetVariable()) { result.setEdge(precond.GetVariable(), eff.GetAssignment().GetVariable()); } } } foreach (var eff in item.GetEffects()) { ConditionalEffect condEff = eff as ConditionalEffect; if (condEff != null) { foreach (var cond in condEff.Conditions) { if (eff.GetAssignment().GetVariable() != cond.GetVariable()) { result.setEdge(cond.GetVariable(), eff.GetAssignment().GetVariable()); } } } } foreach (var eff in item.GetEffects()) { foreach (var eff2 in item.GetEffects()) { if (eff.GetAssignment().GetVariable() != eff2.GetAssignment().GetVariable()) { result.setEdge(eff.GetAssignment().GetVariable(), eff2.GetAssignment().GetVariable()); } } } } return(result); }
private bool isOutsideConditionMet(PAD.Planner.SAS.IEffect condition, Dictionary <int, HashSet <int> > redValues) { ConditionalEffect condEff = condition as ConditionalEffect; if (condEff != null) { foreach (var cond in condEff.Conditions) { if (!redValues.ContainsKey(cond.GetVariable())) { throw new Exception("Outside condition contains a black variable."); } if (!redValues[cond.GetVariable()].Contains(cond.GetValue())) { return(false); } } } return(true); }
public static DomainTransitionGraph computeDTG(PAD.Planner.SAS.Problem problem, int variable) { DomainTransitionGraph result = new DomainTransitionGraph(); result.variable = variable; result.vertices = new List <int>(); result.edges = new List <GraphEdge>(); if (problem.GoalConditions.Any(g => g.GetVariable() == variable)) { result.goalValue = problem.GoalConditions.Where(g => g.GetVariable() == variable).Single().GetValue(); } for (int i = 0; i < problem.Variables[variable].GetDomainRange(); i++) { result.vertices.Add(i); } foreach (PAD.Planner.SAS.IOperator item in problem.Operators) { foreach (var eff in item.GetEffects()) { if (eff.GetAssignment().GetVariable() == variable) { int targetValue = eff.GetAssignment().GetValue(); int originalValue = -1; List <IAssignment> listOutsideConditions = new List <IAssignment>(); List <IAssignment> listOutsideEffects = new List <IAssignment>(); foreach (var eff1 in item.GetEffects()) { if (eff1.GetAssignment().GetVariable() != eff.GetAssignment().GetVariable()) { listOutsideEffects.Add(eff1.GetAssignment()); } } ConditionalEffect condEff = eff as ConditionalEffect; if (condEff != null) { foreach (var cond in condEff.Conditions) { if (cond.GetVariable() == variable) { originalValue = cond.GetValue(); } else { listOutsideConditions.Add(new Assignment(cond.GetVariable(), cond.GetValue())); } } } foreach (var precond in item.GetPreconditions()) { if (precond.GetVariable() == variable) { originalValue = precond.GetValue(); } else { listOutsideConditions.Add(new Assignment(precond.GetVariable(), precond.GetValue())); } } if (originalValue != -1) { GraphEdge e = new GraphEdge(); e.from = originalValue; e.to = targetValue; e.outsideCondition = new ConditionalEffect(new PAD.Planner.SAS.Conditions(listOutsideConditions), new Assignment(-1, -1)); e.outsideEffect = new ConditionalEffect(new PAD.Planner.SAS.Conditions(listOutsideEffects), new Assignment(-1, -1)); e.op = item; result.edges.Add(e); } else { foreach (var val in result.vertices) { if (val == targetValue) { continue; } GraphEdge e = new GraphEdge(); e.from = val; e.to = targetValue; e.outsideCondition = new ConditionalEffect(new PAD.Planner.SAS.Conditions(listOutsideConditions), new Assignment(-1, -1)); e.outsideEffect = new ConditionalEffect(new PAD.Planner.SAS.Conditions(listOutsideEffects), new Assignment(-1, -1)); e.op = item; result.edges.Add(e); } } } } } result.computeRSE_Invertibility(); return(result); }