예제 #1
0
        public void AddMatchingEdges(Tile tile)
        {
            foreach (var key in Edges)
            {
                if (tile.IsMatch(key, out string matchingEdge))
                {
                    if (MatchingEdges.ContainsKey(key))
                    {
                        throw new ArgumentException($"{key} already exists in edges for {MatchingEdges[key]} - tried to add {tile.Id}");
                    }
                    MatchingEdges.Add(key, tile.Id);

                    if (tile.MatchingEdges.ContainsKey(key))
                    {
                        throw new ArgumentException($"{matchingEdge} already exists in edges for {tile.MatchingEdges[key]} - tried to add {Id}");
                    }
                    tile.MatchingEdges.Add(matchingEdge, Id);
                }
            }
        }
예제 #2
0
 public override string ToString()
 {
     return(Id + ": " + string.Join(", ", Edges.Select(edge => $"{edge} ({(MatchingEdges.ContainsKey(edge) ? MatchingEdges[edge].ToString() : "")})")));
 }