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
+36
View File
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
namespace GameOfLife.Entities
{
public class Cell : Tuple<short, short>
{
public Cell(short x, short y) : base(x, y)
{
}
public Cell(short x, int y) : base(x, (short)y) { }
public Cell(int x, short y) : base((short)x, y) { }
public Cell(int x, int y) : base((short)x, (short)y) { }
public static Cell operator +(Cell cell1, Cell cell2)
=> new Cell(cell1.Item1 + cell2.Item1, cell1.Item2 + cell2.Item2);
public static Cell operator -(Cell cell1, Cell cell2)
=> new Cell(cell1.Item1 - cell2.Item1, cell1.Item2 - cell2.Item2);
public Cell Negate()
=> new Cell(-Item1, -Item2);
public IEnumerable<Cell> NeighborCells => new []
{
new Cell(Item1 - 1, Item2 - 1), new Cell(Item1 - 1, Item2), new Cell(Item1 - 1, Item2 + 1),
new Cell(Item1, Item2 - 1), new Cell(Item1, Item2 + 1),
new Cell(Item1 + 1, Item2 - 1), new Cell(Item1 + 1, Item2), new Cell(Item1 + 1, Item2 + 1),
};
public override string ToString()
{
return $"[{Item1}, {Item2}]";
}
}
}