//--------------------------------------------------------------------- static InputParametersParser() { // FIXME: Hack to ensure that Percentage is registered with InputValues Edu.Wisc.Forest.Flel.Util.Percentage p = new Edu.Wisc.Forest.Flel.Util.Percentage(); // Register the local method for parsing a cohort age or age range. InputValues.Register <AgeRange>(ParseAgeOrRange); Type.SetDescription <AgeRange>("cohort age or age range"); uShortParse = InputValues.GetParseMethod <ushort>(); }
//--------------------------------------------------------------------- /// <summary> /// Registers the appropriate method for reading input values. /// </summary> public static void RegisterForInputValues() { Type.SetDescription <SHImode>("Site Host Index Mode"); InputValues.Register <SHImode>(SHIParse); Type.SetDescription <DispersalType>("Dispersal Type"); InputValues.Register <DispersalType>(DispTypeParse); Type.SetDescription <DispersalTemplate>("Dispersal Template"); InputValues.Register <DispersalTemplate>(DispTParse); }
public void GetReadMethod_UnregisteredType() { try { ReadMethod <UnregisteredClass> readMethod = InputValues.GetReadMethod <UnregisteredClass>(); } catch (Exception exc) { Data.Output.WriteLine(exc.Message); throw; } }
//--------------------------------------------------------------------- static PartialThinning() { // Force the harvest library to register its read method for age // ranges. Then replace it with this project's read method that // handles percentages for partial thinning. AgeRangeParsing.InitializeClass(); InputValues.Register <AgeRange>(PartialThinning.ReadAgeOrRange); percentages = new Dictionary <ushort, Percentage>(); CohortSelectors = new PartialCohortSelectors(); }
// Use this for initialization void Start() { input = new InputValues(); chosen = false; choseSFX = GameObject.Find("MenuController").GetComponents <AudioSource>()[0]; swipeSFX = GameObject.Find("MenuController").GetComponents <AudioSource>()[1]; //constantly calls an update function, every 0.25 seconds. Lets us get delays on the controller input. InvokeRepeating("BestUpdate", 0f, 0.25f); }
public void Init() { Flel.Util.Type.SetDescription <RegisteredClass>("Registered Class"); InputValues.Register <RegisteredClass>(RegisteredClass.Parse); byteReadMethod = InputValues.GetReadMethod <byte>(); values = new byte[] { 78, 0, 255 }; string[] valsAsStrs = Array.ConvertAll(values, new Converter <byte, string>(Convert.ToString)); valuesAsStr = string.Join(" ", valsAsStrs); }
public SynthValues(InputValues values) { this.primaryPose = new Pose { position = new Vector3(values.primaryPose.position.x / 5, values.primaryPose.position.y / maxHeight, values.primaryPose.position.z / 5), eulerRotation = values.primaryPose.eulerRotation / 360 }; this.secondaryPose = new Pose { position = new Vector3(values.secondaryPose.position.x / 5, values.secondaryPose.position.y / maxHeight, values.secondaryPose.position.z / 5), eulerRotation = values.secondaryPose.eulerRotation / 360 }; this.inputs = values.inputs; }
LandCover.IChange ProcessLandCoverChange(InputVar <string> landCoverChangeType) { InputVar <bool> repeatableHarvest = new InputVar <bool>("RepeatHarvest?"); bool repeatHarvest = false; if (ReadOptionalVar(repeatableHarvest)) { repeatHarvest = repeatableHarvest.Value.Actual; } LandCover.IChange landCoverChange = null; if (landCoverChangeType.Value.Actual == LandCover.NoChange.TypeName) { landCoverChange = noLandCoverChange; } else if (landCoverChangeType.Value.Actual == LandCover.RemoveTrees.TypeName) { LandCover.LandCover.DontParseTrees = true; PartialThinning.CohortSelectors.Clear(); //Clear static storage selector to prevent writing across land uses InputValues.Register <AgeRange>(PartialThinning.ReadAgeOrRange); ICohortSelector selector = selector = ReadSpeciesAndCohorts("LandUse", ParameterNames.Plant, "Tony Bonanza", "LandCoverChange"); ICohortCutter cohortCutter = CohortCutterFactory.CreateCutter(selector, Main.ExtType); Planting.SpeciesList speciesToPlant = ReadSpeciesToPlant(); landCoverChange = new LandCover.RemoveTrees(cohortCutter, speciesToPlant, repeatHarvest); PartialThinning.CohortSelectors.Clear(); //Prevent interactions with Biomass Harvest LandCover.LandCover.DontParseTrees = false; } else if (landCoverChangeType.Value.Actual == LandCover.InsectDefoliation.TypeName) { //Insects will reduce biomass of cohorts rather than directly affecting demographics InputValues.Register <AgeRange>(LandCover.LandCover.ReadAgeOrRange); ICohortSelector selector = ReadSpeciesAndCohorts("LandUse", ParameterNames.Plant, "Vito Tortellini", "LandCoverChange"); Planting.SpeciesList speciesToPlant = ReadSpeciesToPlant(); landCoverChange = new LandCover.InsectDefoliation(LandCover.LandCover.CohortSelectors, speciesToPlant, repeatHarvest); LandCover.LandCover.CohortSelectors.Clear(); //Clear static storage selector to prevent writing across land uses } else { throw new InputValueException(landCoverChangeType.Value.String, "\"{0}\" is not a type of land cover change", landCoverChangeType.Value.Actual); } //landCoverChange.PrintLandCoverDetails(); return(landCoverChange); }
public void GetReadMethod_Float_LessThanMin() { try { StringReader reader = new StringReader(double.MinValue.ToString()); ReadMethod <float> readMethod = InputValues.GetReadMethod <float>(); int index; InputValue <float> result = readMethod(reader, out index); } catch (InputValueException exc) { Data.Output.WriteLine(exc.Message); throw exc; } }
public void GetReadMethod_Int_MoreThanMax() { try { StringReader reader = new StringReader(long.MaxValue.ToString()); ReadMethod <int> readMethod = InputValues.GetReadMethod <int>(); int index; InputValue <int> result = readMethod(reader, out index); } catch (InputValueException exc) { Data.Output.WriteLine(exc.Message); throw exc; } }
private void Input(Operation operation, int instructionAddress) { if (InputValues.Count > 0) { SetParameter(operation.FirstParameterMode, instructionAddress + 1, InputValues.Dequeue()); IncrementInstructionPointer(2); } else { State = MachineState.Paused; } }
/// <param name="parameters">Parameters of the strategy specifying input coins, the target and final selection restrictions.</param> /// <param name="bestSelection">Best selection so far.</param> public SelectionStrategy(StrategyParameters parameters, CoinSelection bestSelection) { Parameters = parameters; BestSelection = bestSelection; RemainingAmounts = new long[InputValues.Length]; long accumulator = InputValues.Sum(); for (int i = 0; i < InputValues.Length; i++) { accumulator -= InputValues[i]; RemainingAmounts[i] = accumulator; } }
void Execute() { var fis = new FuzzyInferenceSystem( kb, new CentroidDefuzzFactory().Create(), new MamdaniMethod()); var inputs = new InputValues() .AddValue("service", 9.8) .AddValue("food", 6.5); var tip = fis.Compute(inputs); Console.WriteLine(tip); }
void Start() { game = GameObject.Find("GameController").GetComponent <GameController>(); squakSFX = GetComponent <AudioSource>(); rb = GetComponent <Rigidbody>(); charCon = GetComponent <CharacterController> (); animator = GetComponent <Animator> (); yaw = transform.rotation.eulerAngles.y; pitch = transform.rotation.eulerAngles.x; rb.freezeRotation = true; holding = false; flying = true; input = new InputValues(); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { var processName = ProcessName?.Get(context); if (string.IsNullOrEmpty(processName)) { throw new ArgumentException("No process name was given."); } var inputValues = InputValues?.Get(context); var runProcess = new RunProcessDelegate(RunProcess); context.UserState = runProcess; return(runProcess.BeginInvoke(processName, inputValues, callback, state)); }
//--------------------------------------------------------------------- /// <summary> /// Registers a read method for plug-in names with the input values /// modules in the FLEL utility library. /// </summary> /// <param name="installedPlugIns"> /// The dataset of information about plug-ins installed on the local /// machine. Used by the read method to validate plug-in names. /// </param> public static void RegisterReadMethod(PlugIns.IDataset installedPlugIns) { if (installedPlugIns == null) { throw new System.ArgumentNullException(); } PlugInInfo.installedPlugIns = installedPlugIns; if (!registered) { Type.SetDescription <PlugIns.PlugInInfo>("plug-in name"); InputValues.Register <PlugIns.PlugInInfo>(Read); registered = true; } }
public void Vibrate(InputValues vibrationType) { switch (vibrationType) { case InputValues.Left: GamePad.SetVibration(playerIndex, vibrationStrength, 0.0f); break; case InputValues.Right: GamePad.SetVibration(playerIndex, 0.0f, vibrationStrength); break; } StartCoroutine(StopVibrationAfterTimer()); }
//--------------------------------------------------------------------- /// <summary> /// Registers a read method for extension names with the input values /// modules in the FLEL utility library. /// </summary> /// <param name="installedExtensions"> /// The dataset of information about extensions installed on the local /// machine. Used by the read method to validate extension names. /// </param> public static void RegisterReadMethod(IExtensionDataset installedExtensions) { if (installedExtensions == null) { throw new System.ArgumentNullException(); } ExtensionInfoIO.installedExtensions = installedExtensions; if (!registered) { Type.SetDescription <ExtensionInfo>("extension name"); InputValues.Register <ExtensionInfo>(Read); registered = true; } }
public InputValues poll(InputValues prev) { var current = new InputValues(); var rawValue = Input.GetAxisRaw(name) * sign; current.value = rawValue > 0.0f ? rawValue : 0.0f; current.push = rawValue > limit; current.down = (prev.push ^ current.push) & current.push; current.up = (prev.push ^ current.push) & !current.push; return(current); }
// Update is called once per frame void Update() { InputValues inputs = InputHandler.GetInputs(); //TODO: check that the panID is in range of pan count once we have a Static Game Class if (hobID < 0 || hobID >= 3) //i know there 3 but still. { Debug.LogError("Pan Id Out of range (obj name: " + name + ")"); return; } Vector3 currentRotation = transform.eulerAngles; currentRotation.z = -270f * (inputs.hobs[hobID] / 1023f); transform.eulerAngles = currentRotation; }
public void poll() { switch (type) { case EnDeviceType.axis: state = deviceAxis.poll(state); break; case EnDeviceType.key: state = deviceKey.poll(state); break; } }
public override void UpdateCamera() { // Get Input EasyUnityInput.AppendInput(); InputValues input = Input.ProcessedInput; Input.ClearInput(); // Handle the rotating to follow the target from behind. FollowRotation.UpdateRotation(); // Apply target offset modifications Vector3 headbobOffset = Headbob.GetHeadbobModifier(_previousDistance); Target.AddWorldSpaceOffset(headbobOffset); Vector3 screenShakeOffset = ScreenShake.GetShaking(); Target.AddWorldSpaceOffset(screenShakeOffset); Vector3 target = Target.GetTarget(); // Hanlde Zooming if (input.ZoomIn.HasValue) { DesiredDistance = Mathf.Max(DesiredDistance + input.ZoomIn.Value, 0); DesiredDistance = Mathf.Max(DesiredDistance, MinZoomDistance); } if (input.ZoomOut.HasValue) { DesiredDistance = Mathf.Min(DesiredDistance + input.ZoomOut.Value, MaxZoomDistance); } // Set Camera Position float desired = DesiredDistance; // Where we want the camera to be float calculated = ViewCollision.CalculateMaximumDistanceFromTarget(target, Mathf.Max(desired, _previousDistance)); // The maximum distance we calculated we can be based off collision and preference float zoom = Zoom.CalculateDistanceFromTarget(_previousDistance, calculated, desired); // Where we want to be for the sake of zooming Vector3 zoomDistance = CameraTransform.Forward * zoom; CameraTransform.Position = target - zoomDistance; // No buffer if the buffer would zoom us in past 0. float actual = Vector3.Distance(CameraTransform.Position, target); _previousDistance = actual; Target.ClearAdditionalOffsets(); }
static void Main(string[] args) { // Ask user for the range of numbers to loop through Console.Write("Enter a starting number: "); var start = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter an ending number: "); var end = Convert.ToInt32(Console.ReadLine()); // Allow user to enter as many divisor and corresponding values as they want var values = new InputValues(); while (true) { Console.Write("Enter multiplier number or type 'Quit' to exit: "); var multiNum = Console.ReadLine(); if (multiNum.ToLower() == "quit") { break; } Console.Write("Enter cooresponding word or type 'Quit' to exit: "); var multiWord = Console.ReadLine(); if (multiWord.ToLower() == "quit") { break; } var multiplier = Convert.ToInt32(multiNum); // Add user input values to List<Values> values.Add(multiplier, multiWord); } // Pass range of numbers from user input and Values list var range = new Range(start, end, values); range.Output(); Console.ReadLine(); /* From phone interview - put FizzBuzz in a separate class */ // Console.WriteLine(FizzBuzzing.DoFizzBuzz()); // Console.ReadLine(); }
// Update is called once per frame void Update() { InputValues inputs = InputHandler.GetInputs(); SelectPan(inputs.panToggle); // we can not pour when in the default postion if (currentPosition < 0) { return; } Vector3 rotation = transform.eulerAngles; minMaxInputValue.current = inputs.jug; rotation.x = GetCurrentXRotation(); transform.eulerAngles = rotation; // keep the batters x rotation @ 0 so its always level. // TODO: make dynamic. Vector3 batterRotation = batter.eulerAngles; Vector3 batterScale = batter.localScale; batterRotation.x = 0; batter.eulerAngles = batterRotation; batterScale.y = batter_yScale_pour.GetValue(minMaxInputValue.Precent); batter.localScale = batterScale; //TEST. // spwan batter pour if (Mathf.Abs(rotation.x) > 10 && Time.time >= batter_nextSpwTime) { BatterTrail bTrail = Instantiate(batterTrail, pourTrail_startPosition.position, Quaternion.identity); bTrail.Init(this, pourTrail_startPosition, pourTrail_lerpEndPosition, batterTrail_pourAmount); batter_nextSpwTime = Time.time + batterTrail_spwIntervals; batterTrail_pourAmount = 0; } else if (Mathf.Abs(rotation.x) > 10 && Time.time < batter_nextSpwTime) { batterTrail_pourAmount += (batter_maxPourRate * minMaxInputValue.Precent) * Time.deltaTime; } }
public void GetReadMethod_RegisteredType() { ReadMethod <RegisteredClass> readMethod = InputValues.GetReadMethod <RegisteredClass>(); string[] words = new string[] { "aardvark", "LKR555", "<-o->" }; string separator = " \t "; StringReader reader = new StringReader(string.Join(separator, words)); foreach (string word in words) { int index; InputValue <RegisteredClass> result = readMethod(reader, out index); Assert.AreEqual(word, result.Actual.Str); Assert.AreEqual(word, result.String); Assert.AreEqual(index + word.Length, reader.Index); } }
// Update is called once per frame void FixedUpdate() { //TODO: check that the panID is in range of pan count once we have a Static Game Class if (panID < 0 || panID >= 3) //i know there 3 but still. { Debug.LogError("Pan Id Out of range (obj name: " + name + ")"); return; } InputValues inputs = InputHandler.GetInputs(); pan_OffHob_minMaxInputValue.current = inputs.panDistances[panID]; Vector3 position = transform.position; Vector3 rotation = transform.eulerAngles; // Update the Y position of the pan when it has moved on the hob position.y = startYPosition + (pan_OffHob_YPositionOffset * (1f - pan_OffHob_minMaxInputValue.ClampedPrecent)); // get the current pan rotation from inputs rotation.x = -inputs.pans_x[panID]; rotation.z = -inputs.pans_y[panID]; //<-- Hmm, this is a lil confusing. Y on the Gyro is z in unity. TODO: do somthink to clear this up :), ie. rename the array. // make shore the pancake is awake if the inputs have changed since the last frame :) if (currentPancake != null && (rotation.x != last_x_rotation || rotation.y != last_z_rotation || position.y != last_y_position)) { currentPancake.WakeUp(); } transform.eulerAngles = rotation; transform.position = position; ApplyForceToPancakes(rotation.z - last_z_rotation); // record the last rotation and y position so we know whether or not to wake up any pancake that are in the pan last_x_rotation = rotation.x; last_z_rotation = rotation.z; last_y_position = position.y; SetPancakeTemperture(); }
//--------------------------------------------------------------------- /// <summary> /// Reads a plug-in name from a text reader and returns the /// information for the plug-in. /// </summary> public static InputValue <PlugIns.PlugInInfo> Read(StringReader reader, out int index) { ReadMethod <string> strReadMethod = InputValues.GetReadMethod <string>(); InputValue <string> name = strReadMethod(reader, out index); if (name.Actual.Trim(null) == "") { throw new InputValueException(name.Actual, name.String + " is not a valid plug-in name."); } PlugIns.PlugInInfo info = installedPlugIns[name.Actual]; if (info == null) { throw new InputValueException(name.Actual, "No plug-in with the name \"{0}\".", name.Actual); } return(new InputValue <PlugIns.PlugInInfo>(info, name.Actual)); }
//--------------------------------------------------------------------- /// <summary> /// Registers the appropriate method for reading input values. /// </summary> public static void RegisterForInputValues() { Edu.Wisc.Forest.Flel.Util.Type.SetDescription <BaseFuelType>("Base Fuel Type Code"); InputValues.Register <BaseFuelType>(BFParse); Edu.Wisc.Forest.Flel.Util.Type.SetDescription <SurfaceFuelType>("Surface Fuel Type Code"); InputValues.Register <SurfaceFuelType>(SFParse); Edu.Wisc.Forest.Flel.Util.Type.SetDescription <SizeType>("Size Type Indicator"); InputValues.Register <SizeType>(STParse); Edu.Wisc.Forest.Flel.Util.Type.SetDescription <SeasonName>("Season Name"); InputValues.Register <SeasonName>(SNParse); Edu.Wisc.Forest.Flel.Util.Type.SetDescription <LeafOnOff>("Leaf On or Off"); InputValues.Register <LeafOnOff>(LooParse); Edu.Wisc.Forest.Flel.Util.Type.SetDescription <Distribution>("Random Number Distribution"); InputValues.Register <Distribution>(DistParse); }
/// <summary> /// Reads a plug-in name from a text reader and returns the /// information for the plug-in. /// </summary> public static InputValue <Edu.Wisc.Forest.Flel.Util.PlugIns.Info> Read(StringReader reader, out int index) { ReadMethod <string> strReadMethod = InputValues.GetReadMethod <string>(); InputValue <string> name = strReadMethod(reader, out index); if (name.Actual.Trim(null) == "") { throw new InputValueException(name.Actual, name.String + " is not a valid plug-in name."); } Edu.Wisc.Forest.Flel.Util.PlugIns.Info info = (Edu.Wisc.Forest.Flel.Util.PlugIns.Info)PlugIns.Manager.GetInfo(name.Actual); if (info == null) { throw new InputValueException(name.Actual, "No plug-in with the name \"{0}\".", name.Actual); } return(new InputValue <Edu.Wisc.Forest.Flel.Util.PlugIns.Info>(info, name.Actual)); }
public void TestEvaluateExpression() { InputValues input = new InputValues() { maxCardinality = 1, minCardinality = 0, maxDepth = 32, nextDepth = 1, noMaxDepth = true, isArray = true, normalized = false, referenceOnly = true, structured = true }; List <Tuple <string, string> > exprAndExpectedResultList = new List <Tuple <string, string> >(); { exprAndExpectedResultList.Add(new Tuple <string, string>("(cardinality.maximum > 1) && (!referenceOnly)", "False")); exprAndExpectedResultList.Add(new Tuple <string, string>("", "False")); exprAndExpectedResultList.Add(new Tuple <string, string>(" ", "False")); exprAndExpectedResultList.Add(new Tuple <string, string>("always", "True")); exprAndExpectedResultList.Add(new Tuple <string, string>("!structured", "False")); exprAndExpectedResultList.Add(new Tuple <string, string>("referenceOnly || (depth > 5)", "True")); exprAndExpectedResultList.Add(new Tuple <string, string>("!(referenceOnly)", "False")); exprAndExpectedResultList.Add(new Tuple <string, string>("!(normalized && cardinality.maximum > 1)", "True")); exprAndExpectedResultList.Add(new Tuple <string, string>("true", "True")); exprAndExpectedResultList.Add(new Tuple <string, string>("(((true==true)))", "True")); exprAndExpectedResultList.Add(new Tuple <string, string>("!(normalized && isArray) || noMaxDepth", "False")); } foreach (var item in exprAndExpectedResultList) { ExpressionTree tree = new ExpressionTree(); Node treeTop = tree.ConstructExpressionTree(item.Item1); string expected = item.Item2; string actual = ExpressionTree.EvaluateExpressionTree(treeTop, input).ToString(); Assert.AreEqual(expected, actual); } }
public EquipmentState(InputValues playerInputValues) { this.playerInputValues = playerInputValues; }
public KeyboardAndMouse(InputValues inputValues) { InputNames = Resources.Load(PrefabName, typeof(InputNames)) as InputNames; this.InputValues = inputValues; }
private void CharacterInitialization(BaseCharacterController character) { var inputValues = new InputValues(character); InputCollector.Instance.AddInputValues(inputValues); foreach (var InputSourc in character.InputSource) { switch (InputSourc) { case InputSourceType.KeyboardAndMouse: InputCollector.Instance.AddInputSorces(new KeyboardAndMouse(inputValues)); break; } } }