public void EqualityFalseTypeOnlyTest() { var tagOne = Tag.New(new[] { A, B, A, C, D }); var tagTwo = Tag.New(new[] { C, C, D }); var id1 = new UniqueIdentifier(IdentityType.Species, new[] { tagOne, tagTwo }); var id2 = new UniqueIdentifier(IdentityType.ResourceNode, new[] { tagOne, tagTwo }); Assert.IsFalse(id1 == id2); Assert.IsFalse(id2 == id1); }
public void EqualityTrueTest() { var tagOne = Tag.New(new[] { A, B, A, C, D }); var tagTwo = Tag.New(new[] { C, C, D }); var id1 = new UniqueIdentifier(IdentityType.Species, new[] { tagOne, tagTwo }); var id2 = new UniqueIdentifier(IdentityType.Species, new[] { tagOne, tagTwo }); Assert.IsTrue(id1 == id2); Assert.IsTrue(id2 == id1); }
private GridResourceNode(Tag offense, Tag defense, Tag exchange) { RenewableResources = new List<Resource>(); Reservoir = new List<Resource>(); this.Offense = offense; this.Defense = defense; this.Exchange = exchange; Id = new UniqueIdentifier(IdentityType.ResourceNode, new[] { this.Offense, this.Defense, this.Exchange }); Source = null; }
public void EqualityFalseTest() { var tagOne = Tag.New(new[] { A, B, A, C, D }); var tagTwo = Tag.New(new[] { C, C, D }); var tagThree = Tag.New(new[] { B }); var tagFour = Tag.New(new[] { B, A, D, C }); var id1 = new UniqueIdentifier(IdentityType.Species, new[] { tagOne, tagTwo }); var id2 = new UniqueIdentifier(IdentityType.Species, new[] { tagThree, tagFour }); Assert.IsFalse(id1 == id2); Assert.IsFalse(id2 == id1); }
public Species(ISimulation simulation, IAgent exemplar, params UniqueIdentifier[] derivedFromSpeciesIds) { if (simulation == null) throw new ArgumentNullException("simulation"); if (exemplar == null) throw new ArgumentNullException("exemplar"); this.Simulation = simulation; this.firstSeen = simulation.CurrentGeneration; this.ResourcesFromResourceNodes = 0; this.ResourcesFromAgents = 0; this.Population = 0; this.id = CreateUniqueIdentifier(exemplar); this.derivedFromSpeciesIds.AddRange(derivedFromSpeciesIds); this.exemplar = exemplar.DeepCopy(); }
private GridResourceNode(IResourceNode node) { if (node == null) throw new ArgumentNullException("node"); this.Source = node; this.Offense = node.Offense; this.Defense = node.Defense; this.Exchange = node.Exchange; Id = new UniqueIdentifier(IdentityType.ResourceNode, new[] { this.Offense, this.Defense, this.Exchange }); this.RenewableResources = new List<Resource>(); this.RenewableResources.AddRange(node.RenewableResources); this.Reservoir = new List<Resource>(); this.RefreshReservoir(); }
public void MultiAgentTagConstructorTest() { var expectedType = IdentityType.Corpse; var tagOne = Tag.New(new[] { A, B, A, C, D }); var tagTwo = Tag.New(new[] { C, C, D }); var tagThree = Tag.New(new[] { B }); var tagFour = Tag.New(new[] { B, A, D, C }); var id = new UniqueIdentifier(expectedType, new[] { tagOne, tagTwo, null, tagThree, tagFour }); Assert.AreEqual(expectedType, id.Type); Assert.AreEqual(tagOne.Data.Count + tagTwo.Data.Count + tagThree.Data.Count + tagFour.Data.Count + 3 + 1, id.Genome.Length); int actualIndex = 0; for (int i = 0; i < tagOne.Data.Count; i++) { Assert.AreEqual(tagOne.Data[i], id.Genome[actualIndex++]); } Assert.AreEqual(null, id.Genome[actualIndex++]); for (int i = 0; i < tagTwo.Data.Count; i++) { Assert.AreEqual(tagTwo.Data[i], id.Genome[actualIndex++]); } Assert.AreEqual(null, id.Genome[actualIndex++]); Assert.AreEqual(null, id.Genome[actualIndex++]); for (int i = 0; i < tagThree.Data.Count; i++) { Assert.AreEqual(tagThree.Data[i], id.Genome[actualIndex++]); } Assert.AreEqual(null, id.Genome[actualIndex++]); for (int i = 0; i < tagFour.Data.Count; i++) { Assert.AreEqual(tagFour.Data[i], id.Genome[actualIndex++]); } }
public void ResourceConstructorTest() { var expectedType = IdentityType.Species; var expectedGenome = new[] { A, B, A, C, D }; var id = new UniqueIdentifier(expectedType, expectedGenome); Assert.AreEqual(expectedType, id.Type); Assert.AreEqual(expectedGenome.Length, id.Genome.Length); for (int i = 0; i < expectedGenome.Length; i++) { Assert.AreEqual(expectedGenome[i], id.Genome[i]); } }
public Fossil(UniqueIdentifier speciesId) { if (speciesId == null) throw new ArgumentNullException("speciesId"); this.Id = new UniqueIdentifier(IdentityType.Fossil, (Resource[])speciesId.Genome.Clone()); }