mirror of
https://github.com/neogeek23/Life.git
synced 2026-02-04 02:58:17 +00:00
This is this starting of the layout of Conway's Life game. I'm trying to make it so that having different states is as easy as just adding them to State.cs and that any number of dimensions should be handled quickly. Visualizing higher dimensional life games might be tricky, but this should be able to determine it.
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace N_Space {
|
|
class Dimension {
|
|
private readonly int _index;
|
|
private Dimension _parent; //These are the dimensional parents so in (1,2) the dimension that has the index=1 would be the parent of the dimention that has the index=2
|
|
private List<Dimension> _child;
|
|
private readonly Location _location;
|
|
|
|
public Dimension(int n, Location location) {
|
|
_index = n;
|
|
_parent = null;
|
|
_child = null;
|
|
_location = location;
|
|
}
|
|
|
|
public void SetParent(Dimension parent) {
|
|
_parent = parent;
|
|
}
|
|
|
|
public void AddChild(Dimension child) {
|
|
if (_child == null) {
|
|
_child = new List<Dimension>();
|
|
}
|
|
|
|
_child.Add(child);
|
|
_child.Sort((x, y) => x._index.CompareTo(y._index));
|
|
}
|
|
|
|
public int GetIndex() {
|
|
return _index;
|
|
}
|
|
|
|
public Dimension GetParent() {
|
|
return _parent;
|
|
}
|
|
|
|
public List<Dimension> GetChildList() {
|
|
return _child;
|
|
}
|
|
|
|
public Location GetLocation() {
|
|
return _location;
|
|
}
|
|
}
|
|
} |