public void EntityMap_Should_Have_Empty_PropertyMap_Collection() { PreTest(); var map = new EmptyMap(); Assert.IsNotNull(map.PropertyMaps, "PropertyMaps collection is not initialized with an empty list."); }
public void AddingRemoving_Indices() { var map1 = Map((1, 2), 'A'); var map2 = Map((2, 3), 'B'); var map3 = EmptyMap .Add(map1) .Add(map2); Assert.Multiple(() => { Assert.That(map3[1].Simple(), Is.EquivalentTo(new[] { Group((1, 2), 'A') }));
public void EntityMapShouldHaveEmptyPropertyMapCollection() { // Arrange PreTest(); // Act var map = new EmptyMap(); // Assert Assert.NotNull(map.PropertyMaps); Assert.Empty(map.PropertyMaps); }
/// <inheritdoc/> public override void GetAll(IBag <TechniqueInfo> accumulator, IReadOnlyGrid grid) { var r = (Span <int>) stackalloc int[2]; foreach (var((baseSet, coverSet), (a, b, c)) in IntersectionMaps) { if (!EmptyMap.Overlaps(c)) { continue; } short m1 = BitwiseOrMasks(grid, a); short m2 = BitwiseOrMasks(grid, b); short m3 = BitwiseOrMasks(grid, c); short m = (short)(m3 & (m1 ^ m2)); if (m == 0) { continue; } foreach (int digit in m.GetAllSets()) { GridMap elimMap; (r[0], r[1], elimMap) = a.Overlaps(CandMaps[digit]) ? (coverSet, baseSet, a & CandMaps[digit]) : (baseSet, coverSet, b & CandMaps[digit]); if (elimMap.IsEmpty) { continue; } var conclusions = new List <Conclusion>(); foreach (int cell in elimMap) { conclusions.Add(new Conclusion(Elimination, cell, digit)); } var candidateOffsets = new List <(int, int)>(); foreach (int cell in c& CandMaps[digit]) { candidateOffsets.Add((0, cell * 9 + digit)); } accumulator.Add( new LcTechniqueInfo( conclusions, views: new[]
/// <summary> /// Search for all W-Wings. /// </summary> /// <param name="result">The result accumulator.</param> /// <param name="grid">The grid.</param> /// <returns>All technique information instances.</returns> public static void TakeAllWWings(IBag <TechniqueInfo> result, IReadOnlyGrid grid) { if (BivalueMap.Count < 2) { return; } // Iterate on each cells. for (int c1 = 0; c1 < 72; c1++) { if (!BivalueMap[c1] || !EmptyMap[c1]) { continue; } // Iterate on each cells which are not peers in 'c1'. int[] digits = grid.GetCandidatesReversal(c1).GetAllSets().ToArray(); foreach (int c2 in BivalueMap - new GridMap(c1)) { if (c2 < c1 || grid.GetCandidatesReversal(c1) != grid.GetCandidatesReversal(c2)) { continue; } var intersection = new GridMap(c1, false) & new GridMap(c2, false); if (!EmptyMap.Overlaps(intersection)) { continue; } for (int region = 9; region < 27; region++) { if (region < 18 && ( GetRegion(c1, RegionLabel.Row) == region || GetRegion(c2, RegionLabel.Row) == region) || region >= 18 && ( GetRegion(c1, RegionLabel.Column) == region || GetRegion(c2, RegionLabel.Column) == region)) { continue; } SearchWWingByRegions(result, grid, digits, region, c1, c2, intersection); } } } }
/// <summary> /// Constructor for internal usage /// </summary> private GraphExpression() { Map = new EmptyMap(); }
public SceneMapSelect() { sceneType = scene.SceneType.MapSelect; _loader = new MapLoader(); _loader.OnMapLoaded += (s, e) => { _loadedMap = e.Map; _loadEnd = true; _loading = false; }; _loader.OnMapLoadCanceled += (s, e) => { _loadedException = e.Exception; _loadedMap = null; _loadingMapInfo = null; _loadEnd = true; _loading = false; }; _mapInfos = new List <MapInfo>(); _keys = new Key[] { Key.UpArrow, Key.DownArrow, Key.LeftArrow, Key.RightArrow, Key.Return, Key.Escape, Key.One, Key.Two, Key.R }; _builtinMapInfos = new MapInfo[] { EmptyMap.GetMapInfo(), EmptyFixedMap.GetMapInfo(), RandomMap.GetMapInfo(3), RandomMap.GetMapInfo(5), RandomEndlessMap.GetMapInfo(3) }; _randItems = new string[_builtinMapInfos.Length + 1]; for (int i = 0; i < _builtinMapInfos.Length; i++) { _randItems[i] = _builtinMapInfos[i].MapName; } _randItems[_randItems.Length - 1] = Properties.Resources.MenuItem_ReloadMap; _cursor = ResourceManager.GetColoredCursorGraphic(Constants.Color_Foreground); _strongCursor = ResourceManager.GetColoredCursorGraphic(Constants.Color_Strong); #region レイアウト初期化 Size escSize = ResourceManager.MiddlePFont.SizeText(_escItems[0].ToString()); _escRect = new Rectangle( Constants.ScreenWidth - Constants.RightBottomItemMargin - escSize.Width - Constants.CursorMargin, Constants.ScreenHeight - Constants.RightBottomItemMargin - escSize.Height, escSize.Width + Constants.CursorMargin, escSize.Height); _expRect = new Rectangle( Constants.HeaderX + Constants.UnderHeaderMargin, Constants.HeaderY + ResourceManager.LargePFont.Height + Constants.HeaderBottomMargin, Constants.ScreenWidth - Constants.UnderHeaderMargin * 2, ResourceManager.SmallPFont.Height); int top = _expRect.Bottom + Constants.SubHeaderBottomMargin; int bottom = _escRect.Top - Constants.UnderHeaderMargin; _mapRect = new Rectangle( Constants.HeaderX + Constants.UnderHeaderMargin + Constants.CursorMargin, top, (int)((Constants.ScreenWidth - (Constants.HeaderX + Constants.UnderHeaderMargin * 2) - Constants.MenuColumnGap) / 2.0) - Constants.CursorMargin, bottom - top); _randRect = new Rectangle( _mapRect.Right + Constants.MenuColumnGap + Constants.CursorMargin, _mapRect.Top, _mapRect.Width, _mapRect.Height); #endregion _randSurfaces = new SurfaceCollection(); _randRects = new Rectangle[_randItems.Length]; ImageUtil.CreateStrMenu(_randItems, Constants.Color_Foreground, ref _randSurfaces, ref _randRects, _randRect.Width); _randRects[_randRects.Length - 1].Offset(0, ResourceManager.SmallPFont.Height); _escSurfaces = new SurfaceCollection(); _escRects = new Rectangle[_escItems.Length]; ImageUtil.CreateStrMenu(_escItems, Constants.Color_Strong, ResourceManager.MiddlePFont, ref _escSurfaces, ref _escRects, _escRect.Width, ResourceManager.MiddlePFont.Height); }