예제 #1
0
 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)
 {
 }
예제 #4
0
 public void PlaceCell(Location location)
 {
     if (!OccupiedLocations.Contains(location)) OccupiedLocations.Add(location);
 }
예제 #5
0
 public int GetNeighborsOfLocation(Location item)
 {
     var items = _neighborGenerator.GenerateNeighbors(item, new List<Location>())
     return items.FindAll(x => OccupiedLocations.Contains(x)).Count;
 }
예제 #6
0
 public bool ContainsCellAt(Location location)
 {
     return OccupiedLocations.Contains(location);
 }
예제 #7
0
 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));
 }