public static void VerifyGroupActionAssociaty() { for (int caseIdx = 0; caseIdx < 100; caseIdx++) { CubeAction a = CubeAction.Random(Utils.GlobalRandom.Next(1, 20)); CubeAction b = CubeAction.Random(Utils.GlobalRandom.Next(1, 15)); CubeAction c = CubeAction.Random(Utils.GlobalRandom.Next(1, 10)); CubeAction ab = a.Mul(b); CubeAction bc = b.Mul(c); CubeState origState = CubeAction.RandomCube(Utils.GlobalRandom.Next(1, 20)); CubeState a_b_c_state = new CubeState(origState); c.Act(a_b_c_state); b.Act(a_b_c_state); a.Act(a_b_c_state); CubeState ab_c_state = new CubeState(origState); c.Act(ab_c_state); ab.Act(ab_c_state); CubeState a_bc_state = new CubeState(origState); bc.Act(a_bc_state); a.Act(a_bc_state); Utils.DebugAssert(a_b_c_state.Equals(ab_c_state)); Utils.DebugAssert(a_b_c_state.Equals(a_bc_state)); } }
public static void VerifyCubeTurnAround() { for (int caseIdx = 0; caseIdx < 100; caseIdx++) { CubeState cubeState = CubeAction.RandomCube(Utils.GlobalRandom.Next(1, 30)); foreach (CubeOp.Type op in Enum.GetValues(typeof(CubeOp.Type))) { var action = new CubeAction(new int[] { (int)op }); CubeState newCubeState = new CubeState(cubeState); for (int i = 0; i < CubeState.TurnAround; i++) { action.Act(newCubeState); } Utils.DebugAssert(newCubeState.Equals(cubeState)); } } for (int caseIdx = 0; caseIdx < 100; caseIdx++) { CubeState cubeState = CubeAction.RandomCube(Utils.GlobalRandom.Next(1, 30)); foreach (CubeOp.Type op in Enum.GetValues(typeof(CubeOp.Type))) { var action = new CubeAction(new int[] { (int)op, (int)op, (int)op }); CubeState newCubeState = new CubeState(cubeState); for (int i = 0; i < CubeState.TurnAround; i++) { action.Act(newCubeState); } Utils.DebugAssert(newCubeState.Equals(cubeState)); } } for (int caseIdx = 0; caseIdx < 100; caseIdx++) { CubeState cubeState = CubeAction.RandomCube(Utils.GlobalRandom.Next(1, 30)); foreach (CubeOp.Type op in Enum.GetValues(typeof(CubeOp.Type))) { var action = new CubeAction(new int[] { (int)op, (int)op }); CubeState newCubeState = new CubeState(cubeState); for (int i = 0; i < CubeState.TurnAround / 2; i++) { action.Act(newCubeState); } Utils.DebugAssert(newCubeState.Equals(cubeState)); } } }