private void InitStablizingOrder(List <BlockSet> stablizerChain) { StablizingOrder = new List <int>(); foreach (var bs in stablizerChain) { foreach (var idx in bs.Indexes) { var block = bs.State.Blocks[idx]; var position = block.Position; foreach (CubeState.Axis axis in Enum.GetValues(typeof(CubeState.Axis))) { foreach (CubeState.Direction direction in Enum.GetValues(typeof(CubeState.Direction))) { var color = block.Colors[(int)axis, (int)direction]; if (CubeState.Color.None == color) { continue; } int actionMapIndex = ActionMap.ColorBlockToIndex(position, axis, direction); StablizingOrder.Add(actionMapIndex); } } } } VerifyStablizingOrder(); }
private void InitStablizedIdx(BlockSet stablized) { StablizedIdx = -1; var stablizedInOrder = new HashSet <int>(); foreach (var idx in stablized.Indexes) { var block = stablized.State.Blocks[idx]; var position = block.Position; foreach (CubeState.Axis axis in Enum.GetValues(typeof(CubeState.Axis))) { foreach (CubeState.Direction direction in Enum.GetValues(typeof(CubeState.Direction))) { var color = block.Colors[(int)axis, (int)direction]; if (CubeState.Color.None == color) { continue; } int actionMapIndex = ActionMap.ColorBlockToIndex(position, axis, direction); int idxInStablizingOrder = StablizingOrder.IndexOf(actionMapIndex); Utils.DebugAssert(idxInStablizingOrder >= 0); Utils.DebugAssert(!stablizedInOrder.Contains(idxInStablizingOrder)); stablizedInOrder.Add(idxInStablizingOrder); } } } if (stablizedInOrder.Count > 0) { StablizedIdx = stablizedInOrder.Max(); } // // Verify StablizedIdx // for (int i = 0; i < StablizedIdx; i++) { Utils.DebugAssert(stablizedInOrder.Contains(i)); } if (stablizedInOrder.Count > 0) { Utils.DebugAssert(stablizedInOrder.Max() == stablizedInOrder.Count - 1); } else { StablizedIdx = -1; } }