public void MakeRandom(OperatorHolder OHolder, int CIndex) { Holder = OHolder; ContainedIndex = CIndex; Holder.AddOperatorToHolder(this, ContainedIndex); AllOperatorsContainedIndex = Eq.AddOperatorToAlloperators(this); ChangeOperator(); }
public void SetupOperator(bool OResultOmRightSide, MathFunction OMFunction, int OParameterIndex, float ORandomNumber, bool OUseRandomNumber, int CIndex, Connector OExtraMathFunction, OperatorHolder OHolder) { ResultOnRightSide = OResultOmRightSide; MFunction = OMFunction; ParameterIndex = OParameterIndex; RandomNumber = ORandomNumber; UseRandomNumber = OUseRandomNumber; ExtraMathFunction = OExtraMathFunction; Holder = OHolder; Holder.AddOperatorToHolder(this); AllOperatorsContainedIndex = Eq.AddOperatorToAlloperators(this); ContainedIndex = CIndex; }
/// <summary> /// faster way of resetting the operator when all operatos in an equation are reset at once /// </summary> public void StoreAndCleanupAll() { Eq.OPStorage.Push(this); MFunction.StoreAndCleanupAll(this); MFunction = null; Holder.RemoveOperatorFromHolder(ContainedIndex); Holder = null; // these actions might not be required yet but if there is any errors then it will be easier to spot if a null exception is thrown ContainedIndex = -1; AllOperatorsContainedIndex = -1; ResetMaxCalculated(); //NumberOfOperators = 0; }
/// <summary> /// resets the operator so it can be used to make a new random operator /// </summary> public void StoreAndCleanup() { Eq.OPStorage.Push(this); Eq.RemoveOperatorFromAllOperators(AllOperatorsContainedIndex); MFunction.StoreAndCleanup(this); MFunction = null; Holder.RemoveOperatorFromHolder(ContainedIndex); Holder = null; ContainedIndex = -1; AllOperatorsContainedIndex = -1; ResetMaxCalculated(); //NumberOfOperators = 0; }
/// <summary> /// Copys itself into a new OP Can only be called from within Equations copy method /// </summary> /// <param name="Copy">The OP to copy into</param> /// <param name="CopyEInfo">The Equationinfo the copy should use</param> /// <returns></returns> public Operator GetCopy(Operator Copy, Equation CopyEq, OperatorHolder CopyHolder) { Copy.ResultOnRightSide = ResultOnRightSide; Copy.MFunction = MFunction; Copy.ParameterIndex = ParameterIndex; Copy.RandomNumber = RandomNumber; Copy.UseRandomNumber = UseRandomNumber; //Copy.AllOperatorsContainedIndex = AllOperatorsContainedIndex; Copy.AllOperatorsContainedIndex = Tools.GetFirstFreeIndex(Copy.Eq.AllOperators); Copy.Eq.AddOperatorToAlloperators(Copy, Copy.AllOperatorsContainedIndex); Copy.ContainedIndex = ContainedIndex; //Copy.ContainedList[ContainedIndex] = Copy; Copy.Holder = CopyHolder; Copy.Holder.AddOperatorToHolder(Copy, Copy.ContainedIndex); Copy.MFunction.GetCopy(this, Copy); Copy.MaxCalculated = MaxCalculated; return(Copy); }
public Operator AddOperator(bool OResultOmRightSide, MathFunction OMFunction, int OParameterIndex, float ORandomNumber, bool OUseRandomNumber, Connector OExtraMathFunction, OperatorHolder OHolder) { Operator toAdd = Eq.OPStorage.Pop(); toAdd.SetupOperator(OResultOmRightSide, OMFunction, OParameterIndex, ORandomNumber, OUseRandomNumber, NumberOfOperators, OExtraMathFunction, OHolder); return(toAdd); }