private static void CreateGlider(Game myGame, Location location) { myGame.CurrentWorld.PlaceCell(new Location(location, 3, 1)); myGame.CurrentWorld.PlaceCell(new Location(location, 1, 2)); myGame.CurrentWorld.PlaceCell(new Location(location, 3, 2)); myGame.CurrentWorld.PlaceCell(new Location(location, 2, 3)); myGame.CurrentWorld.PlaceCell(new Location(location, 3, 3)); }
public List<Location> GenerateNeighbors(Location location, List<Location> locationsToRemove ) { var result = new List<Location>(); for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { var proposedLocation = new Location(location.X + x, location.Y + y); if (!locationsToRemove.Contains(proposedLocation)) { result.Add(proposedLocation); } } } return result; }
public Location(Location adjustment, int x, int y) : this(adjustment.X + x, adjustment.Y + y) { }
public void PlaceCell(Location location) { if (!OccupiedLocations.Contains(location)) OccupiedLocations.Add(location); }
public int GetNeighborsOfLocation(Location item) { var items = _neighborGenerator.GenerateNeighbors(item, new List<Location>()) return items.FindAll(x => OccupiedLocations.Contains(x)).Count; }
public bool ContainsCellAt(Location location) { return OccupiedLocations.Contains(location); }
private static void CreateBlinker(Game myGame, Location location) { myGame.CurrentWorld.PlaceCell(new Location(location, 1, 1)); myGame.CurrentWorld.PlaceCell(new Location(location, 1, 2)); myGame.CurrentWorld.PlaceCell(new Location(location, 1, 3)); }