public void LocationWithKeyKeyCountTest() { var item1 = new LocationWithKey { Location = new Point(1, 1) }; item1.AddKey('a'); item1.AddKey('b'); Assert.Equal(2, item1.KeyCount); }
public void LocationWithKeyAddManyTest() { var item1 = new LocationWithKey { Location = new Point(1, 1) }; item1.AddKey('a'); item1.AddKey('b'); Assert.True(item1.HasKey('a')); Assert.True(item1.HasKey('b')); }
private int StepsInShortestPathSplitMap(Dictionary <Point, char> map) { var splitMap = new SplitMap(map); var totalSteps = 0; var allKeys = map.Values.Where(char.IsLower).ToList(); for (int robot = 0; robot < 4; robot++) { var start = splitMap.Entrances[robot]; var myKeys = FindMyKeys(start, NeighborsKeysOnly, map); var startLocation = new LocationWithKey { Location = start }; foreach (var key in allKeys.Where(k => !myKeys.Contains(k))) { startLocation.AddKey(key); } var terminationNode = BreadthFirst(new Node <LocationWithKey>(startLocation, 0), Neighbors, map, allKeys.Count); totalSteps += terminationNode.Depth; } return(totalSteps); }