-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
45 lines (42 loc) · 1.32 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using GameOfLife;
using System.Collections.Generic;
using Woopec.Core;
internal class Program
{
public static void WoopecMain()
{
int rowCount = 120;
int columnCount = 120;
var renderer = new Renderer(rowCount, columnCount, 6);
string gosperGilderGun = @"
.........................X
.......................X.X
.............XX......XX............XX
............X...X....XX............XX
.XX........X.....X...XX
.XX........X...X.XX....X.X
...........X.....X.......X
............X...X........
.............XX.";
var seed = AliveCellPositionsOfSeed(gosperGilderGun);
var game = new Game(rowCount, columnCount, seed, renderer);
game.Run(iterationCount: 76);
Screen.Default.Bye();
}
private static IEnumerable<CellPosition> AliveCellPositionsOfSeed(string seedString)
{
const char aliveMarker = 'X';
var lines = seedString.Split('\n');
int row = 0;
foreach (var line in lines)
{
int column = line.IndexOf(aliveMarker);
while (column != -1)
{
yield return new CellPosition(row, column);
column = line.IndexOf(aliveMarker, column + 1);
}
row++;
}
}
}