public ExecuteCommandExportObjectsToFile(IBasicActivateItems activator, IMapsDirectlyToDatabaseTable[] toExport, DirectoryInfo targetDirectoryInfo = null) : base(activator) { _toExport = toExport; ShowInExplorer = true; _repositoryLocator = activator.RepositoryLocator; _toExport = toExport; TargetDirectoryInfo = targetDirectoryInfo; _shareManager = new ShareManager(_repositoryLocator); if (toExport == null || !toExport.Any()) { SetImpossible("No objects exist to be exported"); return; } _gatherer = new Gatherer(_repositoryLocator); var incompatible = toExport.FirstOrDefault(o => !_gatherer.CanGatherDependencies(o)); if (incompatible != null) { SetImpossible("Object " + incompatible.GetType() + " is not supported by Gatherer"); } }
public void PlaceObject(int index) { if (canPlaceObject) { switch (index) { case 0: GameObject newObject = Instantiate(objectsToPlace.ToArray()[index], placementPose.position, placementPose.rotation); if (gatherer != null) { gatherer.destination = newObject; } break; case 1: if (gatherer == null) { GameObject man = Instantiate(objectsToPlace.ToArray()[index], placementPose.position, placementPose.rotation); gatherer = man.GetComponent <Gatherer>(); } break; case 2: if (storage == null) { // storage = Instantiate(objectsToPlace.ToArray()[index], placementPose.position, placementPose.rotation); } break; default: break; } } }
private void GetAllObjects(IActivateItems activator) { Gatherer g = new Gatherer(activator.RepositoryLocator); //We get these from the child provider because some objects (those below go off looking stuff up if you get them //and do not inject known good values first) foreach (var o in Activator.CoreChildProvider.AllExtractionInformations) { _allObjects.Add(o); } foreach (var o in Activator.CoreChildProvider.AllCatalogueItems) { _allObjects.Add(o); } var dxmChildProvider = Activator.CoreChildProvider as DataExportChildProvider; if (dxmChildProvider != null) { foreach (var o in dxmChildProvider.GetAllExtractableColumns(Activator.RepositoryLocator.DataExportRepository)) { _allObjects.Add(o); } } foreach (var o in g.GetAllObjectsInAllDatabases()) { _allObjects.Add(o); } }
public void GathererDefaultProduceTest() { Gatherer gatherer = new Gatherer(1, new List <ResourceAmount>() { new ResourceAmount("wood", 1), new ResourceAmount("rock", 1) }, new List <ResourceAmount>() { new ResourceAmount("wood", 1), new ResourceAmount("rock", 1), }); Assert.Empty(gatherer.Produce()); gatherer.SwitchState(new WoodcutterState()); var woods = gatherer.Produce(); Assert.Single(woods); Assert.Single(woods.Where(p => p.Type == "wood")); Assert.Equal(1, woods.Where(p => p.Type == "wood").Single().Amount); gatherer.SwitchState(new MinerState()); var rocks = gatherer.Produce(); Assert.Single(rocks); Assert.Single(rocks.Where(p => p.Type == "rock")); Assert.Equal(1, rocks.Where(p => p.Type == "rock").Single().Amount); }
public void Enter(BaseEntity entity) { Console.WriteLine("Entity is now gathering resources."); Gatherer gatherer = entity as Gatherer; gatherer.path.Set(Path.GetPathTo(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)], Material.IDToMaterial(gatherer.matID))); }
public void Enter(BaseEntity entity) { Console.WriteLine("Entity is now storing resources"); Gatherer gatherer = entity as Gatherer; gatherer.path.Set(Path.GetPathTo(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)], GameWorld.instance.tiles.tiles[GameWorld.instance.buildings[0].entrancePosition])); }
internal static HashSet <SqlAlias> Gather(SqlNode node) { Gatherer g = new Gatherer(); g.Visit(node); return(g.Consumed); }
public override void AssignUnit(Unit unit) { base.AssignUnit(unit); //típus validálás Gatherer gatherer = unit as Gatherer; gatherer.SwitchState(new WoodcutterState()); }
/// <summary> /// Constructor for the GameWorld class /// </summary> /// <param name="width">The width of the world</param> /// <param name="height">The height of the world</param> public GameWorld(int width, int height) { instance = this; gameWidth = width; gameHeight = height; // Init the time, graph, grid- and tilessystem time = new Time(); materialCollection = new MaterialCollector(true); graph = new Graph(); grid = new GridSystem(); tiles = new TileSystem(); // Initializations for the tiles-, gridsystem and graph tiles.initTiles(); grid.initGrid(); // A temp NPC to test stuff with Gatherer npc = new Gatherer(new Vector2D(20, 100), // Position 20, // Bounding Radius new Vector2D(0, 0), // Velocity 80, // Max Speed Vector2D.Up, // Heading 1, // Mass new Vector2D(15, 15), // Scale 0.05f, // Turnrate 10, // Max Force 15, // Carry Capacity Material.WOOD.id); // MatID //Gatherer npc2 = new Gatherer(new Vector2D(60, 100), // Position // 20, // Bounding Radius // new Vector2D(0, 0), // Velocity // 80, // Max Speed // Vector2D.Left, // Heading // 1, // Mass // new Vector2D(15, 15), // Scale // 0.05f, // Turnrate // 10, // Max Force // 15, // Carry Capacity // 2); // MatID StorageBuilding storage = new StorageBuilding(new Vector2D(400, 200), new Vector2D(40, 40)); graph.initGraph(); tiles.AddResources(); // Setting the path for the npc to follow //npc.path.Set(Path.GetPathTo(tiles.tiles[TileSystem.GetIndexOfTile(npc.position)], Material.WOOD)); //npc2.path.Set(Path.GetPathTo(tiles.tiles[TileSystem.GetIndexOfTile(npc2.position)], Material.STONE)); // Adding the npc to the world entities.Add(npc); //entities.Add(npc2); storage.SetEntranceEdge(); buildings.Add(storage); }
// Methods internal static Dictionary <SqlAlias, bool> Gather(SqlNode node) { Gatherer gatherer = new Gatherer(); gatherer.Visit(node); return(gatherer.Produced); }
//INTERFACE /// <summary> /// Load statistics configuration from given file. /// Creates gatheres writing configuration to files. /// </summary> /// <param name="statisticsFileName">Name of file to read configuration from.</param> public static void Load(string statisticsFileName) { string progressText = string.Format("Reading statistics gatherers from {0}.", Configuration.Files.StatisticsFile); ProgressLogger.Starting(progressText); gatherers = new List <Gatherer>(); XmlDocument document = new XmlDocument(); document.Load(statisticsFileName); XmlNode main = document[statisticsTag]; foreach (XmlNode node in main.ChildNodes) { switch (node.Name) { case Gatherer.GathererTag: gatherers.Add(Gatherer.Create(node)); break; default: throw new ArgumentException("Unknown XML node: " + node.Name); } } ProgressLogger.Finished(progressText); }
public void TestIfNewGathererIsCreated() { //Arange User user = new User { Username = "******", Password = "******", Email = "*****@*****.**" }; Gatherer gatherer = new Gatherer { CharacterName = "Geri-Nikol", User = user }; //Act users.Add(user); users.SaveChanges(); gatherers.Add(gatherer); gatherers.SaveChanges(); User uResult = users.All().First(x => x.Username.Equals("geri-nikol")); Gatherer result = gatherers.All().First(x => x.UserId.Equals(uResult.Id)); //Assert Assert.IsNotNull(result); }
public void Execute(BaseEntity entity) { Gatherer gatherer = entity as Gatherer; if (gatherer.path.isFinished && !gatherer.noMatsLeft) { if (gatherer.CollectMaterialsFromTile(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)])) { gatherer.path.Set(Path.GetPathTo(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)], Material.IDToMaterial(gatherer.matID))); } else { gatherer.state.ChangeState(StoreResourcesState.instance); } if (gatherer.path.Count == 0) { //if (!gatherer.noMatsLeft) { gatherer.state.ChangeState(StoreResourcesState.instance); //} else { gatherer.noMatsLeft = true; //GameWorld.instance.materialCollection += gatherer.inventory; //gatherer.inventory.Clear(); //} } ResourceGatherer.instance.RedrawBackground(); } }
public override Unit RemoveLastUnit() { var unit = base.RemoveLastUnit(); //elkérni a konkrét unit-ot Gatherer gatherer = unit as Gatherer; gatherer.SwitchState(new FreeState()); return(unit); }
public Flee(Gatherer gatherer, NavMeshAgent navMeshAgent, EnemyDetector enemyDetector, Animator animator, ParticleSystem particleSystem) { _gatherer = gatherer; _navMeshAgent = navMeshAgent; _enemyDetector = enemyDetector; _animator = animator; _particleSystem = particleSystem; }
public RemotePushingService(IRDMPPlatformRepositoryServiceLocator repositoryLocator, IDataLoadEventListener listener) { _repositoryLocator = repositoryLocator; this.listener = listener; remotes = _repositoryLocator.CatalogueRepository.GetAllObjects <RemoteRDMP>(); _gatherer = new Gatherer(_repositoryLocator); _shareManager = new ShareManager(_repositoryLocator); }
public override void AssignUnit(Unit unit) { base.AssignUnit(unit); //típus validálás Gatherer gatherer = unit as Gatherer; //TODO: miner upgrade! gatherer.SwitchState(new MinerState()); }
public Unit CreateUnit() { newUnit = new Gatherer(ConfigurationManager.GetInstance().GetUnitFoodConsume(typeof(Gatherer)), ConfigurationManager.GetInstance().GetAllProductsForProducerUnit(typeof(Gatherer)), ConfigurationManager.GetInstance().GetInitialProductsForProducerUnit(typeof(Gatherer))); ApplyPreviousResearchUpgrades(); return(newUnit); }
private void SendResource(Gatherer g) { if (content > 0) { g.ReceiveResource(material); content--; } }
void GathererBoosts(Gatherer gatherer) { gatherer.woodGatherTime = gatherer.woodGatherTime + gatherTimeWood; gatherer.stoneGatherTime = gatherer.stoneGatherTime + gatherTimeStone; gatherer.metalGatherTime = gatherer.metalGatherTime + gatherTimeMetal; gatherer.grainGatherTime = gatherer.grainGatherTime + gatherTimeGrain; gatherer.genGatherTime = gatherer.genGatherTime + gatherTimeGen; gatherer.gatherAmmount = gatherer.gatherAmmount + gatherAmntGen; }
public void Execute(BaseEntity entity) { Gatherer gatherer = entity as Gatherer; if (gatherer.position.Distance(gatherer.path.end) < 1) { GameWorld.instance.materialCollection += gatherer.inventory; gatherer.inventory.Clear(); gatherer.state.ChangeState(GatherResourceState.instance); } }
public void TestPlugin_OrphanImport_Sharing() { //Setup the load module we want to test (with plugin parent) var fi = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah2." + PackPluginRunner.PluginPackageSuffix)); File.WriteAllBytes(fi.FullName, new byte[] { 0x1, 0x2 }); var fi2 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah2." + PackPluginRunner.PluginPackageSuffix)); File.WriteAllBytes(fi2.FullName, new byte[] { 0x1, 0x2 }); var fi3 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah3." + PackPluginRunner.PluginPackageSuffix)); File.WriteAllBytes(fi3.FullName, new byte[] { 0x3, 0x4 }); Core.Curation.Data.Plugin p = new Core.Curation.Data.Plugin(Repository, fi, new Version(1, 1, 1), new Version(1, 1, 1, 1)); var lma = new LoadModuleAssembly(Repository, fi2, p); var lma2 = new LoadModuleAssembly(Repository, fi3, p); //gather dependencies of the plugin (plugin[0] + lma[1]) Gatherer g = new Gatherer(RepositoryLocator); ShareManager sm = new ShareManager(RepositoryLocator); var list = g.GatherDependencies(p).ToShareDefinitionWithChildren(sm); //Delete export definitions foreach (var e in Repository.GetAllObjects <ObjectExport>()) { e.DeleteInDatabase(); } //and delete pluing (CASCADE deletes lma too) p.DeleteInDatabase(); //import them var created = sm.ImportSharedObject(list).ToArray(); //There should be 3 Assert.AreEqual(3, created.Count()); Assert.AreEqual(3, Repository.GetAllObjects <ObjectImport>().Count()); lma2 = (LoadModuleAssembly)created[2]; //now delete lma2 only lma2.DeleteInDatabase(); Assert.AreEqual(2, Repository.GetAllObjects <ObjectImport>().Count()); //import them var created2 = sm.ImportSharedObject(list); //There should still be 3 Assert.AreEqual(3, created2.Count()); }
public override void ReceiveInput(Gatherer g, Button b) { switch (b) { case Button.A: if (material == Resource.Stahl) { SendResource(g); } else { GathererUI.Instance.SendTextMessage(g.team, "Falsches Werkzeug"); } break; case Button.B: if (material == Resource.Sand) { SendResource(g); } else { GathererUI.Instance.SendTextMessage(g.team, "Falsches Werkzeug"); } break; case Button.X: if (material == Resource.Wasser) { SendResource(g); } else { GathererUI.Instance.SendTextMessage(g.team, "Falsches Werkzeug"); } break; case Button.Y: if (material == Resource.Holz) { SendResource(g); } else { GathererUI.Instance.SendTextMessage(g.team, "Falsches Werkzeug"); } break; default: break; } }
public void GatherAndShare_ExtractionFilter_Test() { //Setup some objects under Catalogue var cata = new Catalogue(CatalogueRepository, "Cata"); cata.Periodicity = Catalogue.CataloguePeriodicity.BiMonthly; cata.SaveToDatabase(); var catalogueItem1 = new CatalogueItem(CatalogueRepository, cata, "Ci1"); var tableInfo = new TableInfo(CatalogueRepository, "Myt"); var colInfo = new ColumnInfo(CatalogueRepository, "[Mt].[C1]", "varchar(10)", tableInfo); catalogueItem1.ColumnInfo_ID = colInfo.ID; catalogueItem1.SaveToDatabase(); //Setup a Filter under this extractable column (the filter is what we will share) var ei = new ExtractionInformation(CatalogueRepository, catalogueItem1, colInfo, "UPPER(C1) as Fish"); var filter = new ExtractionFilter(CatalogueRepository, "My Filter", ei); filter.Description = "amagad"; filter.WhereSQL = "UPPER(C1) = @a"; //Give the filter a parameter @a just to make things interesting var declaration = filter.GetQuerySyntaxHelper().GetParameterDeclaration("@a", new DatabaseTypeRequest(typeof(string), 1)); var param = filter.GetFilterFactory().CreateNewParameter(filter, declaration); //Also create a 'known good value' set i.e. recommended value for the parameter to achive some goal (you can have multiple of these - this will not be shared) var set = new ExtractionFilterParameterSet(CatalogueRepository, filter, "Fife"); var val = new ExtractionFilterParameterSetValue(CatalogueRepository, set, (ExtractionFilterParameter)param); val.Value = "'FISH'"; //Gather the dependencies (this is what we are testing) var gatherer = new Gatherer(RepositoryLocator); Assert.IsTrue(gatherer.CanGatherDependencies(filter)); var gathered = gatherer.GatherDependencies(filter); //gatherer should have gathered the filter and the parameter (but not the ExtractionFilterParameterSet sets) Assert.AreEqual(1, gathered.Children.Count); Assert.AreEqual(param, gathered.Children[0].Object); //Cleanup val.DeleteInDatabase(); set.DeleteInDatabase(); cata.DeleteInDatabase(); }
private LoadMetadata ShareToNewRepository(LoadMetadata lmd) { var gatherer = new Gatherer(RepositoryLocator); Assert.IsTrue(gatherer.CanGatherDependencies(lmd)); var rootObj = gatherer.GatherDependencies(lmd); var sm = new ShareManager(RepositoryLocator, null); var shareDefinition = rootObj.ToShareDefinitionWithChildren(sm); var repo2 = new MemoryDataExportRepository(); var sm2 = new ShareManager(new RepositoryProvider(repo2)); return(sm2.ImportSharedObject(shareDefinition).OfType <LoadMetadata>().Single()); }
static void Main(string[] args) { var l = new Gatherer() .From(new DirectoryInfo(Assembly.GetExecutingAssembly().Location)) .WithDiagnosticTiming() .WithVerboseLogging() .WithLogger(x => Console.WriteLine(x)); var loadedTypes = l.LoadAll(); Console.WriteLine("Load All"); foreach (var type in loadedTypes) { PrintTypeInfo(type); } Console.WriteLine("Adding to Ninject container"); var container = new StandardKernel(); foreach (var harvest in loadedTypes) { if (harvest.SupportedInterfaces.Contains(typeof(ITypeA))) { container.Bind <ITypeA>().To(harvest.GatheredType); } if (harvest.SupportedInterfaces.Contains(typeof(ITypeB))) { container.Bind <ITypeB>().To(harvest.GatheredType); } if (harvest.SupportedInterfaces.Contains(typeof(ITypeC))) { container.Bind <ITypeC>().To(harvest.GatheredType); } } var typeAs = container.GetAll <ITypeA>(); var typeBs = container.GetAll <ITypeB>(); var typeCs = container.GetAll <ITypeC>(); Console.WriteLine($"Found {typeAs.Count()} type a"); Console.WriteLine($"Found {typeBs.Count()} type b"); Console.WriteLine($"Found {typeCs.Count()} type c"); Console.ReadLine(); }
public void GetData(string requested) { if (Gatherer == null) { OnGetData(requested); } else { PropertyInfo[] properties = Gatherer.GetType().GetProperties(); foreach (PropertyInfo property in properties) { if (property.Name == requested) { MethodInfo get = property.GetGetMethod(); get.Invoke(Gatherer, new object[] { }); } } } }
public void GathererTest() { Gatherer gatherer = new Gatherer(1, new List <ResourceAmount>() { new ResourceAmount("wood", 1), new ResourceAmount("rock", 1), new ResourceAmount("ore", 1) }, new List <ResourceAmount>() { new ResourceAmount("wood", 1), new ResourceAmount("rock", 1), }); Assert.Equal(1, gatherer.FoodNeeded); Assert.Equal(2, gatherer.Products.Count); Assert.Single(gatherer.Products.Where(p => p.Type == "wood" && p.Amount == 1)); Assert.Single(gatherer.Products.Where(p => p.Type == "rock" && p.Amount == 1)); }
public void GatherAndShare_Plugin_Test() { var f1 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Imaginary1" + PackPluginRunner.PluginPackageSuffix)); File.WriteAllBytes(f1.FullName, new byte[] { 0x1, 0x2 }); var plugin = new Core.Curation.Data.Plugin(CatalogueRepository, new FileInfo("Imaginary" + PackPluginRunner.PluginPackageSuffix), new System.Version(1, 1, 1), new System.Version(1, 1, 1)); var lma1 = new LoadModuleAssembly(CatalogueRepository, f1, plugin); Assert.AreEqual(lma1.Plugin_ID, plugin.ID); Gatherer g = new Gatherer(RepositoryLocator); Assert.IsTrue(g.CanGatherDependencies(plugin)); var gObj = g.GatherDependencies(plugin); //root should be the server Assert.AreEqual(gObj.Object, plugin); Assert.IsTrue(gObj.Children.Any(d => d.Object.Equals(lma1))); }
public void Train(double learningRate, int epochs, double momentum, List <TrainingElement> inputs, double desiredError = 0) { ResetLayers(); Errors.Clear(); for (var i = 0; i < epochs; i++) { List <double> epochsErrors = new List <double>(); for (var j = 0; j < inputs.Count; j++) { var guess = ForwardPropagation(inputs[j].Input); epochsErrors.Add(MeanSquaredError(guess, inputs[j].DesiredOutput)); //an equation for the error in the output layer, δL var outputLayer = Layers.Last(); var sigmoidDerivative = outputLayer.ActivationFunction.CalculateDifferential(outputLayer.WeightedSum); //∇aC=(aL−y) outputLayer.DeltaL = guess.Subtract(inputs[j].DesiredOutput).PointwiseMultiply(sigmoidDerivative); //δL //an equation for the error δl in terms of the error in the next layer, δl + 1 for (var k = Layers.Count - 2; k >= 0; k--) { Layers[k].Backpropagate(Layers[k + 1]); } Layers.First().UpdateLayer(inputs[j].Input, learningRate, momentum); for (var k = 1; k < Layers.Count; k++) { Layers[k].UpdateLayer(Layers[k - 1].Activation, learningRate, momentum); } } Errors.Add(epochsErrors.Sum() / inputs.Count); if (Errors[i] <= desiredError) { break; } Gatherer.GatherStatistics(this); } }
internal static HashSet<SqlAlias> Gather(SqlNode node) { Gatherer g = new Gatherer(); g.Visit(node); return g.Produced; }
/// <summary> /// Creates a marking for the current system /// </summary> public Marking() { TheGatherer = new Gatherer(); }