|
|
@@ -13,7 +13,7 @@ Authors: Tanish Bhongade and RaZe
|
|
|
// 6 moves along with direction
|
|
|
char moves[6] = {'R', 'U', 'F', 'B', 'L', 'D'};
|
|
|
char dir[4] = {' ', '\'', '2'};
|
|
|
-const int SLEN = 20;
|
|
|
+const int32_t SLEN = 20;
|
|
|
#define RESULT_SIZE 100
|
|
|
// Structure which holds main scramble
|
|
|
struct GetScramble
|
|
|
@@ -25,10 +25,7 @@ struct GetScramble a; // Its object
|
|
|
// Function prototypes to avoid bugs
|
|
|
void scrambleReplace();
|
|
|
void genScramble();
|
|
|
-void valid();
|
|
|
-int getRand(int upr, int lwr);
|
|
|
char *printData();
|
|
|
-void writeToFile();
|
|
|
|
|
|
// Main function
|
|
|
/* int main(){
|
|
|
@@ -44,7 +41,7 @@ void writeToFile();
|
|
|
void genScramble()
|
|
|
{
|
|
|
// Stage 1
|
|
|
- for (int i = 0; i < SLEN; i++)
|
|
|
+ for (int32_t i = 0; i < SLEN; i++)
|
|
|
{
|
|
|
strcpy(a.mainScramble[i], "00");
|
|
|
}
|
|
|
@@ -57,16 +54,16 @@ void scrambleReplace()
|
|
|
// Actual process begins here
|
|
|
|
|
|
// Initialize the mainScramble array with all the possible moves
|
|
|
- for (int i = 0; i < SLEN; i++)
|
|
|
+ for (int32_t i = 0; i < SLEN; i++)
|
|
|
{
|
|
|
a.mainScramble[i][0] = moves[furi_hal_random_get() % 6];
|
|
|
a.mainScramble[i][1] = dir[furi_hal_random_get() % 3];
|
|
|
}
|
|
|
|
|
|
// Perform the Fisher-Yates shuffle
|
|
|
- for (int i = 6 - 1; i > 0; i--)
|
|
|
+ for (int32_t i = 6 - 1; i > 0; i--)
|
|
|
{
|
|
|
- int j = rand() % (i + 1);
|
|
|
+ int32_t j = rand() % (i + 1);
|
|
|
char temp[3];
|
|
|
strcpy(temp, a.mainScramble[i]);
|
|
|
strcpy(a.mainScramble[i], a.mainScramble[j]);
|
|
|
@@ -74,11 +71,11 @@ void scrambleReplace()
|
|
|
}
|
|
|
|
|
|
// Select the first 10 elements as the scramble, using only the first three elements of the dir array
|
|
|
- for (int i = 0; i < SLEN; i++)
|
|
|
+ for (int32_t i = 0; i < SLEN; i++)
|
|
|
{
|
|
|
a.mainScramble[i][1] = dir[furi_hal_random_get() % 3];
|
|
|
}
|
|
|
- for (int i = 1; i < SLEN; i++) {
|
|
|
+ for (int32_t i = 1; 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[furi_hal_random_get()%5];
|
|
|
}
|
|
|
@@ -93,8 +90,8 @@ void scrambleReplace()
|
|
|
|
|
|
// Let this function be here for now till I find out what is causing the extra space bug in the scrambles
|
|
|
void remove_double_spaces(char *str) {
|
|
|
- int i, j;
|
|
|
- int len = strlen(str);
|
|
|
+ int32_t i, j;
|
|
|
+ int32_t len = strlen(str);
|
|
|
for (i = 0, j = 0; i < len; i++, j++) {
|
|
|
if (str[i] == ' ' && str[i + 1] == ' ') {
|
|
|
i++;
|
|
|
@@ -106,8 +103,8 @@ void remove_double_spaces(char *str) {
|
|
|
char *printData()
|
|
|
{
|
|
|
static char result[RESULT_SIZE];
|
|
|
- int offset = 0;
|
|
|
- for (int loop = 0; loop < SLEN; loop++)
|
|
|
+ int32_t offset = 0;
|
|
|
+ for (int32_t loop = 0; loop < SLEN; loop++)
|
|
|
{
|
|
|
offset += snprintf(result + offset, RESULT_SIZE - offset, "%s ", a.mainScramble[loop]);
|
|
|
}
|