Initial commit

This commit is contained in:
2026-05-07 03:23:56 +00:00
commit 5e8575f42a
42 changed files with 2330 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace GameOfLife.IO
{
public class RlePatternMetaData : PatternMetadata
{
public RlePatternMetaData(string line, IEnumerable<string> comments)
{
Comments = comments.ToArray();
var mdLine = Regex.Replace(line, @"\s+", "");
var props = mdLine.Split(',');
if (props.Length < 2)
throw new ArgumentException("Line does not contain two properties");
var mp = new Regex(@"(\w+)=(.*)");
foreach (var prop in props)
{
var capture = mp.Match(prop).Groups;
var name = capture[1].Value;
var val = capture[2].Value;
switch (name)
{
case "x":
Width = int.Parse(val);
break;
case "y":
Height = int.Parse(val);
break;
// TODO: decode the rules
case "rules":
Rules = val;
break;
}
}
}
}
}