Skip to content

Commit

Permalink
fix: Made the scramble making 10 times faster
Browse files Browse the repository at this point in the history
  • Loading branch information
RaZeSloth committed Jan 11, 2023
1 parent 0830299 commit c9d2041
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions src/rubiks_cube_scrambler/scrambler.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,13 @@ void scrambleReplace()



void valid()
{
// Stage 3
// Variables for loop
int loopOne, loopTwo;

// This will actually start to make the scramble usable
// It will remove stuff like R R F L, etc.
for (loopOne = 1; loopOne < SLEN; loopOne++)
{
while (a.mainScramble[loopOne][0] == a.mainScramble[loopOne - 1][0])
{
a.mainScramble[loopOne][0] = moves[getRand(5, 0)];
}
}

// This will further check it and remove stuff like R L R
for (loopTwo = 2; loopTwo < SLEN; loopTwo++)
{
while ((a.mainScramble[loopTwo][0] == a.mainScramble[loopTwo - 2][0]) || (a.mainScramble[loopTwo][0]) == a.mainScramble[loopTwo - 1][0])
{
a.mainScramble[loopTwo][0] = moves[getRand(5, 0)];
}
}
// Scramble generation complete
void valid() {
for (int i = 2; i < SLEN; i++) {
while ( a.mainScramble[i][0] == a.mainScramble[i - 2][0] || a.mainScramble[i][0] == a.mainScramble[i - 1][0]) {
a.mainScramble[i][0] = moves[rand()%5];
}
}
// Scramble generation complete
}

int getRand(int upr, int lwr)
Expand Down

0 comments on commit c9d2041

Please sign in to comment.