public static void d(string tag, string msg) { if (LOG_ENABLE) { Log.Debug(tag, msg); } }
protected override void Write(LogEventInfo logEvent) { var logMessage = this.Layout.Render(logEvent); if (logEvent.Level.Equals(LogLevel.Info)) { Log.Info(logEvent.LoggerName, logMessage); return; } if (logEvent.Level.Equals(LogLevel.Debug)) { Log.Debug(logEvent.LoggerName, logMessage); return; } if (logEvent.Level.Equals(LogLevel.Warn)) { Log.Warn(logEvent.LoggerName, logMessage); return; } if (logEvent.Level.Equals(LogLevel.Error)) { Log.Error(logEvent.LoggerName, logMessage); return; } }
public override double AssessShot(SmoothedList <float> distancesDodged, List <TimeSpan> timestamps, IncomingRangedAttack incoming) { var effectiveDodge = distancesDodged.Last() / DistanceForOneSigma / (1.0 + 0.01 * incoming.DodgeCompensationBonus); var bellCurveDieRoll = Accord.Statistics.Distributions.Univariate.NormalDistribution.Random(); var resultScore = incoming.BaseZScore - effectiveDodge - bellCurveDieRoll; Log.Debug("Evasion|AssessShot", $"Resolved an evasion attempt with a {((resultScore > 0) ? "hit" : "miss")} ({resultScore:f2}) based on an EffectiveDodge of {effectiveDodge:f2} and a random dodge of {bellCurveDieRoll:f2}."); return(resultScore); }
protected async void PerformSpellSelection() { if (GlyphCastStage.CurrentGlyph != null) { GlyphCastStage.CurrentGlyph.Deactivate(); GlyphCastStage.CurrentGlyph = null; } SpellDefinition ChosenSpell = null; //useVolumeTrigger = false; try { //Log.Debug("SpellSelection", $"Diagnostics: #sensors {Res.NumSensors}; CurrentStage {(CurrentStage as GestureRecognizerStage)?.Label}; Background stages activity: {BaseActivity.BackgroundStages?.Select(s => $"{(s as GestureRecognizerStage)?.Label}:{s.IsActive}").Join()}"); var MagnitudeGlyph = await new GlyphCastStage(Glyph.MagnitudeGlyphs, Glyph.StartOfSpell, 2.0).AwaitResult(); double timeCoefficient = (MagnitudeGlyph == Glyph.L) ? 4.0 : (MagnitudeGlyph == Glyph.M) ? 1.5 : (MagnitudeGlyph == Glyph.H) ? -2.0 : -5.0; // for Magnitude == Glyph.G var SpellTypeGlyph = await new GlyphCastStage(Glyph.SpellTypeGlyphs, MagnitudeGlyph, timeCoefficient).AwaitResult(); // Now figure out what possible third "key" glyphs exist given our spell list. var PossibleSpells = SpellDefinition.AllSpells .Where(s => s.Magnitude == MagnitudeGlyph && s.SpellType == SpellTypeGlyph) .ToDictionary(s => s.KeyGlyph); var KeyGlyph = await new GlyphCastStage(PossibleSpells.Keys, SpellTypeGlyph, timeCoefficient).AwaitResult(); ChosenSpell = PossibleSpells.GetValueOrDefault(KeyGlyph); // Now that we know that... var lastGlyph = KeyGlyph; var RemainingGlyphs = ChosenSpell.Glyphs.Skip(3); // The three we already extracted above, of course. foreach (var glyph in RemainingGlyphs) { await new GlyphCastStage(glyph, lastGlyph, timeCoefficient).AwaitResult(); lastGlyph = glyph; } Task.Run(() => ChosenSpell?.OnCast(Current)) // Passing the Activity allows us to ask it to do things (like animate properties or other UI stuff) .LaunchAsOrphan($"Effects of {ChosenSpell.SpellName}"); //Finish(); } catch (TaskCanceledException) { //ChosenSpell?.FailResult?.Invoke(null); Log.Debug("GlyphCast", $"Spell selection / casting cancelled during glyph casting."); //Finish(); } finally { useVolumeTrigger = true; } }
public void Debug(string d) { if (d == null) { d = _defaultLogString; } AndroidLog.Debug(_target, d); CrashlyticsLog(d); if (FileExtensiveLogs) { Writer.Write(d); } }
public void Debug(Exception e) { if (!string.IsNullOrEmpty(e.Message)) { AndroidLog.Debug(_target, e.Message); } if (!string.IsNullOrEmpty(e.StackTrace)) { AndroidLog.Debug(_target, e.StackTrace); } CrashlyticsLog(e); Writer.Write(e); }
private async void DoTimeoutLoop() { while (Provider.IsActive) { await Task.Delay(1000); if (!SessionActive) { ClearDataOlderThan(TimeSpan.FromSeconds(1)); if (Provider.Interval > InitialInterval + TimeSpan.FromMilliseconds(120)) { // Lagging! Log.Debug(_tag, $"Excessive lag detected ({Provider.Interval.TotalMilliseconds:f0} ms). Might need to figure out how to reset Provider."); //AccumulatedRuntime += Provider.RunTime; //Provider.Deactivate(); //Provider.Activate(); } } } }
public void Log(LogLevel level, string format, object param1, object param2) { switch (level) { case LogLevel.Debug: AndroidLog.Debug(_name, format, param1, param2); break; case LogLevel.Info: AndroidLog.Info(_name, format, param1, param2); break; case LogLevel.Warn: AndroidLog.Warn(_name, format, param1, param2); break; case LogLevel.Error: AndroidLog.Error(_name, format, param1, param2); break; } }
public void Log(LogLevel level, object message) { var s = message.ToString(); switch (level) { case LogLevel.Debug: AndroidLog.Debug(_name, s); break; case LogLevel.Info: AndroidLog.Info(_name, s); break; case LogLevel.Warn: AndroidLog.Warn(_name, s); break; case LogLevel.Error: AndroidLog.Error(_name, s); break; } }
protected override void Debug(ILog log, string message, object extraData, LogData logData, DateTime time) { Log.Debug(Tag, message); }
protected void LoadHackingClassifier() { foreach (var option in new string[] { HACKING }) // Might want to add more classifiers later on. { try { ClassifierTree cTree = null; string contents; AssetManager assets = this.Assets; var filename = $"{option}.{Classifier.FileExtension}"; var filepath = $"{GetExternalFilesDir(null)}/{filename}"; try { using (var streamReader = new StreamReader(filepath)) { contents = streamReader.ReadToEnd(); cTree = Serializer.Deserialize <ClassifierTree>(contents); if (cTree != null) { Log.Debug("Loading classifier", $"Loading our {option} classifier tree (from phone-specific file)"); } } } catch (Exception) { cTree = null; } if (cTree == null) { using (StreamReader sr = new StreamReader(assets.Open(filename))) { contents = sr.ReadToEnd(); cTree = Serializer.Deserialize <ClassifierTree>(contents); if (cTree != null) { Log.Debug("Loading classifier", $"Loaded our {option} classifier tree (from asset file)."); } } } if (cTree == null) { throw new Exception($"Classifier deserialization failed - filename {filepath}"); } CueClassifiers[option] = cTree.MainClassifier; if (option == HACKING) { Classifier = cTree.MainClassifier; } Dataset = new DataSet <DKS> { Name = cTree.MainClassifier.MatchingDatasetName }; foreach (var gClass in cTree.GestureClasses) { Dataset.AddClass(gClass); } SelectedGestureClass = Dataset.Classes.FirstOrDefault(); } catch (Exception ex) { Log.Debug("MachineLearning|Load Classifier", ex.ToString()); Speech.Say("Cannot launch hacking - no hacking classifier found."); Finish(); } } }
public async Task ActOnGestureIndex(int gestureIndex) { if (gestureIndex < 0) { return; // Means it wasn't recognized as any gesture at all. } HackingAction_New chosenAction; try { //Func<HackingAction, bool> mpredicate = (HackingAction h) => //{ // if (h == null) return false; // if (!h.Availability.IsVisible) return false; // if (h.Availability.IsKnownBlocked) return false; // if (h.Gesture == null) return false; // if (h.Gesture == HackGesture.None) return false; // return true; //}; //var ActionsWithGestures = HackingActionsList ////.AllActionsList //.ActionsList.Values ////.Where(h => h != null && h.Availability.IsVisible && !h.Availability.IsKnownBlocked && h.Gesture != null && h.Gesture != HackGesture.None) //.Where(mpredicate); //var ActionsByGesture = ActionsWithGestures.ToDictionary(h => h.Gesture.GestureIndex); //chosenAction = ActionsByGesture.GetValueOr(gestureIndex, null); //Log.Debug(_tag, $"Selected action: {chosenAction.Name}"); var AvailableActions = new List <HackingAction_New>(); if (Map.CurrentLeft != null) { AvailableActions.Add(HackingAction_New.GoLeft); } if (Map.CurrentRight != null) { AvailableActions.Add(HackingAction_New.GoRight); } if (Map.CurrentAbove != null) { AvailableActions.Add(HackingAction_New.GoUp); } if (Map.CurrentBelow != null) { AvailableActions.Add(HackingAction_New.GoDown); } AvailableActions.AddRange(Map.CurrentNode.Actions); var ActionsByGesture = AvailableActions.ToDictionary(h => h.Gesture.GestureIndex); chosenAction = ActionsByGesture.GetValueOr(gestureIndex, null); Log.Debug(_tag, $"Selected action: {chosenAction?.Name}"); } catch (NullReferenceException) { Log.Debug(_tag, $"Null reference exception when trying to construct dictionary."); return; } //if (gestureIndex == HackGesture.RightThenUp.GestureIndex && HackingNavigation.CurrentAction != null) //{ // HackingNavigation.CurrentAction.Cancel(); // PulseImage(HackGesture.RightThenUp.IconID, MostRecentSample.Bitmap); // UpdateListView(); // return; //} //if (chosenAction == null) { Log.Debug(_tag, $"Cannot find action with gesture index {gestureIndex}."); return; } //if (chosenAction.IsSelectable && (HackingNavigation.CurrentAction == null || !Object.ReferenceEquals(chosenAction, HackingNavigation.CurrentAction))) //{ // if (gestureIndex != HackGesture.Typing.GestureIndex) PulseImage(chosenAction.Gesture.IconID, MostRecentSample.Bitmap); // else PulseImage(chosenAction.Gesture.IconID); // No bitmap to pulse // chosenAction.Select(); //} //else //{ // if (gestureIndex != HackGesture.Typing.GestureIndex) PulseImage(chosenAction.Gesture.IconID, MostRecentSample.Bitmap, 500); // else PulseImage(chosenAction.Gesture.IconID, null, 350); // No bitmap to pulse // chosenAction.Execute(); //} //UpdateListView(); PulseImage(HackGesture.IndexedGestures[gestureIndex].IconID, MostRecentSample.Bitmap); // Validate the gesture - are we really allowed to do what's just been requested? if (!Map.CurrentNode.ValidateGesture(HackGesture.IndexedGestures[gestureIndex])) { Map.CurrentNode.OnValidationFailed(HackGesture.IndexedGestures[gestureIndex]); return; } if (chosenAction == HackingAction_New.GoLeft && Map.CurrentLeft != null) { await TransitionNode(HackingMapNode.Dir.Left); } else if (chosenAction == HackingAction_New.GoRight && Map.CurrentRight != null) { if (!Map.CurrentNode.IsBlocking) { await TransitionNode(HackingMapNode.Dir.Right); } else { Speech.Say("Blocked. Clear current ice first."); } } else if (chosenAction == HackingAction_New.GoUp && Map.CurrentAbove != null) { await TransitionNode(HackingMapNode.Dir.Above); } else if (chosenAction == HackingAction_New.GoDown && Map.CurrentBelow != null) { await TransitionNode(HackingMapNode.Dir.Below); } else { Map.ExecutableActionsCounter++; chosenAction?.OnExecute?.Invoke(chosenAction, Map.CurrentNode); await FadeMapView(); UpdateMapView(); } }