Skip to content

RubikHelper API RubikSolver

Fabio Di Monte edited this page Apr 30, 2015 · 11 revisions

Overview | Details | Examples

Overview

RubikHelper.static.RubikSolver

Static Class that provides all solving methods needed to clear a scrambled cube.

Properties | Methods

Properties

name type notes
explainArray Array
solveArray Array

Methods

name returns notes
explainCallback(name, value) void

RubikSolver.check

Group of methods for various checks before the solving process begins.

name returns notes
orientedCube(cube) Boolean Checks if the cube is correctly oriented.
correctPieces(cube) Boolean Checks if cube have no duplicated pieces.

RubikSolver.service

Group of methods used during the solving process.

name returns notes
freeTarget(cube, type, medgeSafe, full) `String Array
opposite(piece, is_buffer) String Returns the opposite piece of the given one.

RubikSolver.solve

Group of methods for the solving process.

name returns notes
explain(cube) Object Returns an object with solve and explain arrays.
full(cube, type) Array Returns the complete list of moves to solve the given cube.
pieces(cube, buffer, MR) Array Solves a single type of pieces (edges or corners) from a scrambled cube.
edgesUnoriented(cube) Array Returns a list of orient patterns to correctly orient all the edges.
mEdgesUnoriented(flipped) Array Returns an array of orient patterns to correctly orient all M-Edges.

Details

Properties | Methods

Properties detailed

explainArray

RubikHelper.static.RubikSolver.explainArray = []

solveArray

RubikHelper.static.RubikSolver.solveArray = []

Methods detailed

explainCallback

RubikHelper.static.RubikSolver.explainCallback(name, value)
  • params
    • {String} name :
    • {String} value :
  • returns void

check.orientedCube

RubikHelper.static.RubikSolver.check.orientedCube(cube)

Returns TRUE if the cube is correctly oriented (F on Front, U on Up, ...), FALSE otherwise.

  • params
    • {Object} cube : the scrambled cube to check
  • returns
    • {Boolean}

check.correctPieces

RubikHelper.static.RubikSolver.check.correctPieces(cube)

Returns TRUE if all pieces are single instances.

  • params
    • {Object} cube : the scrambled cube to check
  • returns
    • {Boolean}

service.freeTarget

RubikHelper.static.RubikSolver.service.freeTarget(cube, type, medgeSafe, fullList)

Returns the first unoriented/unpermuted piece of given cube.

  • params
    • {Object} cube : the scrambled cube to search into
    • {Number} type : the type of piece to search for
    • {Boolean} medgeSafe : if true, pieces on M-slice will be considered solved regardless of their rotation
    • {Boolean} fullList : whether should return the first quicker piece left to solve, or the full list of pieces
  • returns
    • {String} : the unoriented/unpermuted piece
    • {Array} : the list of unoriented/unpermuted pieces if fullList = true
    • {Boolean} : FALSE if nothing found

Notes
type=1 : searches for both edges and corners
type=2 : searches for edges
type=3 : searches for corners

service.opposite

RubikHelper.static.RubikSolver.service.opposite(piece, is_buffer)

Returns the opposite piece of the one passed as argument, considering the M2/R2 pattern.

  • params
    • {String} piece : the piece to search for
    • {Boolean} is_buffer : whether it will opposite pieces on buffer line or not
  • returns
    • {String}

Notes
this method will only return the opposite of [UF|FU], [DB|BD], [URF|RFU|FUR], [DRB|BDR|RBD]
when is_buffer = true it will return the opposite of [DF|FD], [UB|BU], [DFR|RDF|FRD], [UBR|RUB|BRU]
the returned piece will have the same orientation of given piece
if the piece is not an M-slice's edge or an R-face's corner, it will return the piece itself

solve.explain

RubikHelper.static.RubikSolver.solve.explain(cube)

It calls solve.full() and returns an object with solve (s) and explain (e) arrays.

  • params
    • {Object} cube : the scrambled cube to be solved
  • returns
    • {Object}
      • {Array} s : solve array
      • {Array} e : explain array

Notes
the explain array should be evaluated by RubikTeacher.explainAll method

solve.full

RubikHelper.static.RubikSolver.solve.full(cube, type)

Returns the complete list of moves to solve the given cube.

  • params
    • {Object} cube : the scrambled cube to be solved
    • {Number} type : the type of return (default: 0)
  • returns
    • {Array} : depending on type param, will return the solving sequence with M2R2 method

Notes
type=0 : the list of pieces and patterns to execute in the correct order
type=1 : the uncollapsed list of moves
type=2 : the collapsed list of moves
type=3 : the inverted list of moves (ie. the scramble list of moves)

solve.pieces

RubikHelper.static.RubikSolver.solve.pieces(cube, buffer, MR)

Solves a single type of pieces (edges or corners) from a scrambled cube.

  • params
    • {Object} cube : the scrambled cube to be solved
    • {String} buffer : the buffer piece
    • {Array} MR : list of moves between setup and unsetup (M2 or R2)
  • returns
    • {Array} : ordered list of pieces to be moved

solve.edgesUnoriented

RubikHelper.static.RubikSolver.solve.edgesUnoriented(cube)

Returns a list of orient patterns to correctly orient all the edges.

  • params
    • {Object} cube : the scrambled cube to be solved
  • returns
    • {Array}

solve.mEdgesUnoriented

RubikHelper.static.RubikSolver.solve.mEdgesUnoriented(flipped)

Returns an array of orient patterns to correctly orient all M-Edges.

  • params
    • {Array} flipped :
  • returns
    • {Array}