public bool Equals(UnitRotation other) { if (other == null) { return(false); } return(Id.Equals(other.Id)); }
public Cube Rotate(UnitRotation rotation) { var side = GetSide(rotation.Direction); var pieces = side.Pieces; var others = Positions.Except(pieces); var rotated = pieces.Select(x => x.Rotate(rotation)); return(new Cube(rotated.Concat(others), Rotations.Concat(new [] { rotation }))); }
public Cube Scramble(int iterations = 200) { var cube = this; UnitRotation previous = null; while (iterations > 0) { var rotation = Rotation.AllRotations.Values.Where(x => !x.Reverse.Equals(previous)).ToList().SelectRandom(); cube = cube.Rotate(rotation); previous = rotation; iterations--; } return(cube); }