rubikscube

college code for finding optimal rubiks cube solutions in java

git clone https://9o.is/git/rubikscube.git

commit be4b84b5626603206fe46410e4356aaf7833acfc
parent a88b1992ff8f520477a0a797414431ad74d3a8d1
Author: Jul <jul@9o.is>
Date:   Fri, 26 Oct 2012 18:39:08 -0400

Removed RubiksHalf2EdgeState

Diffstat:
Dsrc/RubiksHalf2EdgeState.java | 69---------------------------------------------------------------------
1 file changed, 0 insertions(+), 69 deletions(-)

diff --git a/src/RubiksHalf2EdgeState.java b/src/RubiksHalf2EdgeState.java @@ -1,69 +0,0 @@ -import java.util.LinkedList; -import java.util.List; - -/** - * Holds part of the edge state of the rubik's cube with a - * heuristic that measures the amount of moves away from - * the goal state. - */ -public class RubiksHalf2EdgeState extends RubiksSubState { - private final String[][] COMBINATIONS = { - {"YO", "OY"}, - {"OG", "GO"}, - {"BO", "OB"}, - {"OW", "WO"}, - {"GW", "WG"}, - {"WB", "BW"}}; - - public RubiksHalf2EdgeState(String state, int heuristic) throws Exception { - super(state, heuristic); - if(!isValid(state)) - throw new Exception(); - } - - public RubiksHalf2EdgeState(String state) throws Exception { - super(state); - if(!isValid(state)) - throw new Exception(); - } - - @Override - protected boolean isValid(String str) { - if(str.length() == 12) { - List<Integer> edgesChecked = new LinkedList<Integer>(); - for(int i=0; i<str.length(); i+=2) { - String edge = - str.substring(i,i+2).toUpperCase(); - int check = isValidEdge(edge); - if(check == -1) return false; - else { - for(int edgesUsed : edgesChecked) { - if(edgesUsed == check) return false; - } - edgesChecked.add(check); - } - } - return true; - } - return false; - } - - @Override - //TODO - protected int hashState() { - return 0; - } - - /* - * Returns which edge out of all combinations is the string - * or -1 if it didn't match any. - */ - private int isValidEdge(String edge) { - for(int i=0; i<COMBINATIONS.length; i++) - for(int j=0; j<COMBINATIONS[i].length; j++) { - if(COMBINATIONS[i][j].equals(edge)) - return i; - } - return -1; - } -}