Пример #1
0
    public void SetResources(RubiksCubeModel fullCubeModel, RubiksCubeView fullCubeView, RubiksCubeSolver fullCubeSolver,
                             CubeModel[] cubeArrayTop, CubeModel[] cubeArrayMiddleHorizontal, CubeModel[] cubeArrayBottom,
                             ActionQueueController queueController, ActionQueueModel queueModel)
    {
        this._fullCubeModel  = fullCubeModel;
        this._fullCubeView   = fullCubeView;
        this._fullCubeSolver = fullCubeSolver;

        //this._fullCubeModel.SetRubiksCubeController (this);
        this._fullCubeView.SetRubiksCubeController(this);
        this._fullCubeSolver.SetRubiksCubeController(this);

        this._cubeArrayTop = cubeArrayTop;
        this._cubeArrayMiddleHorizontal = cubeArrayMiddleHorizontal;
        this._cubeArrayBottom           = cubeArrayBottom;

        this._queueController = queueController;
        this._queueController.SetActionQueueModel(queueModel);

        for (int i = 0; i < 9; i++)
        {
            this._cubeArrayTop[i].SetRubiksCubeController(this);
            this._cubeArrayMiddleHorizontal[i].SetRubiksCubeController(this);
            this._cubeArrayBottom[i].SetRubiksCubeController(this);

            _fullCubeModel.GiveCubes(this._cubeArrayTop, this._cubeArrayMiddleHorizontal, this._cubeArrayBottom);
        }
    }
Пример #2
0
        public BeginnersSolver(RubiksCubeModel model, Func <string, string> getContent)
        {
            _model = model;
            var cont = getContent(@"D:\Projects\RubiksCube\src\ScrarchEngine.Libraries.RubiksCube\Solver\Methods\Beginners\Patterns");

            _algorithms = JsonConvert.DeserializeObject <List <MoveAlgorithm> >(cont);
        }
Пример #3
0
        public BeginnersSolverTests()
        {
            _cube = new RubiksCubeModel();

            var now = DateTime.Now;

            Trace.Listeners.Add(new TextWriterTraceListener($@"D:\Projects\RubiksCube\tests\ScrarchEngine.Libraries.RubiksCube.Tests\bin\Debug\logs\{now.Day}d{now.Month}m{now.Year}y and {now.Hour}h{now.Minute}m{now.Second}s.txt"));
            Trace.AutoFlush = true;
        }
 private void RotateFaceCounterClockwise(int face, RubiksCubeModel fullCubeModel)
 {
     for (var z = 0; z < 3; z++)
     {
         for (var x = 0; x < 3; x++)
         {
             fullCubeModel.GetRubiksCubeBlock(x, face, z).RotateCube(Vector3.zero, Vector3.forward, fullCubeController.GetRotationDegree() * Time.deltaTime);
         }
     }
 }
 private void RotateSliceBackward(int slice, RubiksCubeModel fullCubeModel)
 {
     for (var z = 0; z < 3; z++)
     {
         for (var y = 2; y >= 0; y--)
         {
             fullCubeModel.GetRubiksCubeBlock(slice, y, z).RotateCube(Vector3.zero, Vector3.right, fullCubeController.GetRotationDegree() * Time.deltaTime);
         }
     }
 }
 private void RotateLayerCounterClockwise(int layer, RubiksCubeModel fullCubeModel)
 {
     for (var x = 0; x < 3; x++)
     {
         for (var y = 0; y < 3; y++)
         {
             fullCubeModel.GetRubiksCubeBlock(x, y, layer).RotateCube(Vector3.zero, Vector3.down, fullCubeController.GetRotationDegree() * Time.deltaTime);
         }
     }
 }
Пример #7
0
        private void LogError(string stage, int tryNumber, RubiksCubeModel cube, List <MoveAlgorithm> solution)
        {
            Trace.WriteLine($"{stage} solving failed on {tryNumber} try out of {RetriesCount}.");
            Trace.WriteLine($"Cube front face: {cube.GetFace(FaceType.Front).ToString()}");
            Trace.WriteLine($"Cube back face: {cube.GetFace(FaceType.Back).ToString()}");
            Trace.WriteLine($"Cube left face: {cube.GetFace(FaceType.Left).ToString()}");
            Trace.WriteLine($"Cube right face: {cube.GetFace(FaceType.Right).ToString()}");
            Trace.WriteLine($"Cube up face: {cube.GetFace(FaceType.Up).ToString()}");
            Trace.WriteLine($"Cube down face: {cube.GetFace(FaceType.Down).ToString()}");
            Trace.WriteLine($"Solution: {string.Join(", ", solution.Select(a => a.ToString()))}");

            Assert.Fail($"{stage} solving failed on {tryNumber} try out of {RetriesCount}.");
        }
