Beispiel #1
0
 /// <summary>
 /// Constructor for clonning
 /// </summary>
 /// <param name="cell"><see cref="Cell"/> for clonning</param>
 public Cell(Cell cell)
 {
     _x = cell.X;
     _y = cell.Y;
     _status = cell.Status;
     _cellOrganism = cell.Organism;
 }
Beispiel #2
0
 /// <summary>
 /// Organism dead
 /// </summary>
 private void OrganismDead()
 {
     _cellOrganism = null;
 }
Beispiel #3
0
 /// <summary>
 /// Create new organism
 /// </summary>
 private void OrganismCreate()
 {
     var rand = new Random(_x*_y + _x + _y + Environment.TickCount);
     _cellOrganism = new Organism(rand.Next(511), _x, _y);
 }
Beispiel #4
0
 /// <summary>
 /// Organism born
 /// </summary>
 private void OrganismBorn()
 {
     int inheritGenome;
     if (_parents != null && _parents.Count() == 3)
     {
         inheritGenome = _parents.Sum(x => x.Genome)/3;
     }
     else
     {
         throw new Exception("Error parents");
     }
     _cellOrganism = new Organism(inheritGenome, _x, _y);
 }
Beispiel #5
0
 /// <summary>
 /// Cell is empty for organism
 /// </summary>
 private void CellEmpty()
 {
     _cellOrganism = null;
 }
Beispiel #6
0
 /// <summary>
 /// Set migration of organism
 /// </summary>
 /// <param name="organism"><see cref="Organism"/></param>
 public void SetMigration(Organism organism)
 {
     _status = OrganismStatus.Live;
     if (_cellOrganism == null)
     {
         _cellOrganism = organism;
     }
     else
     {
         throw new Exception("Migration to full occupied cell");
     }
 }
Beispiel #7
0
 /// <summary>
 /// Create new <see cref="Migration"/>
 /// </summary>
 /// <param name="from">Coordinate of old <see cref="Cell"/></param>
 /// <param name="to">Coordinate of new <see cref="Cell"/></param>
 /// <param name="organism">Organism, that was migrate</param>
 public void SetMigration(Coordinate from, Coordinate to, Organism organism)
 {
     _migration.IsMigrartion = true;
     _migration.From = from;
     _migration.To = to;
     _migration.Organism = organism;
 }