Initial commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{8E6D5F09-E4A5-496D-8DCC-36F4780F4CCD}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>GolConsole</RootNamespace>
|
||||
<AssemblyName>GolConsole</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<Content Include="Patterns\ark1.rle">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Patterns\ark2.rle">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Patterns\blom.rle">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Patterns\glider-stream-crystal.rle">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Patterns\glider.rle">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Patterns\honey-farm-hassler-147.rle">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GameOfLife\GameOfLife.csproj">
|
||||
<Project>{0BEA14A8-8E11-4A18-BD7D-628D3F1561B0}</Project>
|
||||
<Name>GameOfLife</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,3 @@
|
||||
# ark1 -- 16 cells, stabilizes at 736692 gens, found by Nick Gotts.
|
||||
x = 32, y = 29, rule = B3/S23
|
||||
27bo$28bo$29bo$28bo$27bo$29b3o20$oo$bbo$bbo$3b4o!
|
||||
@@ -0,0 +1,3 @@
|
||||
# ark2 -- 19 cells, stabilizes at 8120878 gens, found by Nick Gotts.
|
||||
x = 53, y = 44, rule = B3/S23
|
||||
50b3o28$12bo$12bo$13boo$15bo$15bo$15bo$15bo6$oo$bbo$bbo$3b4o!
|
||||
@@ -0,0 +1,5 @@
|
||||
#C Blom. Runs for 23314 gens. Initial pop = 13. Final pop = 2740.
|
||||
#C Found by Dean Hickerson, 7 July 2002
|
||||
#C See also http://www.radicaleye.com/DRH/methuselahs.html
|
||||
x = 12, y = 5, rule = B3/S23
|
||||
o10bo$b4o6bo$2b2o7bo$10bo$8bobo!
|
||||
@@ -0,0 +1,66 @@
|
||||
#C High-period oscillator built by David Dauthier, showing
|
||||
#C a common crystal forming on a glider stream. Several adjustable
|
||||
#C high-period guns have been constructed that make use of two
|
||||
#C identical copies of this repeatable growth-and-decay reaction.
|
||||
#C It is also possible to support a single crystal of adjustable
|
||||
#C length, and extract a glider from either end of the reaction.
|
||||
#C See, e.g., p08832.lif in Jason Summers' "guns2j" collection.
|
||||
x = 252, y = 221, rule = B3/S23
|
||||
90b2o68b2o$90b2o16b2o32b2o16b2o$108b2o32b2o4$89b3o8b2o48b2o8b3o$89b3o
|
||||
8b2o48b2o8b3o$88bo3bo66bo3bo$108b3o30b3o$27b2o58b2o3b2o6bo6bo3bo28bo3b
|
||||
o6bo6b2o3b2o58b2o$29bo69bobo48bobo69bo$16b2o12bo67bo3bo3bo5bo26bo5bo3b
|
||||
o3bo67bo12b2o$16b2o4bo7bo8b2o57b5o3b2o3b2o26b2o3b2o3b5o57b2o8bo7bo4b2o
|
||||
$13b2o5b2o8bo8b2o56b2o3b2o44b2o3b2o56b2o8bo8b2o5b2o$5b2o5b3o5bo2b2o4bo
|
||||
57b3o8b5o46b5o8b3o57bo4b2o2bo5b3o5b2o$5b2o6b2o6b5ob2o62b2o6b3o7bo32bo
|
||||
7b3o6b2o62b2ob5o6b2o6b2o$16b2o4bo68b2o7bo7bob2o28b2obo7bo7b2o68bo4b2o$
|
||||
16b2o74b2o14bo34bo14b2o74b2o$90bobo15bo3bo26bo3bo15bobo$90b2o8bo8bo2bo
|
||||
26bo2bo8bo8b2o$18b2o79bobo7b5o24b5o7bobo79b2o$16bo3bo78bo9b5o24b5o9bo
|
||||
78bo3bo$10b2o3bo5bo63b2o3b2o16b2o3b2o22b2o3b2o16b2o3b2o63bo5bo3b2o$10b
|
||||
2o2b2obo3bo2bobo58b2o3b2o17b5o24b5o17b2o3b2o58bobo2bo3bob2o2b2o$15bo5b
|
||||
o3bo71b2o4bo6b3o26b3o6bo4b2o71bo3bo5bo$16bo3bo8b2o56b3o7b2o12bo28bo12b
|
||||
2o7b3o56b2o8bo3bo$18b2o9b2o56b3o72b3o56b2o9b2o$88bo74bo3$13bo8b2o204b
|
||||
2o8bo$11bobo6bo2bo204bo2bo6bobo$4b2o4bobo7bo3bo2b2o194b2o2bo3bo7bobo4b
|
||||
2o$4b2o3bo2bo7bo2b2o2b3o57b2o74b2o57b3o2b2o2bo7bo2bo3b2o$10bobo16b2obo
|
||||
12bo41b2o21b2o28b2o21b2o41bo12bob2o16bobo$11bobo4b3o8bo2bo5b2o6bo63b2o
|
||||
28b2o63bo6b2o5bo2bo8b3o4bobo$13bo15b2obo5b2o4b3o158b3o4b2o5bob2o15bo$
|
||||
27b3o192b3o$27b2o194b2o$87bobo72bobo$87b2o74b2o$88bo74bo18$65b2o118b2o
|
||||
$64b3o118b3o$64b2obo116bob2o$65b3o116b3o$66bo118bo13$23b2o202b2o$23b3o
|
||||
200b3o$9bo15b2obo5b2o4b3o166b3o4b2o5bob2o15bo$7bobo4b3o8bo2bo5b2o6bo
|
||||
166bo6b2o5bo2bo8b3o4bobo$6bobo16b2obo12bo168bo12bob2o16bobo$2o3bo2bo7b
|
||||
o2b2o2b3o200b3o2b2o2bo7bo2bo3b2o$2o4bobo7bo3bo2b2o202b2o2bo3bo7bobo4b
|
||||
2o$7bobo6bo2bo212bo2bo6bobo$9bo8b2o212b2o8bo4$14b2o9b2o198b2o9b2o$12bo
|
||||
3bo8b2o198b2o8bo3bo$11bo5bo3bo208bo3bo5bo$6b2o2b2obo3bo2bobo206bobo2bo
|
||||
3bob2o2b2o$6b2o3bo5bo216bo5bo3b2o$12bo3bo218bo3bo$14b2o220b2o3$12b2o
|
||||
224b2o$12b2o4bo214bo4b2o$b2o6b2o6b5ob2o202b2ob5o6b2o6b2o$b2o5b3o5bo2b
|
||||
2o4bo200bo4b2o2bo5b3o5b2o$9b2o5b2o8bo8b2o178b2o8bo8b2o5b2o$12b2o4bo7bo
|
||||
8b2o178b2o8bo7bo4b2o$12b2o12bo198bo12b2o$25bo40b2o116b2o40bo$23b2o41b
|
||||
3o114b3o41b2o$65bob2o114b2obo$65b3o116b3o$66bo118bo2$66bo118bo$65b3o
|
||||
116b3o$65bob2o114b2obo$23b2o41b3o114b3o41b2o$25bo40b2o116b2o40bo$12b2o
|
||||
12bo198bo12b2o$12b2o4bo7bo8b2o178b2o8bo7bo4b2o$9b2o5b2o8bo8b2o178b2o8b
|
||||
o8b2o5b2o$b2o5b3o5bo2b2o4bo200bo4b2o2bo5b3o5b2o$b2o6b2o6b5ob2o202b2ob
|
||||
5o6b2o6b2o$12b2o4bo214bo4b2o$12b2o224b2o3$14b2o220b2o$12bo3bo218bo3bo$
|
||||
6b2o3bo5bo216bo5bo3b2o$6b2o2b2obo3bo2bobo206bobo2bo3bob2o2b2o$11bo5bo
|
||||
3bo208bo3bo5bo$12bo3bo8b2o198b2o8bo3bo$14b2o9b2o198b2o9b2o4$9bo8b2o
|
||||
212b2o8bo$7bobo6bo2bo212bo2bo6bobo$2o4bobo7bo3bo2b2o202b2o2bo3bo7bobo
|
||||
4b2o$2o3bo2bo7bo2b2o2b3o200b3o2b2o2bo7bo2bo3b2o$6bobo16b2obo12bo168bo
|
||||
12bob2o16bobo$7bobo4b3o8bo2bo5b2o6bo166bo6b2o5bo2bo8b3o4bobo$9bo15b2ob
|
||||
o5b2o4b3o166b3o4b2o5bob2o15bo$23b3o200b3o$23b2o202b2o13$66bo118bo$65b
|
||||
3o116b3o$64b2obo116bob2o$64b3o118b3o$65b2o118b2o18$88bo74bo$87b2o74b2o
|
||||
$87bobo72bobo$27b2o194b2o$27b3o192b3o$13bo15b2obo5b2o4b3o158b3o4b2o5bo
|
||||
b2o15bo$11bobo4b3o8bo2bo5b2o6bo63b2o28b2o63bo6b2o5bo2bo8b3o4bobo$10bob
|
||||
o16b2obo12bo41b2o21b2o28b2o21b2o41bo12bob2o16bobo$4b2o3bo2bo7bo2b2o2b
|
||||
3o57b2o74b2o57b3o2b2o2bo7bo2bo3b2o$4b2o4bobo7bo3bo2b2o194b2o2bo3bo7bob
|
||||
o4b2o$11bobo6bo2bo204bo2bo6bobo$13bo8b2o204b2o8bo3$88bo74bo$18b2o9b2o
|
||||
56b3o72b3o56b2o9b2o$16bo3bo8b2o56b3o7b2o12bo28bo12b2o7b3o56b2o8bo3bo$
|
||||
15bo5bo3bo71b2o4bo6b3o26b3o6bo4b2o71bo3bo5bo$10b2o2b2obo3bo2bobo58b2o
|
||||
3b2o17b5o24b5o17b2o3b2o58bobo2bo3bob2o2b2o$10b2o3bo5bo63b2o3b2o16b2o3b
|
||||
2o22b2o3b2o16b2o3b2o63bo5bo3b2o$16bo3bo78bo9b5o24b5o9bo78bo3bo$18b2o
|
||||
79bobo7b5o24b5o7bobo79b2o$90b2o8bo8bo2bo26bo2bo8bo8b2o$90bobo15bo3bo
|
||||
26bo3bo15bobo$16b2o74b2o14bo34bo14b2o74b2o$16b2o4bo68b2o7bo7bob2o28b2o
|
||||
bo7bo7b2o68bo4b2o$5b2o6b2o6b5ob2o62b2o6b3o7bo32bo7b3o6b2o62b2ob5o6b2o
|
||||
6b2o$5b2o5b3o5bo2b2o4bo57b3o8b5o46b5o8b3o57bo4b2o2bo5b3o5b2o$13b2o5b2o
|
||||
8bo8b2o56b2o3b2o44b2o3b2o56b2o8bo8b2o5b2o$16b2o4bo7bo8b2o57b5o3b2o3b2o
|
||||
26b2o3b2o3b5o57b2o8bo7bo4b2o$16b2o12bo67bo3bo3bo5bo26bo5bo3bo3bo67bo
|
||||
12b2o$29bo69bobo48bobo69bo$27b2o58b2o3b2o6bo6bo3bo28bo3bo6bo6b2o3b2o
|
||||
58b2o$108b3o30b3o$88bo3bo66bo3bo$89b3o8b2o48b2o8b3o$89b3o8b2o48b2o8b3o
|
||||
4$108b2o32b2o$90b2o16b2o32b2o16b2o$90b2o68b2o!
|
||||
@@ -0,0 +1,3 @@
|
||||
#C This is a glider.
|
||||
x = 3, y = 3
|
||||
bo$2bo$3o!
|
||||
@@ -0,0 +1,12 @@
|
||||
#CXRLE Pos=-28,-26
|
||||
x = 42, y = 49, rule = B3/S23
|
||||
13b2o12b2o$9b2o3bo12bo3b2o$10bo3bobo4bo3bobo3bo$10bob2obobob3o2bobob2o
|
||||
bo$11bobobob2o3b3obobobo$20b2o$14bob4o2b4obo$9b2o3bobo2bo2bo2bobo3b2o$
|
||||
9b2o2bo4bo4bo4bo2b2o$14bob2o6b2obo3$2b2o34b2o$2bobo32bobo$3bo34bo3$bo
|
||||
12b3o8b3o12bo$obo10bo3bo6bo3bo10bobo$2o10bo5bo4bo5bo10b2o$12bo5bo4bo5b
|
||||
o$12bo5bo4bo5bo$13bo3bo6bo3bo$14b3o8b3o2$14b3o8b3o$13bo3bo6bo3bo$12bo
|
||||
5bo4bo5bo$12bo5bo4bo5bo$2o10bo5bo4bo5bo10b2o$obo10bo3bo6bo3bo10bobo$bo
|
||||
12b3o8b3o12bo3$3bo34bo$2bobo32bobo$2b2o34b2o3$14bob2o6b2obo$9b2o2bo4bo
|
||||
4bo4bo2b2o$9b2o3bobo2bo2bo2bobo3b2o$14bob4o2b4obo$20b2o$11bobobob2o3b
|
||||
3obobobo$10bob2obobob3o2bobob2obo$10bo3bobo4bo3bobo3bo$9b2o3bo12bo3b2o
|
||||
$13b2o12b2o!
|
||||
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using GameOfLife.Entities;
|
||||
using GameOfLife.IO;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace GameOfLife
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//var rleParser = new RleDecoder(@"PatternProjections/honey-farm-hassler-147.rle");
|
||||
//var rleParser = new RleDecoder(@"PatternProjections/glider-stream-crystal.rle");
|
||||
//var rleParser = new RleDecoder(@"PatternProjections/glider.rle");
|
||||
var rleParser = new RleDecoder(@"PatternProjections/blom.rle");
|
||||
|
||||
var pattern = rleParser.Pattern;
|
||||
|
||||
var paddingX = 3;
|
||||
var paddingY = 3;
|
||||
|
||||
var life = new LifeHashSet(rleParser.Pattern);
|
||||
var patternLibrary = new PatternLibrary();
|
||||
|
||||
var timer = new Stopwatch();
|
||||
timer.Start();
|
||||
do
|
||||
{
|
||||
life.IncrementGeneration();
|
||||
|
||||
Console.WriteLine($"{life.Generation} + {life.Population}");
|
||||
foreach (var p in patternLibrary.MatchLibraryPatterns(life.LivingCells))
|
||||
{
|
||||
Console.WriteLine($"\t\t\tFound {p.Item1.Name} {p.Item2.Length}");
|
||||
}
|
||||
|
||||
|
||||
//Console.Clear();
|
||||
//OutputBoard(sim);
|
||||
//Console.ReadKey();
|
||||
|
||||
//Thread.Sleep(100);
|
||||
} while (life.Population > 0 && life.Generation < 3000);
|
||||
timer.Stop();
|
||||
Console.WriteLine($"Final: Generation:{life.Generation}, Pop:{life.Population}, Time:{timer.ElapsedMilliseconds}");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void OutputBoard(LifeBase sim)
|
||||
{
|
||||
var neighborField = Neighborhood.GetNeighborField(sim.LivingCells);
|
||||
|
||||
for (short x = 0; x < 40 /*sim.SizeX*/; x++)
|
||||
{
|
||||
for (short y = 0; y < 120 /*sim.SizeY*/; y++)
|
||||
{
|
||||
var cell = new Cell(x, y);
|
||||
|
||||
var neighbors = neighborField.FirstOrDefault(n => n.Item1.Equals(cell));
|
||||
|
||||
Console.BackgroundColor = ConsoleColor.Black;
|
||||
Console.Write(" ");
|
||||
var isCellAlive = sim.IsCellAlive(cell);
|
||||
|
||||
if (neighbors != null)
|
||||
switch (neighbors.Item2)
|
||||
{
|
||||
case 0:
|
||||
Console.BackgroundColor = ConsoleColor.Black;
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
break;
|
||||
case 1 when isCellAlive:
|
||||
Console.BackgroundColor = ConsoleColor.DarkMagenta;
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
break;
|
||||
case 1:
|
||||
Console.BackgroundColor = ConsoleColor.DarkGreen;
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
break;
|
||||
|
||||
case 2 when isCellAlive:
|
||||
Console.BackgroundColor = ConsoleColor.DarkGray;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
break;
|
||||
case 2:
|
||||
Console.BackgroundColor = ConsoleColor.DarkGreen;
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
break;
|
||||
|
||||
|
||||
case 3 when isCellAlive:
|
||||
Console.BackgroundColor = ConsoleColor.DarkGray;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
break;
|
||||
case 3:
|
||||
Console.BackgroundColor = ConsoleColor.Green;
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.BackgroundColor = ConsoleColor.DarkRed;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
break;
|
||||
}
|
||||
|
||||
Console.Write(isCellAlive ? "O" : ".");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("GolConsole")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("GolConsole")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8e6d5f09-e4a5-496d-8dcc-36f4780f4ccd")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user