Пример #8
0
        public DfsSolver(RubiksCubeModel model)
        {
            _model = model;

            getState = (f) =>
            {
                var state = new Dictionary <FaceType, int[, ]>();
                foreach (var faceItem in f)
                {
                    var face = new int[3, 3];
                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            face[i, j] = (int)faceItem[i, j];
                        }
                    }
                    state.Add(faceItem.Type, face);
                }
                return(state);
            };

            getFaces = (s) =>
            {
                var state = new Face[6];
                int k     = 0;
                foreach (var stateItem in s)
                {
                    var face = new Face(stateItem.Key);
                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            face[i, j] = (FacePieceType)stateItem.Value[i, j];
                        }
                    }
                    state[k] = face;
                    k++;
                }
                return(state);
            };

            getChildNode = (f, l, r) =>
            {
                var childNode = new Node(getState(f));
                childNode.Layer    = l;
                childNode.Rotation = r;
                return(childNode);
            };
        }
Пример #9
0
    void Start()
    {
        // Get the model
        _model = GetComponent <RubiksCubeModel>();

        // Instantiate the base values
        _isUserInputLocked = false;
        _isRotationLocked  = false;

        // Instantiate the random
        _random = new System.Random();

        // Create the face for the rotations
        _face             = new Face();
        _face._gameObject = new GameObject("Face");
        _face._gameObject.transform.parent = transform;

        // Set the camera to a base position
        _newCameraPos = Vector3.Slerp(_minCameraPosition.position, _maxCameraPosition.position, _currZoom);
        _camera.transform.position = _newCameraPos;
    }
 public void RotateMiddleFaceCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateFaceCounterClockwise((int)Face.MIDDLE, fullCubeModel);
 }
 public void RotateTopCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateLayerCounterClockwise((int)Layer.TOP, fullCubeModel);
 }
 public void ReverseCube(RubiksCubeModel fullCubeModel)
 {
     RotateCubeLeft(fullCubeModel);
     RotateCubeLeft(fullCubeModel);
 }
 public void RotateMiddleHorizontalRight(RubiksCubeModel fullCubeModel)
 {
     RotateLayerCounterClockwise((int)Layer.MIDDLE, fullCubeModel);
 }
 public void RotateCubeBackwards(RubiksCubeModel fullCubeModel)
 {
     RotateLeftCounterClockwise(fullCubeModel);
     RotateMiddleVerticalBackwards(fullCubeModel);
     RotateRightClockwise(fullCubeModel);
 }
 public void RotateCubeRight(RubiksCubeModel fullCubeModel)
 {
     RotateTopCounterClockwise(fullCubeModel);
     RotateMiddleHorizontalRight(fullCubeModel);
     RotateBottomClockwise(fullCubeModel);
 }
 public void RotateBackCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateFaceClockwise((int)Face.BACK, fullCubeModel);
 }
 public void RotateCubeCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateFrontCounterClockwise(fullCubeModel);
     RotateMiddleFaceCounterClockwise(fullCubeModel);
     RotateBackClockwise(fullCubeModel);
 }
 public void RotateFrontCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateFaceCounterClockwise((int)Face.FRONT, fullCubeModel);
 }
Пример #19
0
 public void Init()
 {
     _cube = new RubiksCubeModel();
 }
Пример #20
0
 public TwoWayBfsSolver(RubiksCubeModel model)
 {
     _model = model;
 }
 public void RotateRightCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateSliceForward((int)Slice.RIGHT, fullCubeModel);
 }
 public void RotateMiddleVerticalBackwards(RubiksCubeModel fullCubeModel)
 {
     RotateSliceBackward((int)Slice.MIDDLE, fullCubeModel);
 }
 public void RotateLeftCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateSliceBackward((int)Slice.LEFT, fullCubeModel);
 }
 public void RotateBottomCounterClockwise(RubiksCubeModel fullCubeModel)
 {
     RotateLayerClockwise((int)Layer.BOTTOM, fullCubeModel);
 }