private static bool DoAllTheMoves(Cube cube, byte depth, byte prevMove, byte prevPrevMove, PruneTable prune, byte startDepth) { if (depth == 0) //all moves done on all depths { if (prune.table.Count() < prune.maxCount) { int index = CalculateIndex(cube, prune); prune.AddIndex(index, startDepth); //adds if not already added return(false); } else { return(true); //done! all indices found } } else { for (byte move = 0; move < 18; move++) //go through all moves { if (Algorithm.IsAllowedMove(move, prevMove, prevPrevMove)) { Cube newCube = new Cube(cube); Algorithm.DoMove(newCube, move); if (DoAllTheMoves(newCube, (byte)(depth - 1), move, prevMove, prune, startDepth)) { return(true); } } } } return(false); }