|
using System;
using System.Collections.Generic;
using System.Text;
namespace LifeSimulation.Extensions
{
static class RandomizeLifeModelExtension
{
#region Extension methods
public static void Randomize(this LifeModelBase model)
{
Random rnd = new Random(DateTime.Now.Millisecond);
model.NeighbourDistance = rnd.Next(1, 5);
int spawn = rnd.Next(1, 7); //Makes 1 to 6
model.CellDeathIndicators.Clear();
for (int i = 0; i < model.GetMaximumNeighbours(); i++)
{
if (i != spawn)
{
//if (i > 7 || i == 0)
// model.CellDeathIndicators.Add(i);
//else if (rnd.Next(100) < 90)
// model.CellDeathIndicators.Add(i);
if (rnd.Next(100) < 10)
model.CellDeathIndicators.Add(i);
}
}
model.CellSpawnIndicators.Clear();
model.CellSpawnIndicators.Add(spawn);
model.MaximumAge = rnd.Next(20, 200);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.