Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rubix/Inc/Cube.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ void R_PRIME(uint64_t num_of_turns);
void L_PRIME(uint64_t num_of_turns);
void B_PRIME(uint64_t num_of_turns);
void apply_moves(std::string moves);
void apply_move_index(int move_index);
};
Comment on lines 128 to 132
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply_moves(std::string ...) uses std::string, but Cube.h doesn’t include <string>. This makes the header non-self-contained and can fail to compile when Cube.h is included before any <string> include. Please add #include <string> to Cube.h (or otherwise ensure std::string is declared before use).

Copilot uses AI. Check for mistakes.

#endif /* CUBE_H */
48 changes: 23 additions & 25 deletions Rubix/Inc/Solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ struct TargetState {
masks[face_index] = 0;
}

// Re-enable checking for a specific sticker position
void set_relevant(uint8_t face_index, uint8_t position) {
SET_COLOR(masks[face_index], position, 0xFFU);
}

// Re-enable checking for an entire face
void set_face_relevant(uint8_t face_index) {
masks[face_index] = 0xFFFFFFFFFFFFFFFF;
}

// Compare a cube with this target state, respecting don't care masks
bool matches_cube(const RubixCube& cube) const {
for(int i = 0; i < 6; i++) {
Expand All @@ -73,11 +83,12 @@ class Solver{
"B", "B'", "B2"
};

// Helper function to check if a cube matches a target state
bool matches_target(const RubixCube& cube, const TargetState& target);

std::string Solve_DFS(RubixCube current_cube, TargetState target_state, std::string Moves, int depth_remaining);
std::string Solve_IDFS(RubixCube given_cube, TargetState target_state, int Depth_Limit);
std::string Solve_IDFS(RubixCube given_cube, const TargetState& target_state, int Depth_Limit);
bool Solve_DFS_fast(RubixCube current_cube, const TargetState& target_state,
std::vector<int>& path, int depth_remaining, int prev_move);

bool has_white_cross(RubixCube& cube);
bool has_white_corners(RubixCube& cube);
bool has_second_layer(RubixCube& cube);
Expand All @@ -87,31 +98,18 @@ class Solver{
std::string solve_second_layer(RubixCube& cube);
std::string solve_bottom_cross(RubixCube& cube);
std::string solve_bottom_corners(RubixCube& cube);

// Helper function to check if a move would undo the previous move
bool is_redundant_move(const std::string& current_move, const std::string& previous_move) const {
if (previous_move.empty()) return false;

// Get the base move (without prime or 2)
char current_base = current_move[0];
char prev_base = previous_move[0];

// Same face moves are redundant
if (current_base == prev_base) return true;

// Check if current move would undo previous move
if (current_base == prev_base) {
// If previous was prime and current is not, or vice versa
if ((previous_move.find("PRIME") != std::string::npos && current_move.find("PRIME") == std::string::npos) ||
(previous_move.find("PRIME") == std::string::npos && current_move.find("PRIME") != std::string::npos)) {
return true;
}
}


// Move index redundancy: groups of 3 (L/L'/L2 = group 0, R/R'/R2 = group 1, ...)
// Opposite pairs: (0,1)=L/R, (2,3)=U/D, (4,5)=F/B
bool is_redundant_move_idx(int current_idx, int prev_idx) const {
if (prev_idx < 0) return false;
int cur_group = current_idx / 3;
int prev_group = prev_idx / 3;
if (cur_group == prev_group) return true;
if (cur_group % 2 == 0 && prev_group == cur_group + 1) return true;
return false;
}

// DFS count for tracking search progress
int dfs_count;

public:
Expand Down
Loading