private async void BtnGenerate_Click(object obj) { IsBtnGenerateEnable = false; IsBtnResolveEnable = false; ForestGrowParameters p = new ForestGrowParameters { ExportDirectoryPath = ExportFolder, ExportToJson = true, ResolutionFeatureName = ResolutionFeatureName, ItemSubsetCountRatio = TrainingSubsetCountRatio, TrainingDataPath = TrainingSet, MaxItemCountInCategory = MaxNumberOfTainingItemsInCategory, TreeCount = NumberOfTrees, SplitMode = SplitMode.GINI }; if (_forest == null) { _forest = ForestFactory.Create(); _forest.TreeBuildComplete += _forest_TreeBuildComplete; _forest.ForestGrowComplete += _forest_ForestGrowComplete; } try { int x = await _forest.GrowAsync(p); //int x = _forest.Grow(p); } catch (Exception ex) { } }
public void SetUp() { forest = new Forest(); // forest.CurrentSeason = forest.GetSeason(DateTime.Now); forest.Add(TypeOfTree.Fir); first = forest.TreesInForest[0]; }
public void OnNewState(IForest forest) { Console.Clear(); var size = forest.GetForestSize(); var width = size.Y; var rows = forest.GetPoints(); var enumerator = rows.GetEnumerator(); var j = 0; while (enumerator.MoveNext()) { if (j == width) { j = 0; Console.WriteLine(); } var e = enumerator.Current; char c; if (!artistsView.TryGetValue(e, out c)) { c = e[0]; } Console.Write(c); j++; } Console.Write("\n\n"); WriteNames(forest); }
public void Tick(IForest forest) { var moves = 0; var gridContents = forest.GridContents(Location); while (moves < 3 && CheckGridAtLocationFor <ITree>(gridContents)) { var spotPossibilities = GetAdjacentSpots(forest.Bound); var desiredSpot = spotPossibilities[_numberGeneratorService.GetNextRandomOfBound(spotPossibilities.Count - 1)]; Location = desiredSpot; moves++; gridContents = forest.GridContents(Location); } if (gridContents == null) { return; } var trees = gridContents.Where(o => o is ITree).ToList(); if (trees.Any()) { CutDown(forest, (ITree)trees.First()); } }
public bool TryGetValue(uint id, out IForest forest) { lock (forests) { return(forests.TryGetValue(id, out forest)); } }
/// <summary> /// Constructor /// </summary> /// <remarks> /// It is private because the class is a singleton. /// </remarks> private TileFactory() { this.mountain = new Mountain(); this.lowland = new Lowland(); this.forest = new Forest(); this.sea = new Sea(); this.desert = new Desert(); }
public void StartTrackingForest(IForest forest, INumberGeneratorService numberGeneratorService = null) { Forest = forest; _numberGeneratorService = numberGeneratorService ?? new RandomNumberGeneratorService(new Random()); Year = 0; Month = 1; Forest.InitializeForest(); }
private void WriteNames(IForest forest) { foreach (var creature in forest.GetCreatures()) { Console.WriteLine("{0} - {1} with {2} lifes", creature.GetSquareCode()[0], creature.GetSquareCode(), creature.GetAmountOfLifes()); } }
public ForestDepleteAction(IForest forest, DateTime time, IForestManager forestManager, IRegionManager regionManager, ILocker locker) { this.forestManager = forestManager; this.regionManager = regionManager; this.locker = locker; Forest = forest; Time = time; }
public void CutDown(IForest forest, ITree tree) { switch (tree.Age) { case TreeAge.Tree: forest.Lumber += 1; forest.Remove(tree); break; case TreeAge.ElderTree: forest.Lumber += 2; forest.Remove(tree); break; } }
public void RemoveForest(IForest forest) { lock (forests) { if (!forests.TryRemove(forest.ObjectId, out forest)) { return; } forest.BeginUpdate(); world.Regions.Remove(forest); forest.EndUpdate(); dbManager.Delete(forest); } }
public void Tick(IForest forest) { _monthsOld++; if (Age == TreeAge.Sapling) { if (_monthsOld > 12) { Age = TreeAge.Tree; } else { return; } } if (Age == TreeAge.Tree && _monthsOld > 120) { Age = TreeAge.ElderTree; } if ((Age == TreeAge.Tree && NumberGeneratorService.GetNextRandomInRange(1, 10) == 1) || //Flat 10% chance Age == TreeAge.ElderTree && NumberGeneratorService.GetNextRandomInRange(1, 10) <= 2) //Flat 20% chance { var assigned = false; var spotPossibilities = GetAdjacentSpots(forest.Bound); while (!assigned && spotPossibilities.Count > 0) { var spotIndex = NumberGeneratorService.GetNextRandomOfBound(spotPossibilities.Count); var checkSpot = spotPossibilities[spotIndex]; spotPossibilities.RemoveAt(spotIndex); if (forest.IsOpenSpot(checkSpot.X, checkSpot.Y)) { assigned = true; _saplingGeneratorService.CreateSapling(forest, checkSpot.X, checkSpot.Y); } } } }
public override void Tick(IForest forest) { var moves = 0; var gridContents = forest.GridContents(Location); while (moves < 5 && CheckGridAtLocationFor <ILumberJack>(gridContents)) { var spotPossibilities = GetAdjacentSpots(forest.Bound); var desiredSpot = spotPossibilities[NumberGeneratorService.GetNextRandomOfBound(spotPossibilities.Count - 1)]; Location = desiredSpot; moves++; gridContents = forest.GridContents(Location); } if (gridContents != null) { var lumberJacks = gridContents.Where(o => o is ILumberJack).ToList(); if (lumberJacks.Any()) { Maul(forest, (ILumberJack)lumberJacks.First()); } } }
public void CreateSapling(IForest forest, int x, int y) { forest.AddForestObject(new Tree(x, y, this)); }
public ForestDepleteAction CreateForestDepleteAction(IForest forest, DateTime time) { return(new ForestDepleteAction(forest, time, kernel.Get <IForestManager>(), kernel.Get <IRegionManager>(), kernel.Get <ILocker>())); }
public virtual void Tick(IForest forest) { }
public void SetUp() { double deltaHeight = 1.2; int needleLength = 11; int numberOfCones = 24; forest = new Forest(); forest.BornFirTree(deltaHeight, needleLength, numberOfCones); firTree = forest.FirTrees[0]; }
public void Maul(IForest forest, ILumberJack lumberJack) { forest.Maulings += 1; forest.Remove(lumberJack); }
public virtual double GetLumbermillCampBuildTime(int campBuildTime, IStructure lumbermill, IForest forest, ITileLocator tileLocator) { var distance = tileLocator.TileDistance(lumbermill, forest); return(BuildTime(campBuildTime, lumbermill.City, lumbermill.City.Technologies) + distance * 5); }
public ForestNumerable(IForest <Tnode> forest) { this.forest = forest.trees; }
public void SetUp() { forest = new Forest(); firTree = new FirTree(); }
public void DbLoaderAdd(IForest forest) { objectIdGenerator.Set(forest.ObjectId); forests.TryAdd(forest.ObjectId, forest); }