private void LayerNumber_Changed(object sender, KeyEventArgs e) { if (!(sender is TextBox t)) { return; } switch (e.KeyCode) { case Keys.Enter: var splits = t.Name.Split('_'); int.TryParse(splits[1], out int whichLayer); int.TryParse(t.Text, out int howMany); howMany = MathHandler.Clamp(howMany, NeuralNetwork.NeuronMin, NeuralNetwork.NeuronMax); t.Text = howMany.ToString(); _ann.UpdateLayer(whichLayer, howMany); break; case Keys.Escape: splits = t.Name.Split('_'); int.TryParse(splits[1], out whichLayer); t.Text = _ann.GetArchitecture()[whichLayer].ToString(); break; } }
void CheckPoint() { if (!isStopped && MathHandler.IsPointInRange(transform.position, toPoint.position, pointStopRadius)) { Stop(); } }
private void CreateDevicesForBulkRegistration() { List <BasicGeoposition> coordinates = Item.Project.Coordinates; BasicGeoposition centroid = GeopositionHandler.GetPolygonCentroid(coordinates); BasicGeoposition northwest = GeopositionHandler.GetNorthWestPosition(coordinates, centroid); BasicGeoposition southeast = GeopositionHandler.GetSouthEastPosition(coordinates, centroid); var projectName = Item.Project.Name.Substring(0, 3).ToUpper(CultureInfo.InvariantCulture); var length = 16; Item.Devices.Clear(); for (int i = 0; i < Item.NMessages; i++) { var now = DateTime.Now; var datetime = now.Ticks.ToString(CultureInfo.InvariantCulture); var deviceID = projectName + i + datetime.Substring(datetime.Length - length, length); Windows.Devices.Geolocation.BasicGeoposition devicePosition = new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = MathHandler.GetRandomNumber(southeast.Latitude, northwest.Latitude), Longitude = MathHandler.GetRandomNumber(northwest.Longitude, southeast.Longitude), }; Item.Devices.Add(new Device(deviceID, devicePosition)); } }
void SetInitialTarget(Transform target) { _angle = MathHandler.GetAngle(target.position, transform); // In Degree _angle = _angle * Mathf.Deg2Rad; float _posX = Mathf.Cos(_angle) * stoppingDistance; float _posY = Mathf.Sin(_angle) * stoppingDistance; targetPos = new Vector2(_posX, _posY); }
private List <List <Symbol> > FormBatches() { List <List <Symbol> > batches = null; switch (_bacpropagationType) { case BackpropagationType.Batch: batches = new List <List <Symbol> > { _instance.Symbols.ToList() }; break; case BackpropagationType.MiniBatch: batches = new List <List <Symbol> >(); MathHandler.FindDivisor(_instance.NumSamples, out int numBatches, out int perBatchElements); int[] elemCounter = new int[_instance.NumSymbols]; int[] currentBatch = new int[_instance.NumSymbols]; for (int i = 0; i < _instance.NumSymbols; i++) { elemCounter[i] = perBatchElements; currentBatch[i] = 0; } for (int i = 0; i < numBatches; i++) { batches.Add(new List <Symbol>()); } foreach (Symbol t in _instance.Symbols) { int whichClass = WhichClass(t.Class); batches[currentBatch[whichClass]].Add(t); elemCounter[whichClass]--; if (elemCounter[whichClass] != 0) { continue; } elemCounter[whichClass] = perBatchElements; currentBatch[whichClass]++; } break; case BackpropagationType.Online: batches = new List <List <Symbol> >(); foreach (Symbol t in _instance.Symbols) { batches.Add(new List <Symbol> { t }); } break; } return(batches); }
private void Update() { if (_playerObj == null) { return; } if (MathHandler.IsExceedMinimumDistance(_playerObj.transform.position, transform.position, _minimumDistanceFromPlayerForShooting)) { Shoot(); } }
private void DesiredError_Left(object sender, EventArgs e) { if (!(sender is TextBox t)) { return; } double.TryParse(t.Text, out double desiredError); desiredError = MathHandler.Clamp(desiredError, NeuralNetwork.DesiredErrorMin, NeuralNetwork.DesiredErrorMax); t.Text = desiredError.ToString(CultureInfo.InvariantCulture); _ann.ChangeDesiredError(desiredError); }
public static int TextBoxLeft(object sender, EventArgs e, int valueToBeChanged, int min, int max) { if (!(sender is TextBox t)) { return(valueToBeChanged); } int.TryParse(t.Text, out int value); value = MathHandler.Clamp(value, min, max); t.Text = value.ToString(CultureInfo.InvariantCulture); return(value); }
private void Eta_Left(object sender, EventArgs e) { if (!(sender is TextBox t)) { return; } double.TryParse(t.Text, out double eta); eta = MathHandler.Clamp(eta, NeuralNetwork.EtaMin, NeuralNetwork.EtaMax); t.Text = eta.ToString(CultureInfo.InvariantCulture); _ann.ChangeEta(eta); }
private void LayerNumber_Left(object sender, EventArgs e) { if (!(sender is TextBox t)) { return; } var splits = t.Name.Split('_'); int.TryParse(splits[1], out int whichLayer); int.TryParse(t.Text, out int howMany); howMany = MathHandler.Clamp(howMany, NeuralNetwork.NeuronMin, NeuralNetwork.NeuronMax); t.Text = howMany.ToString(); _ann.UpdateLayer(whichLayer, howMany); }
private void DesiredError_Changed(object sender, KeyEventArgs e) { if (!(sender is TextBox t)) { return; } switch (e.KeyCode) { case Keys.Enter: double.TryParse(t.Text, out double desiredError); desiredError = MathHandler.Clamp(desiredError, NeuralNetwork.DesiredErrorMin, NeuralNetwork.DesiredErrorMax); t.Text = desiredError.ToString(CultureInfo.InvariantCulture); _ann.ChangeDesiredError(desiredError); break; case Keys.Escape: t.Text = _ann.GetDesiredError().ToString(CultureInfo.InvariantCulture); break; } }
private void Eta_Changed(object sender, KeyEventArgs e) { if (!(sender is TextBox t)) { return; } switch (e.KeyCode) { case Keys.Enter: double.TryParse(t.Text, out double eta); eta = MathHandler.Clamp(eta, NeuralNetwork.EtaMin, NeuralNetwork.EtaMax); t.Text = eta.ToString(CultureInfo.InvariantCulture); _ann.ChangeEta(eta); break; case Keys.Escape: t.Text = _ann.GetEta().ToString(CultureInfo.InvariantCulture); break; } }
public static int TextBoxChanged(object sender, KeyEventArgs e, int valueToBeChanged, int min, int max) { if (!(sender is TextBox t)) { return(valueToBeChanged); } switch (e.KeyCode) { case Keys.Enter: int.TryParse(t.Text, out int value); value = MathHandler.Clamp(value, min, max); t.Text = value.ToString(CultureInfo.InvariantCulture); return(value); case Keys.Escape: t.Text = valueToBeChanged.ToString(CultureInfo.InvariantCulture); break; } return(valueToBeChanged); }
private Vector3 GetDirNotColliding(Vector3 origin, Vector3 dir) { _dirRight = dir; _dirLeft = dir; float magntiude = dir.magnitude; for (int i = 0; i < MAX_ANGLE / ANGLE_DELTA_DIR; i++) { _dirRight = MathHandler.RotateVectorByAngle(_dirRight, -ANGLE_DELTA_DIR); _dirLeft = MathHandler.RotateVectorByAngle(_dirLeft, ANGLE_DELTA_DIR); if (!Physics.SphereCast(origin, _rayRadius, _dirRight, out _rayhit, magntiude, _layermaskIgnored)) { return(_dirRight); } if (!Physics.SphereCast(origin, _rayRadius, _dirLeft, out _rayhit, magntiude, _layermaskIgnored)) { return(_dirLeft); } } return(Vector3.zero); }
private void MoveTowards() { if (_canMove == true) { if (MathHandler.IsExceedMinimumDistance(_target.transform.position, transform.position, _stoppingDistance) == false) { float step = _movingSpeed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, _target.transform.position, step); } else { if (isReachedDestination == false) { isReachedDestination = true; if (OnGoingCompleted != null) { SetMovement(); } //this.enabled = false; } } } }
// konstruktor, w którym jest ustawiony delegat MathDelegate na funkcję MathFunction public DelegateClass() { this.MathDelegate = new MathHandler(MathFunction); }
//Funkcja przyjmująca jako argument delegat (wskaźnik do funkcji); public void FunctionWithDelagate(double X, double Y, MathHandler m) { Console.WriteLine("Wywolano FuncionWithDelegate: " + m(X, Y)); }