public MainWindow() { InitializeComponent(); RenderOptions.SetBitmapScalingMode(FieldImage, BitmapScalingMode.NearestNeighbor); RenderOptions.SetEdgeMode(FieldImage, EdgeMode.Aliased); var preset = new RandomPreset(70); var settings = new GameSettings( (int)FieldImage.Width, (int)FieldImage.Height, new RandomAreas(40, 2, preset)); var game = new Game(settings, new WpfRender(FieldImage)); game.Prepare(); FieldImage.Height = Height; FieldImage.Width = Width; Task.Run( () => { long counter = 0; while (true) { counter++; game.MakeNextGeneration(); Dispatcher.Invoke(() => Counter.Text = counter.ToString()); } }); }
public void ShouldSortRandomly() { int[] items = { 1, 2, 3 }; var randomPreset = new RandomPreset(0.3, 0.1, 0.8); var generator = new RandomGenerator(() => randomPreset.Next()); int[] sortedItems = generator.Sort(items).ToArray(); int[] expected = { 2, 1, 3 }; CollectionAssert.AreEqual(expected, sortedItems); }