//private bool destroyed = false; void Start(){ soundManager = gameObject.GetComponentInChildren<SoundManager>(); energy = maxEnergy; score = FindObjectOfType(typeof(ScoreKeeper)) as ScoreKeeper; playerControl = gameObject.GetComponentInChildren<PlayerControl>(); playerGUI = gameObject.GetComponentInChildren<PlayerGUI>(); playerHealth = gameObject.GetComponentInChildren<PlayerHealth>(); thrust = gameObject.GetComponentInChildren<Thrust>(); shield = gameObject.AddComponent<Shield>() as Shield; shield.PDelegate = this; foreach(Weapon weapon in gameObject.GetComponentsInChildren(typeof(IWeapon))){ if(weapon.gameObject.name == "Left weapon"){ leftWeapon = weapon; leftWeapon.soundManager = soundManager; }else if(weapon.gameObject.name == "Right weapon"){ rightWeapon = weapon; rightWeapon.soundManager = soundManager; } } StartCoroutine("RegenerateEnergy"); }
public void CalculateFitness(CudaDeviceVariable <byte> population, CudaDeviceVariable <float> fitness) { Profiler.Start("Calculate accuracy"); var deviceAccuracy = accuracyCalc.CalculateAccuracy(population); Profiler.Stop("Calculate accuracy"); float[] asdf = deviceAccuracy; Profiler.Start("Calculate vectorSizes"); countVectorsKernel.Calculate(population, vectorSizes); Profiler.Stop("Calculate vectorSizes"); int[] v = vectorSizes; Profiler.Start("Avrage VectorSizes"); float avrageVectorSize = Thrust.Avrage(vectorSizes); Profiler.Stop("Avrage VectorSizes"); Profiler.Start("Avrage accuracy"); float avrageAccuracy = Thrust.Avrage(deviceAccuracy); Profiler.Stop("Avrage accuracy"); Profiler.Start("fittness kernel"); fitnessKernel.Run( deviceAccuracy.DevicePointer, avrageAccuracy, vectorSizes.DevicePointer, avrageVectorSize, fitness.DevicePointer ); Profiler.Stop("fittness kernel"); }
private void SpawnRocket() { GameObject rocket = Instantiate(RocketPref, transform.position, new Quaternion(0, 0, 0, 0)) as GameObject; Thrust thrust = rocket.GetComponent <Thrust>(); RocketsLaunched++; thrust.rigidBody.gravityScale = gravityStart + gravityGrow * RocketsLaunched + Random.value * gravitySpread; switch (launchMode) { case LaunchMode.City: thrust.SetImpulse(RocketImpulse(thrust, TargetPoint.transform.position, DistanceSpread, MinHeight, MaxHeight)); break; case LaunchMode.UFO: thrust.SetImpulse(RocketImpulse(thrust, UFO.transform.position)); var sprite = rocket.GetComponent <SpriteRenderer>(); sprite.color = new Color(1, 0.4f, 0.4f); break; default: break; } launchMode = LaunchMode.None; }
public Engine(Dictionary <RenderingPaneHwndDescription> renderingPaneHwndDescriptions) { Console.WriteLine("\nMojo initializing...\n"); D3D11.Initialize(out mDxgiFactory, out mD3D11Device); Cuda.Initialize(mD3D11Device); Thrust.Initialize(); Segmenter = new Segmenter { Interop = new Interop.Segmenter(mD3D11Device, mD3D11Device.ImmediateContext, Constants.Parameters) }; Viewers = new Dictionary <Viewer> { { "Segmenter2D", new Viewer { RenderingPane = new RenderingPane(mDxgiFactory, mD3D11Device, mD3D11Device.ImmediateContext, renderingPaneHwndDescriptions.Get("Segmenter2D").Handle, renderingPaneHwndDescriptions.Get("Segmenter2D").Width, renderingPaneHwndDescriptions.Get("Segmenter2D").Height, new Segmenter2D.RenderingStrategy(mD3D11Device, mD3D11Device.ImmediateContext, Segmenter)), UserInputHandler = new Segmenter2D.UserInputHandler(Segmenter) } } }; }
public void CreateNewPopulation() { var tmp = populationGens; populationGens = populationGens2; populationGens2 = tmp; // var b = new FlattArray<byte>((byte[])populationGens, genLength).To2d(); Profiler.Start("Calculate fitness"); fitnessCalc.CalculateFitness(populationGens, deviceFitnes); Profiler.Stop("Calculate fitness"); Profiler.Start("sqauance"); Thrust.seaquance(fitnessIndeces); Profiler.Stop("sqauance"); Profiler.Start("sorting fitness"); Thrust.sort_by_key(deviceFitnes, fitnessIndeces); Profiler.Stop("sorting fitness"); Profiler.Start("performing genetics"); // var c = new FlattArray<byte>((byte[])populationGens, genLength).To2d(); performGeneticAlgorythm.Run( populationGens.DevicePointer, populationGens2.DevicePointer, deviceFitnes.DevicePointer, fitnessIndeces.DevicePointer ); //var a = new FlattArray<byte>((byte[])populationGens, genLength).To2d() ; Profiler.Stop("performing genetics"); }
protected virtual int GetFocusIndex(Chart chart, Thrust thrust) { Frame focusFrame = chart.Frames.Where(f => f.Bar.time == thrust.FocusTime).FirstOrDefault(); int focusIndex = chart.Frames.IndexOf(focusFrame); return(focusIndex); }
public void Deinit() { // Environment StaticAirTemperature.Remove(); StaticPressure.Remove(); // Orbit Apoapsis.Remove(); Periapsis.Remove(); TimeToApoapsis.Remove(); // Vessel Altitude.Remove(); AngularVelocity.Remove(); AvailablePosTorque.Remove(); AvailableRCSForce.Remove(); AvailableThrust.Remove(); AvailableTorque.Remove(); Direction.Remove(); DryMass.Remove(); Forward.Remove(); Mass.Remove(); MaxVacuumThrust.Remove(); MomentOfInertia.Remove(); Position.Remove(); Right.Remove(); Thrust.Remove(); Up.Remove(); VacuumSpecificImpulse.Remove(); Velocity.Remove(); }
protected override void OnRender(DrawingContext context) { base.OnRender(context); context.DrawLine(baselinePen, angleLeftLeft, angleLeftRight); //context.DrawText(warningFormattedText, new Point(ActualWidth/2, ActualHeight/2)); context.DrawLine(baselinePen, angleRightLeft, angleRightRight); context.DrawLine(baselinePen, directionLineLeftBoundTop, directionLineLeftBoundBottom); context.DrawLine(baselinePen, directionLineRightBoundTop, directionLineRightBoundBottom); context.DrawLine(baselinePen, directionTop, directionBottom); RenderGauge(context, Humidity.ToString("0.00"), 2, humidityFormattedText); RenderGauge(context, Temperature.ToString("0.00"), 6, temperatureFormattedText); RenderGauge(context, Fps.ToString("0.0"), 18, fpsFormattedText); RenderGauge(context, Voltage.ToString("0.00"), 4, voltageFormattedText); RenderGauge(context, Current.ToString("0.00"), 16, currentFormattedText); RenderGauge(context, Thrust.ToString("0"), 10, thrustFormattedText); RenderGauge(context, Salinity.ToString("0.00"), 8, salinityFormattedText); RenderGauge(context, Depth.ToString("0.00"), 12, depthFormattedText); RenderGauge(context, ExtTemp.ToString("0.00"), 14, extTempFormattedText); RenderDepthGauge(context); RenderBatteryBar(context); if (ScreenshotAck == true) { RenderCTDValues(context, "Captured!", 2, screenshotFormattedText); } RenderCompass(context); RenderFalseHorizon(context); //RenderMap(context); //RenderLocation(context); }
/// <summary> /// /// </summary> /// <param name="tradeId"></param> /// <param name="takeProfitPrice"></param> /// <param name="stopLossPrice"></param> /// <returns></returns> protected virtual async Task UpdateOpenTrade(Thrust thrust, long tradeId, double?takeProfitPrice, double?stopLossPrice, int?places) { // create patch Dictionary <string, string> patchData = new Dictionary <string, string>(); if (takeProfitPrice.GetValueOrDefault() > 0) { patchData.Add("takeProfit", takeProfitPrice.ToString()); } if (stopLossPrice.GetValueOrDefault() > 0) { patchData.Add("stopLoss", stopLossPrice.ToString()); } TradeData response = null; // send patch if (patchData.Count > 0) { try { response = await Rest.PatchTradeAsync(_accountId, tradeId, patchData); } catch (Exception e) { throw e; } DateTime transactionTime = Convert.ToDateTime(response.time).ToUniversalTime(); thrust.SetOrUpdatePrices(null, takeProfitPrice, stopLossPrice, places, transactionTime); } }
public override void AddedToFieldHook() { base.AddedToFieldHook(); //Strategy that does not automatically rotate but instead, needs to be rotated manually TargetRotationStrategy = new TargetAngleRotation ( owner: this , verticalOrientation: Direction.Vertical , angleDeltaCount: 320 , maxAngleDegrees: 360 ); //Initialization of the default Shooting parameters via strategy AddStrategy(new Shooting ( owner: this , shootingInterval: 7 , weaponCallback: () => Weapon , bulletFocusPosition: () => BulletFocusPosition , angleCallback: () => TargetRotationStrategy.CurrentAngleDegrees ) { IsShooting = true }); AddStrategy(TargetRotationStrategy); //Custom Thrust WaveghostThrust = new Thrust(this); }
protected virtual Thrust ValidateThrust(Thrust thrust) { // consider filtering out thrusts that have the same SignalTime as previous thrusts // if the FocusPrice isn't a breakout return(thrust); }
public static void CalculateNeabours <T> (CudaContext context, DeviceDataSet <T> teaching, DeviceDataSet <T> test, CudaDeviceVariable <int> calculatedNeabours, int threadsPerBlock ) where T : struct { var kernel = context.LoadKernel("kernels/VectorReduction.ptx", "calculateNearestNeabours"); kernel.GridDimensions = test.length / threadsPerBlock + 1; kernel.BlockDimensions = threadsPerBlock; kernel.SetConstantVariable("testVectorsCount", test.length); kernel.SetConstantVariable("teachingVectorsCount", teaching.length); kernel.SetConstantVariable("attributeCount", teaching.attributeCount); using (var deviceDistanceMemory = new CudaDeviceVariable <float>(teaching.length * test.length)) { kernel.Run( teaching.vectors.DevicePointer, test.vectors.DevicePointer, deviceDistanceMemory.DevicePointer, calculatedNeabours.DevicePointer ); Thrust.sort_by_key_multiple(deviceDistanceMemory, calculatedNeabours, teaching.length, test.length); } }
public override IPattern DetectPattern(Chart chart) { _chart = chart; // first, check db Thrust thrust = GetActiveThrust(); // second, detect if (thrust == null) { thrust = DetectThrust(); } _chart.Patterns.RemoveAll(p => p.Type == MACC.Constants.SignalType.Thrust); if (thrust != null) { SetFocusPrice(thrust); thrust = ValidateThrust(thrust); } if (thrust != null) { _chart.Patterns.Add(thrust); } return(thrust); }
/// <summary> /// Calculate the force ratio from acceleration. /// </summary> /// <param name="blockAccel">Acceleration</param> /// <returns>Force ratio</returns> private Vector3 ToForceRatio(Vector3 blockAccel) { Vector3 result = Vector3.Zero; if (blockAccel.X > 0f) { result.X = blockAccel.X * Block.Physics.Mass / Thrust.GetForceInDirection(Base6Directions.GetFlippedDirection(Block.CubeBlock.Orientation.Left)); } else if (blockAccel.X < 0f) { result.X = blockAccel.X * Block.Physics.Mass / Thrust.GetForceInDirection(Block.CubeBlock.Orientation.Left); } if (blockAccel.Y > 0f) { result.Y = blockAccel.Y * Block.Physics.Mass / Thrust.GetForceInDirection(Block.CubeBlock.Orientation.Up); } else if (blockAccel.Y < 0f) { result.Y = blockAccel.Y * Block.Physics.Mass / Thrust.GetForceInDirection(Base6Directions.GetFlippedDirection(Block.CubeBlock.Orientation.Up)); } if (blockAccel.Z > 0f) { result.Z = blockAccel.Z * Block.Physics.Mass / Thrust.GetForceInDirection(Base6Directions.GetFlippedDirection(Block.CubeBlock.Orientation.Forward)); } else if (blockAccel.Z < 0f) { result.Z = blockAccel.Z * Block.Physics.Mass / Thrust.GetForceInDirection(Block.CubeBlock.Orientation.Forward); } //Log.DebugLog("accel: " + localAccel + ", force ratio: " + result + ", mass: " + Block.Physics.Mass, "ToForceRatio()"); return(result); }
/// <summary> /// Stop movement and rotation of the controller. /// </summary> /// <param name="enableDampeners">If true, dampeners will be enabled. If false, they will not be toggled.</param> public void MoveAndRotateStop(bool enableDampeners = true) { if (enableDampeners) { SetDamping(true); } if (m_stopped) { Log.TraceLog("already stopped"); return; } Log.DebugLog("stopping movement and rotation, dampeners: " + enableDampeners); m_moveForceRatio = m_moveAccel = Vector3.Zero; StopRotate(); MyAPIGateway.Utilities.TryInvokeOnGameThread(() => { Block.Controller.MoveAndRotateStopped(); Thrust.ClearOverrides(); //m_gyro.ClearOverrides(); }); m_stopped = true; }
void Start() { rb = GetComponent <Rigidbody>(); falcon = GetComponent <Thrust>(); position = transform.position; mat = gameObject.GetComponent <Renderer>().material; }
public void MaxfTest() { var context = new CudaContext(); var data = new float[] { 2, 5, 8, 9, 6, 3, 5, 4, 0, 8, 8 }; float max = Thrust.Max(data); Assert.AreEqual(9, max); }
public void MinfTest() { var context = new CudaContext(); var data = new float[] { 2, 5, 8, 9, 6, 3, 5, 4, 0, 8, 8 }; float min = Thrust.Min(data); Assert.AreEqual(0, min); }
public override IPattern BuildPattern(Chart chart, IPattern pattern) { Thrust thrust = (Thrust)pattern; SetThrustFocus(chart, thrust); SetThrustActive(chart, thrust, true); return(thrust); }
public Solution Clone() { var s = new Solution(); Thrust.CopyTo(s.Thrust, 0); Angle.CopyTo(s.Angle, 0); s._score = -1; return(s); }
/// <summary> /// Utworzenie instancji i inicjalizacja komponentów GUI. /// </summary> public ShowBallistics() { Engine e = new Engine(); _ph = new PropertyHolder(e, "Tpeak"); _burnRate = new BurnRate(_ph); _thrust = new Thrust(_ph); InitializeComponent(); }
public void AvrageFloatTest() { using (var context = new CudaContext()) { var data = new float[] { 2, 5, 8, 9, 6, 3, 5, 4, 0, 8, 8 }; float avg = Thrust.Avrage(data); Assert.AreEqual((float)data.Average(), avg); } }
public void MaxiTest() { using (var context = new CudaContext()) { var data = new int[] { 2, 5, 8, 8, 6, 3, 5, 4, 0, 8, 8 }; int max = Thrust.Max(data); Assert.AreEqual(8, max); } }
protected virtual Thrust SetFocusPrice(Thrust thrust) { // set the focus price IPatternFactory thrustFactory = ObjectBase.Container.GetExportedValue <IPatternFactory>("ThrustFactory"); thrustFactory.Initialize(_parameters); thrust = (Thrust)thrustFactory.BuildPattern(_chart, thrust); return(thrust); }
public override string ToString() { var thrust = Shield ? "SHIELD" : (Boost ? "BOOST" : Thrust.ToString()); if (string.IsNullOrEmpty(Message)) { return($"{Target} {thrust}"); } return($"{Target} {thrust} {Message}"); }
public void Dispose() { Viewers.Internal.Values.ToList().ForEach(viewer => viewer.Dispose()); Segmenter.Dispose(); Thrust.Terminate(); Cuda.Terminate(); D3D11.Terminate(ref mDxgiFactory, ref mD3D11Device); Console.WriteLine("\nMojo terminating...\n"); }
public override int GetHashCode() { unchecked { var hashCode = 1170092085; hashCode = hashCode * -1521134295 + Position.GetHashCode(); hashCode = hashCode * -1521134295 + Thrust.GetHashCode(); hashCode = hashCode * -1521134295 + Speed.GetHashCode(); return(hashCode); } }
/// <summary> /// 创建发动机推力 /// </summary> /// <param name="name">名称</param> /// <param name="description">描述</param> /// <returns></returns> public static Thrust CreateThrust(string name, string description) { var thrust = new Thrust { Name = name, Description = description }; thrust.GenerateNewIdentity(); return thrust; }
private void InitializeComponent() { Font = UI.NORMAL.Font; _burnRate = new BurnRate(_ph); _thrust = new Thrust(_ph); Controls.Add(UpperPanel()); Controls.Add(ControlPanel()); ClientSize = new System.Drawing.Size(INITIAL_WIDTH, INITIAL_HEIGHT); Text = "Efekt tPeak(4)"; }
protected virtual Thrust SetThrustFocus(Chart chart, Thrust thrust) { Frame reactionFrame = chart.Frames.Where(f => f.Bar.time == thrust.SignalTime).FirstOrDefault(); int reactionIndex = chart.Frames.IndexOf(reactionFrame); IPriceBar focusBar = null; double focusPrice = thrust.Direction == EPatternDirection.Up ? reactionFrame.Bar.highMid : reactionFrame.Bar.lowMid; List <Frame> afterFocusFrames = new List <Frame>(); for (int i = reactionIndex + 1; i < chart.Frames.Count; i++) { Frame frame = chart.Frames[i]; if (thrust.Direction == EPatternDirection.Up) { if (frame.Bar.highMid > focusPrice) { thrust.ReactionToFocusSpan = i - reactionIndex; focusBar = frame.Bar; focusPrice = frame.Bar.highMid; afterFocusFrames.Clear(); } else { afterFocusFrames.Add(frame); } } else { if (frame.Bar.lowMid < focusPrice) { thrust.ReactionToFocusSpan = i - reactionIndex; focusBar = frame.Bar; focusPrice = frame.Bar.lowMid; afterFocusFrames.Clear(); } else { afterFocusFrames.Add(frame); } } } // update FocusTime and FocusPrice bool reactionBarIsFocusBar = focusBar == null; thrust.FocusTime = reactionBarIsFocusBar ? reactionFrame.Bar.time : focusBar.time; thrust.FocusPrice = focusPrice; return(thrust); }
public override IPattern UpdatePattern(Chart chart, IPattern pattern) { Thrust thrust = (Thrust)pattern; SetThrustRetracementExtrema(chart, thrust); SetThrustFillZoneReached(chart, thrust); SetThrustTakeProfitZoneReached(chart, thrust); SetThrustFocus(chart, thrust); SetThrustActive(chart, thrust, false); return(thrust); }
protected override void OnUpdate() { var thrustData = GetComponentDataFromEntity <Thrust>(isReadOnly: false); Entities .WithAll <Enabling>() .ForEach((in Engine engine, in Parent parent) => { Thrust thrust = thrustData[parent.Value]; thrust.Forward += engine.ForwardThrust; thrust.Turning += engine.TurningThrust; thrustData[parent.Value] = thrust; })
void Start(){ // Find our Thrust component thrust = GetComponent<Thrust>(); }