public Food(ConstsUniverse ctUn, FoodType foodType) : base(ctUn) { switch (foodType) { case FoodType.deadCell: descriptor = -2; energyLevel = ConstsUniverse.EnergyLevel_DeadCell; break; case FoodType.defaultFood: descriptor = -1; energyLevel = ConstsUniverse.EnergyLevel_DefFood; break; case FoodType.poison: descriptor = -3; energyLevel = ConstsUniverse.EnergyLevel_Poison; break; default: descriptor = -1; energyLevel = 1; break; } this.foodType = foodType; }
public Cell(ConstsUniverse ctUn, Dictionary <string, object> dictionary) : base(ctUn) { Initialize( new Genome( ConstsUniverse, Convert.ToInt32(dictionary["hunger"]), Convert.ToInt32(dictionary["aggression"]), Convert.ToInt32(dictionary["reproduction"]), Convert.ToInt32(dictionary["friendly"]), Convert.ToInt32(dictionary["poisonAddiction"]) ), 1000, 1000); foreach (var atr in GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)) { if (atr == null) { continue; } string name = atr.Name; if (typeof(IFormattable).IsAssignableFrom(atr.FieldType)) { atr.SetValue(this, dictionary[name]); } } }
void Initialize(int width, int height, ConstsUniverse ctUniverse) { if (width <= 0 || height <= 0) { throw new Exception(@"Can`t create so small Universe!"); } ConstsUniverse = ctUniverse; this.width = width; this.height = height; universeMatrix = new UniverseObject[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { AddUniverseObject(i, j, new EmptySpace(ConstsUniverse), true); } } disposed = false; foodForTick = 0; poisonForTick = 0; ticksCount = 0; blockCellDesc = 0; MaxCellsPersent = 1; SetFoodPlace(0, 0, width, height); SetPoisonPlace(0, 0, width, height); }
public Food(ConstsUniverse constsUniverse, FoodType foodType) : base(constsUniverse) { //I use delegate to always return value from ConstsUniverse, if it updated. if (foodType == FoodType.defaultFood) { descriptor = -1; GetEnergyLevelDelegate = delegate { return(ConstsUniverseProperty.EnergyLevel_DefFood); }; } else if (foodType == FoodType.deadCell) { descriptor = -2; GetEnergyLevelDelegate = delegate { return(ConstsUniverseProperty.EnergyLevel_DeadCell); }; } else if (foodType == FoodType.poison) { descriptor = -3; GetEnergyLevelDelegate = delegate { return(ConstsUniverseProperty.EnergyLevel_PoisonedFood); }; } }
public Genome(ConstsUniverse ctUn) { ConstsUniverse = ctUn; Hunger = ConstsUniverse.CellGenome_Hunger; Aggression = ConstsUniverse.CellGenome_Aggression; Reproduction = ConstsUniverse.CellGenome_Reproduction; Friendly = ConstsUniverse.CellGenome_Friendly; PoisonAddiction = ConstsUniverse.CellGenome_PoisonAddiction; }
public Genome(ConstsUniverse ctUn, int hunger, int aggression, int reproduction, int friendly, int poisonAddiction) { ConstsUniverse = ctUn; Hunger = hunger; Aggression = aggression; Reproduction = reproduction; Friendly = friendly; PoisonAddiction = poisonAddiction; }
public Universe(int width, int height) { this.width = width; this.height = height; foodPlace = new bool[width, height]; poisonPlace = new bool[width, height]; SetDefaultObjectsAccessiblePlace(); ConstsUniverseProperty = new ConstsUniverse(); universeMatrix = new UniverseObject[width, height]; ticksCount = 0; }
public Genome(ConstsUniverse constsUniverse) : this( constsUniverse.CellGenome_Hunger, constsUniverse.CellGenome_Aggression, constsUniverse.CellGenome_Reproduction, constsUniverse.CellGenome_Friendly, constsUniverse.CellGenome_PoisonAddiction, constsUniverse.CellGenome_CorpseAddiction ) { }
public EmptySpace(ConstsUniverse ctUn, Dictionary <string, object> dictionary) : base(ctUn, dictionary) { //foreach (var atr in GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)) //{ // if (atr == null) // continue; // string name = atr.Name; // if (typeof(IFormattable).IsAssignableFrom(atr.FieldType)) // atr.SetValue(this, dictionary[name]); //} }
public Cell(ConstsUniverse constsUniverse, Genome genome, float energyLevel, int descriptor) : base(constsUniverse) { this.genome = genome; age = 0; this.energyLevel = energyLevel; if (descriptor < 100) { int desc = StableRandom.rd.Next(100, int.MaxValue); this.descriptor = desc; } else { this.descriptor = descriptor; } parentDescriptor = StableRandom.rd.Next(100, int.MaxValue); }
public void Dispose() { disposed = true; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { GetMatrixElement(i, j).Dispose(); } } universeMatrix = null; poisonPlace = null; foodPlace = null; cellList = null; MostFitGenome_OneCell = null; constsUniverse = null; invokedActions = null; }
public Cell(ConstsUniverse constsUniverse) : this(constsUniverse, new Genome(constsUniverse), constsUniverse.EnergyLevel_CreatingCell, 1) { }
public Food(ConstsUniverse ctUn) : this(ctUn, FoodType.defaultFood) { }
public Cell(ConstsUniverse ctUn, Genome genome, float energyLevel, int descriptor) : base(ctUn) { Initialize(genome, descriptor, energyLevel); }
public Cell(ConstsUniverse ctUn, Genome genome, float energyLevel) : base(ctUn) { Initialize(genome, 1, energyLevel); }
public Cell(ConstsUniverse ctUn, Genome genome) : base(ctUn) { Initialize(genome, 1, ConstsUniverse.EnergyLevel_CreatingCell); }
public Cell(ConstsUniverse ctUn) : base(ctUn) { Initialize(new Genome(ConstsUniverse), 1, ConstsUniverse.EnergyLevel_CreatingCell); }
public EmptySpace(ConstsUniverse ctUn) : base(ctUn) { }
public UniverseObject(ConstsUniverse constsUniverse) { ConstsUniverseProperty = constsUniverse; }
protected UniverseObject(ConstsUniverse ctUn) { ConstsUniverse = ctUn; }