protected void CastMeditate() { isMeditateInProcess = true; SpellObject spellObject = null; StatList spellStat = null; spellObject = Data.SpellObjects.GetItemByName("meditate", false); if (spellObject != null) { spellStat = Data.AvatarSpells.GetItemByID(spellObject.ID); } if (spellObject == null || spellStat == null) { Log("WARN", "Can't find spell " + spellObject.Name + "."); return; } if (Data.IsResting) { SendUserCommandStand(); } SendReqCastMessage(spellObject); System.Threading.Thread.Sleep(21000); isMeditateInProcess = false; if (!Data.IsResting) { SendUserCommandRest(); } }
public List <ProtoActivity> TextSearch(string query, int count) { if (query == null || query == "" || count < 1) { return(new List <ProtoActivity>(0)); } StatList <double, ProtoActivity> sortedItems = new StatList <double, ProtoActivity>(new ReverseDoubleComparer(), new NoopCombiner <ProtoActivity>()); foreach (ProtoActivity protoActivity in this.ProtoActivities) { double textQuality = this.stringQueryMatcher.StringScore(protoActivity.Text, query); if (textQuality > 0) { double matchQuality = textQuality + protoActivity.IntrinsicInterest; sortedItems.Add(matchQuality, protoActivity); } } count = Math.Min(count, sortedItems.NumItems); List <ProtoActivity> top = new List <ProtoActivity>(count); for (int i = 0; i < count; i++) { top.Add(sortedItems.GetValueAtIndex(i).Value); } return(top); }
public static void Main(string[] args) { StatXClient statxClient = new StatXClient(); Configuration configuration = statxClient.getConfiguration(); Console.WriteLine("Enter Stat Title"); string statTitle = Console.ReadLine(); string groupName = "StatX-API-Examples"; GroupsApi groupsApi = new GroupsApi(configuration); GroupList groupList = groupsApi.GetGroups(groupName); Group group; if ((groupList == null) || (groupList.Data == null) || (groupList.Data.Count == 0)) { // The group does not exist. Let's create one. Since we are creating the group // the api will add the current user as a member and admin of the group. group = new Group(null, groupName, null); group = groupsApi.CreateGroup(group); } else { // Pick the first group (should be the only one). group = groupList.Data[0]; } // Find the stat by name. If the stat does not exist then create it. // // Note: The stat title is not unique. In general it is not a good idea to use // the stat title as a key to determine whether the stat exists or not. If possible // use the statid instead. StatsApi statsApi = new StatsApi(configuration); StatList statList = statsApi.GetStats(group.Name, statTitle); if ((statList == null) || (statList.Data == null) || (statList.Data.Count == 0)) { // The stat does not exist. Let's create a number stat. HorizontalBarStat horizontalBar = new HorizontalBarStat(); horizontalBar.Title = statTitle; horizontalBar.VisualType = Stat.VisualTypeEnum.HorizontalBars; horizontalBar.Items = getStockInfo(); statsApi.CreateStat(group.Id, horizontalBar); } else { // Pick the first stat (should be the only one) and get the statId from it. string statId = statList.Data[0].Id; HorizontalBarStat horizontalBarStat = (HorizontalBarStat)statList.Data[0]; // Create the stat to update. HorizontalBarStat newHorizontalBardStat = new HorizontalBarStat(); newHorizontalBardStat.Items = getStockInfo(); newHorizontalBardStat.LastUpdatedDateTime = DateTime.Now; statsApi.UpdateStat(group.Id, statId, newHorizontalBardStat); } Console.WriteLine("Last update at: " + DateTime.Now); }
private IEnumerable <int> nChooseK(int maxExclusive, int count) { StatList <int, bool> choices = new StatList <int, bool>(new IntComparerer(), new NoopCombiner <bool>()); if (count > maxExclusive) { count = maxExclusive; } for (int i = 0; i < count; i++) { int randInt = this.generator.Next(maxExclusive - i); int index = randInt; while (true) { int smallerCount = choices.CountBeforeKey(index, true); if (index != randInt + smallerCount) { index = randInt + smallerCount; } else { break; } } choices.Add(index, true); } return(choices.Keys); }
public void Test1() { Engine engine = this.MakeEngine(400); StatList <DateTime, double> efficiencies = this.GetEfficiencies(); this.simulate(engine, efficiencies); }
private List <Datapoint> getDatapoints(IEnumerable <Activity> activities) { StatList <DateTime, int> discoveredCounts = new StatList <DateTime, int>(new DateComparer(), new IntAdder()); foreach (Activity activity in activities) { discoveredCounts.Add(activity.DiscoveryDate, 1); } DateTime minPossibleDate = TimeProgression.AbsoluteTime.StartDate; bool isFirst = false; List <Datapoint> datapoints = new List <Datapoint>(); // compute cumulative values foreach (DateTime when in discoveredCounts.Keys) { if (isFirst) { isFirst = false; } TimeSpan duration = when.Subtract(minPossibleDate); int cumulative = discoveredCounts.CombineBeforeKey(when, true); datapoints.Add(new Datapoint(duration.TotalSeconds, cumulative, 1)); } return(datapoints); }
public void AddPointToStat(GameObject point_Number) { string name = EventSystem.current.currentSelectedGameObject.name; name = name.Replace("_Button", ""); foreach (var stat in attributes) { if (stat.type.ToString() == name) { StatList statList = GameManager.Instance.uiManager.StatsCanvasGO.GetComponent <StatList>(); stat.value.BaseValue += 1; if (stat.type == StatTypes.Stamina) { GetComponent <Health>().addHealthPlayer(BONUS_HEATH_PER_POINT); GameObject.Find("EnergyGlobe").GetComponentInChildren <EnergyGlobeControl>().addEnergyPlayer((int)BONUS_HEATH_PER_POINT); } statList.lvlup_Points -= 1; point_Number.GetComponent <Text>().text = statList.lvlup_Points.ToString(); if (statList.lvlup_Points <= 0) { statList.LevelUpStatButtons.SetActive(false); statList.bLvlupactive = false; } StatTextUpdate(); } } }
public SampleItem() { foreach (var stat in Helpers.List) { StatList.Add(new AdditiveStatClass((float)_rng.NextDouble())); } }
public void AddTotalSaleValue() { StatList.Clear(); StatList.Add(new Statistics(SellingTotal(), "Indkomst")); StatList.Add(new Statistics(BuyingTotal(), "Udgifter")); StatList.Add(new Statistics((SellingTotal() - BuyingTotal()), "Profit")); StatList.Add(new Statistics(0, "")); }
public T GetValue <T>(StatType type) { if (StatList.TryGetValue(type, out object value)) { return((T)value); } else { return(default);
private StatList ApplyPipeline() { StatList statList = GetCurrentStatList(); foreach (IPipeableEffect effect in effectPipeline) { effect.Pipe(statList); } return(statList); }
protected int Level = 1; //TODO Make own class for this protected Fighter() { resistances = new Elemental_Attributes(); FighterName = "Gladiator"; maxHealth = 100; currentHealth = 100; maxManaPoints = 20; currentManaPoints = 20; statList = new StatList(); }
public void updateStat(StatList e, int value, bool isstun) { switch (e) { case StatList.bravery: updateBraveryStat(value); this.isStun = isstun; break; case StatList.encouragement: updateEncouragementStat(value); this.isStunE = isstun; break; case StatList.trust:; break; } }
private StatList <DateTime, double> GetEfficiencies() { // Suppose efficiency[day[i]] = i StatList <DateTime, double> efficiencies = new StatList <DateTime, double>(new DateComparer(), new FloatAdder()); for (int i = 1; i < 365; i++) { efficiencies.Add(new DateTime(2000, 1, 1).AddDays(i), Math.Pow(1.01, i)); } return(efficiencies); }
private static void GetStatNames(TextAsset cfg) { if (cfg != null) { mStats = StatList.FromJSON(cfg.text); if (mStats == null) { mStats = new List <StatData>(); } } }
public void LevelSystem_OnLevelChanged(object sender, System.EventArgs e) { SetLevelNumber(levelSystem.GetLevelNumber()); GameManager.Instance.player.level = levelSystem.GetLevelNumber(); StatList statlist = GameManager.Instance.uiManager.StatsCanvasGO.GetComponent <StatList>(); statlist.ToggleLevelUp(true); GameManager.Instance.player.GetComponent <Health>().addHealthPlayer(GameManager.Instance.player.BONUS_HEATH_PER_POINT); GameObject.Find("EnergyGlobe").GetComponentInChildren <EnergyGlobeControl>().addEnergyPlayer((int)GameManager.Instance.player.BONUS_HEATH_PER_POINT); GameManager.Instance.player.StatTextUpdate(); }
public void InitializeStats() { StatList statList = GameManager.Instance.uiManager.StatsCanvasGO.GetComponent <StatList>(); UILife = statList.getNumberGameObject("Health"); UIMana = statList.getNumberGameObject("Ressources"); for (int i = 0; i < attributes.Length; i++) { attributes[i].SetParent(this); } StatTextUpdate(); }
public void SetValue(StatType type, object value) { if (!StatList.ContainsKey(type)) { StatList.Add(type, value); } else { StatList[type] = value; } RaiseEvent(); }
private void InitialiseStatList() { try { _stats = (StatList)AssetDatabase.LoadAssetAtPath("Assets/Stats/Common Stat List.asset", typeof(StatList)); } catch (UnityException e) { Debug.Log(e); return; } UpdateDictionary(requirements); UpdateDictionary(rewards); }
public LinearProgression Smoothed(TimeSpan windowSize) { // make a List of the cumulative time spent DateTime minDate = this.Owner.DiscoveryDate; IEnumerable <ListItemStats <DateTime, ParticipationAndSummary> > items = this.searchHelper.AllItems; LinearProgression cumulatives = new LinearProgression(); // first sort the starts and ends StatList <DateTime, double> deltaIntensities = new StatList <DateTime, double>(new DateComparer(), new FloatAdder()); foreach (ListItemStats <DateTime, ParticipationAndSummary> item in items) { deltaIntensities.Add(item.Value.Participation.StartDate, 1); deltaIntensities.Add(item.Value.Participation.EndDate, -1); } if (deltaIntensities.NumItems < 1) { return(new LinearProgression()); } DateTime maxDate = deltaIntensities.GetLastValue().Key; // now add up the (possibly overlapping) values double intensity = 0; DateTime prevDate = minDate; double sum = 0; foreach (ListItemStats <DateTime, double> deltaIntensity in deltaIntensities.AllItems) { double duration = deltaIntensity.Key.Subtract(prevDate).TotalSeconds; sum += intensity * duration; intensity += deltaIntensity.Value; cumulatives.Add(deltaIntensity.Key, sum); prevDate = deltaIntensity.Key; } // find what's in the sliding window by subtracting the cumulative from the shifted cumulative LinearProgression shiftedCumulatives = cumulatives.Shifted(windowSize); if (windowSize.TotalSeconds > 0) { cumulatives.Add(maxDate.Add(windowSize), sum); LinearProgression result = cumulatives.Minus(shiftedCumulatives); return(result); } else { shiftedCumulatives.Add(maxDate, sum); LinearProgression result = shiftedCumulatives.Minus(cumulatives); return(result); } }
private void simulate(Engine engine, StatList <DateTime, double> efficiencies) { for (int i = 0; i < efficiencies.NumItems; i++) { DateTime when = efficiencies.GetValueAtIndex(i).Key; if (engine.Test_ChooseExperimentOption().HasError) { break; // not enough data to run more experiments } // make a list of experiment options List <SuggestedMetric> experimentOptions = engine.ChooseExperimentOptions(when); // Skip setting difficulties for now. // Task difficulties could be set via something like: // experimentOptions[0].PlannedMetric.DifficultyEstimate.NumEasiers++; // Make an experiment ExperimentSuggestion suggestion = engine.Experiment(experimentOptions, when); if (!suggestion.Experiment.Started) { engine.PutExperimentInMemory(suggestion.Experiment); } // Do the suggestion double efficiency = efficiencies.FindPreviousItem(when, false).Value; double duration = 1.0 / efficiency; ActivityDescriptor activityDescriptor = suggestion.ActivitySuggestion.ActivityDescriptor; Activity activity = engine.ActivityDatabase.ResolveDescriptor(activityDescriptor); Metric metric = activity.DefaultMetric; Participation participation = new Participation(when, when.AddDays(duration), activityDescriptor); participation.EffectivenessMeasurement = new CompletionEfficiencyMeasurement(metric, true, 0); participation.EffectivenessMeasurement.DismissedActivity = true; RelativeEfficiencyMeasurement measurement = engine.Make_CompletionEfficiencyMeasurement(participation); participation.EffectivenessMeasurement.Computation = measurement; engine.PutParticipationInMemory(participation); } engine.FullUpdate(); DateTime lastDay = efficiencies.GetLastValue().Key; for (int i = 1; i < efficiencies.NumItems; i++) { ListItemStats <DateTime, double> item = efficiencies.GetValueAtIndex(i - 1); ListItemStats <DateTime, double> nextItem = efficiencies.GetValueAtIndex(i); Distribution estimatedEfficiency = engine.EfficiencySummarizer.GetValueDistributionForDates(item.Key, nextItem.Key, true, false); System.Diagnostics.Debug.WriteLine("True efficiency at " + item.Key + " = " + item.Value + ", estimated efficiency = " + estimatedEfficiency.Mean); } System.Diagnostics.Debug.WriteLine("Test done"); }
public void StatTextUpdate() { StatList statList = GameManager.Instance.uiManager.StatsCanvasGO.GetComponent <StatList>(); foreach (var child in statList.GetComponentsInChildren <StatNumberUpdate>()) { foreach (var stat in attributes) { if (child.type == stat.type) { child.updateStatefield(stat.value.BaseValue, stat.value.ModifiedValue); } } } UILife.GetComponent <Text>().text = this.GetComponent <Health>().MaxHealthPoints.ToString(); UIMana.GetComponent <Text>().text = GameObject.Find("EnergyGlobe").GetComponentInChildren <EnergyGlobeControl>().maxEnergy.ToString(); }
public void ExtractOriginals() { foreach (var tile in TileCodes) { var path = $@"D:\Data\DEM\NZ\{tile}.asc"; var file = NzReader.Read(path); Assert.AreEqual(8192, file.Columns); Assert.AreEqual(8192, file.Rows); Assert.AreEqual(-999, file.NoDataValue); var list = new StatList(); var arr = file.Data; foreach (var index in arr.Indices()) { var value = arr[index]; if (value == file.NoDataValue) { foreach (var neighbour in arr.Neighbours(index)) { var neighbourValue = arr[neighbour]; if (neighbourValue != file.NoDataValue) { list.Add(neighbourValue); } } } } if (list.Any()) { file.ReplaceNoDataValue(list.Average()); } var outputPath = Path.Combine(OutputPath, $"{tile}.npy"); np.save(outputPath, file.Data); using (var stream = File.Create(Path.Combine(OutputPath, $"{tile}.png"))) { new ImageConverter().ToPng(file.Data, stream, HeightToGrayscale.FullRange8(file.Data)); } } }
// Find the top few matching activities public List <Activity> FindBestMatches(ActivityDescriptor descriptor, int count) { if (count < 1) { return(new List <Activity>(0)); } if (count == 1) { Activity best = this.ResolveDescriptor(descriptor); if (best != null) { return new List <Activity>() { best } } ; return(new List <Activity>() { }); } IEnumerable <Activity> activities = this.GetCandidateMatches(descriptor); StatList <double, Activity> sortedItems = new StatList <double, Activity>(new ReverseDoubleComparer(), new NoopCombiner <Activity>()); foreach (Activity activity in activities) { double quality = this.MatchQuality(descriptor, activity); if (quality > 0) { sortedItems.Add(quality, activity); } } count = Math.Min(count, sortedItems.NumItems); List <Activity> top = new List <Activity>(count); for (int i = 0; i < count; i++) { top.Add(sortedItems.GetValueAtIndex(i).Value); } return(top); }
public LinearProgression Minus(LinearProgression other) { StatList <DateTime, double> union = this.searchHelper.Union(other.searchHelper); LinearProgression diff = new LinearProgression(); DateTime prevDate = new DateTime(); foreach (ListItemStats <DateTime, double> item in union.AllItems) { DateTime when = item.Key; if (when == prevDate) { // skip duplicates continue; } // this relies on this.searchHelper.optimizeForLocality = true and other.searchHelper.optimizeForLocality = true for it to be fast double ourValue, theirValue; ourValue = this.GetValueAt(when, false).Value.Mean; theirValue = other.GetValueAt(when, false).Value.Mean; double value = ourValue - theirValue; diff.Add(item.Key, value); } return(diff); }
public void LoadFile() { foreach (var tile in new[] { "BJ", "UB", "UC" }) { var path = $@"D:\Data\DEM\NZ\{tile}.asc"; var file = NzReader.Read(path); Assert.AreEqual(8192, file.Columns); Assert.AreEqual(8192, file.Rows); Assert.AreEqual(-999, file.NoDataValue); var list = new StatList(); var arr = file.Data; foreach (var index in arr.Indices()) { var value = arr[index]; if (value == file.NoDataValue) { foreach (var neighbour in arr.Neighbours(index)) { var neighbourValue = arr[neighbour]; if (neighbourValue != file.NoDataValue) { list.Add(neighbourValue); } } } } file.ReplaceNoDataValue(list.Average()); using (var stream = File.Create($@"D:\Data\DEM\NZ\{tile}.png")) { new ImageConverter().ToPng(file.Data, stream, HeightToGrayscale.FullRange8(file.Data)); } } }
public override void Finish() { this.log("Grouping participations by category"); foreach (KeyValuePair <String, Dictionary <Activity, int> > entry in this.feedbacks) { this.log(""); this.log("Instances of feedback " + entry.Key + ":"); // sort StatList <int, Activity> sorted = new StatList <int, Activity>(new IntComparerer(), null); foreach (KeyValuePair <Activity, int> e2 in entry.Value) { sorted.Add(e2.Value, e2.Key); } // Find the activities that were done often enough to be noteworthy int max = sorted.GetLastValue().Key; int cumulative = 0; int minInterestingKey = 0; List <ListItemStats <int, Activity> > interesting = new List <ListItemStats <int, Activity> >(); foreach (ListItemStats <int, Activity> stats in sorted.AllItems) { cumulative += stats.Key; // Some activities were only done a very small number of times. We skip displaying those because they might be distracting if (cumulative >= max) { interesting.Add(stats); } } // sort the more commonly done activities to the top interesting.Reverse(); foreach (ListItemStats <int, Activity> stats in interesting) { this.log(stats.Value + " : " + stats.Key + " times"); } } base.Finish(); }
public void Change() { StatList.ForEach(x => x.Value += x.ValueIncrease); }
/// <summary> /// Executes a Task 'cast' /// </summary> /// <param name="Task"></param> protected void DoCast(BotTaskCast Task) { SpellObject spellObject = null; StatList spellStat = null; string sureTarget = Task.Target; string sureWhere = Task.Where; // handle selftargeting if (sureTarget.ToLower().Equals(SpellBotConfig.XMLVALUE_SELF)) { if (Data.AvatarObject == null) { Log("WARN", "Cant execute task 'cast' " + Task.Name + ". Technical interruption changed the target."); return; } sureTarget = Data.AvatarObject.Name.ToLower(); sureWhere = SpellBotConfig.XMLVALUE_ROOM; } // try to get the spell from the spells spellObject = Data.SpellObjects.GetItemByName(Task.Name, false); // try to get stat for % value if (spellObject != null) { spellStat = Data.AvatarSpells.GetItemByID(spellObject.ID); } // one not found if (spellObject == null || spellStat == null) { // log Log("WARN", "Cant execute task 'cast'. Spell " + Task.Name + " found."); return; } // handle spells above cap if (spellStat.SkillPoints >= Task.Cap) { if (Task.OnMax.ToLower() == SpellBotConfig.XMLVALUE_QUIT) { // log Log("BOT", "Quitting.. spell " + spellObject.Name + " reached 99%."); // prepare quit IsRunning = false; return; } else if (Task.OnMax.ToLower() == SpellBotConfig.XMLVALUE_SKIP) { // log Log("BOT", "Skipped task 'cast' " + spellObject.Name + " (99%)"); return; } } // spell doesn't need a target if (spellObject.TargetsCount == 0) { // send castreq SendReqCastMessage(spellObject); // log Log("BOT", "Executed task 'cast' " + spellObject.Name); } // speed needs a target else if (spellObject.TargetsCount > 0) { // marked to cast on roomobject if (sureWhere == SpellBotConfig.XMLVALUE_ROOM) { // try to get the target RoomObject roomObject = Data.RoomObjects.GetItemByName(sureTarget, false); // target not found if (roomObject == null) { // log Log("WARN", "Can't execute task 'cast'. RoomObject " + sureTarget + " not found."); return; } // send castreq ReqCastMessage reqCastMsg = new ReqCastMessage( spellObject.ID, new ObjectID[] { new ObjectID(roomObject.ID) }); SendGameMessage(reqCastMsg); // log Log("BOT", "Executed task 'cast' " + spellObject.Name); } // cast on inventory item else if (sureWhere == SpellBotConfig.XMLVALUE_INVENTORY) { // try to get the target InventoryObject inventoryObject = Data.InventoryObjects.GetItemByName(sureTarget, false); // target not found if (inventoryObject == null) { // log Log("WARN", "Can't execute task 'cast'. Item " + sureTarget + " not found."); return; } // send castreq ReqCastMessage reqCastMsg = new ReqCastMessage( spellObject.ID, new ObjectID[] { new ObjectID(inventoryObject.ID) }); SendGameMessage(reqCastMsg); // log Log("BOT", "Executed task 'cast' " + spellObject.Name); } else { // log Log("WARN", "Can't execute task 'cast'. " + sureWhere + " is unknown 'where'."); } } }
public Participation_BinComparison_View(Engine engine, IEnumerable <Activity> activitiesToPredictFrom, Activity activityToPredict, TimeSpan windowSize) { DateTime now = DateTime.Now; engine.EnsureRatingsAreAssociated(); LinearProgression progressionToPredict = activityToPredict.ParticipationsSmoothed((new TimeSpan()).Subtract(windowSize)); StatList <NeighborhoodInterpolation, Activity> results = new StatList <NeighborhoodInterpolation, Activity>(new Neighborhood_MiddleOutputMean_Comparer(), new NoopCombiner <Activity>()); foreach (Activity activity in activitiesToPredictFrom) { System.Diagnostics.Debug.WriteLine("comparing " + activity + " and " + activityToPredict.Name); List <Datapoint> datapoints = activity.compareParticipations(windowSize, progressionToPredict, now.Subtract(windowSize)); // put data into the interpolator FloatRange inputRange = new FloatRange(0, true, windowSize.TotalSeconds, true); AdaptiveLinearInterpolator <Distribution> interpolator = new AdaptiveLinearInterpolator <Distribution>(new HyperBox <Distribution>(new FloatRange[] { inputRange }), new DistributionAdder()); foreach (Datapoint datapoint in datapoints) { interpolator.AddDatapoint(new AdaptiveInterpolation.Datapoint <Distribution>(datapoint.Input, Distribution.MakeDistribution(datapoint.Output, 0, datapoint.Weight))); } // ask the interpolator which input has the highest average output IEnumerable <double[]> representativePoints = interpolator.FindRepresentativePoints(); if (representativePoints.Count() > 0) { double[] bestInput = new double[1]; AdaptiveInterpolation.Distribution bestOutput = null; foreach (double[] coordinates in representativePoints) { AdaptiveInterpolation.Distribution output = interpolator.Interpolate(coordinates); if (bestOutput == null || output.Mean > bestOutput.Mean) { bestInput = coordinates; bestOutput = output; } } // Check nearby regions for their outputs too HyperBox <Distribution> inputNeighborhood = interpolator.FindNeighborhoodCoordinates(bestInput); double inputNeighborhoodWidth = inputNeighborhood.Coordinates[0].Width; double lowerInput = Math.Max(inputNeighborhood.Coordinates[0].LowCoordinate - inputNeighborhoodWidth, inputRange.LowCoordinate); double higherInput = Math.Min(inputNeighborhood.Coordinates[0].HighCoordinate + inputNeighborhoodWidth, inputRange.HighCoordinate); NeighborhoodInterpolation result = new NeighborhoodInterpolation(); result.Middle = new Interpolation(bestInput[0], bestOutput); result.Left = new Interpolation(lowerInput, interpolator.Interpolate(new double[] { lowerInput })); result.Right = new Interpolation(higherInput, interpolator.Interpolate(new double[] { higherInput })); results.Add(result, activity); } } IEnumerable <ListItemStats <NeighborhoodInterpolation, Activity> > resultList = results.AllItems; if (resultList.Count() <= 0) { // This shouldn't be able to happen unless we disallow predicting the activity from itself this.SubLayout = new TextblockLayout("No activities found!"); } else { int numWindowDays = (int)windowSize.TotalDays; GridLayout_Builder layoutBuilder = new Vertical_GridLayout_Builder().Uniform(); if (resultList.Count() > 1) { string title = "Activities that when done most strongly predict future participations in " + activityToPredict.Name; layoutBuilder.AddLayout(new TextblockLayout(title)); } else { string title = "Predicting future participations in " + activityToPredict.Name; layoutBuilder.AddLayout(new TextblockLayout(title)); } string explanation = "A block of the form a->{b,c,d} means that when you have spent an average of <a> min/day on the given activity over the last " + numWindowDays + " days, " + "you have spent on average <c> min/day on " + activityToPredict.Name + " over the next " + numWindowDays + " days, with <b> and <d> marking -1 and +1 standard deviation, respectively"; layoutBuilder.AddLayout(new TextblockLayout(explanation)); int count = 0; foreach (ListItemStats <NeighborhoodInterpolation, Activity> result in resultList.Reverse()) { count++; if (count > 3) { break; } Activity activity = result.Value; NeighborhoodInterpolation neighborhood = result.Key; layoutBuilder.AddLayout(new TextblockLayout("After " + activity.Name + ":")); foreach (Interpolation interpolation in neighborhood.Items) { double inputSecondsPerWindow = interpolation.Input; double inputMinutesPerDay = inputSecondsPerWindow / windowSize.TotalDays / 60; double avgOutputSecondsPerWindow = interpolation.Output.Mean; double avgOutputMinutesPerDay = avgOutputSecondsPerWindow / windowSize.TotalDays / 60; double stddevOutputSecondsPerWindow = interpolation.Output.StdDev; double stddevOutputMinutesPerDay = stddevOutputSecondsPerWindow / windowSize.TotalDays / 60; string itemLine = Math.Round(inputMinutesPerDay, 1) + " -> {" + Math.Round((avgOutputMinutesPerDay - stddevOutputMinutesPerDay), 1) + "," + Math.Round(avgOutputMinutesPerDay, 1) + "," + Math.Round((avgOutputMinutesPerDay + stddevOutputMinutesPerDay), 1) + "}"; layoutBuilder.AddLayout(new TextblockLayout(itemLine)); } } this.SubLayout = layoutBuilder.Build(); } }