Skip to content

Commit

Permalink
Added FMC, thus all WCA events are added!
Browse files Browse the repository at this point in the history
  • Loading branch information
1Codealot committed Nov 25, 2023
1 parent 8435765 commit a38166f
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ square-1

#### Event modifiers
`-b` (or `-B`) will generate scrambles for blindfolded events for 3x3, 4x4 and 5x5.
###### NOTE: May work on FMC

<hr>

`-f` will generate fmc scrambles. This will only work for 3x3

<hr>

Expand Down
56 changes: 53 additions & 3 deletions src/Scrambles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static std::string Two_By_Two()
return scramble;
}

static std::string Three_By_Three(bool blind)
static std::string Three_By_Three(const bool blind)
{
std::string scramble;
puzzle_move Move{};
Expand Down Expand Up @@ -125,6 +125,49 @@ static std::string Three_By_Three(bool blind)
return scramble;
}

static std::string FMC(){
// R' U' F ... R' U' F

std::string scramble;

const puzzle_move R_Prime{'R', '\'', ' '};
const puzzle_move U_Prime{'U', '\'', ' '};
const puzzle_move F {'F', ' ', ' '};

scramble += getRepresentation(&R_Prime) + ' ' + getRepresentation(&U_Prime) + ' ' + getRepresentation(&F) + ' ';

puzzle_move Move = F;
puzzle_move PrevMove = U_Prime;
puzzle_move TwoPrevMove = R_Prime;
const int moveCount = getRandomNum(19, 27) - 6;

TwoPrevMove = PrevMove;
PrevMove = Move;

for (int i = 0; i < moveCount-1; i++)
{
do
{
createMove(Move, '3');
} while (!canUseMove(&TwoPrevMove, &PrevMove, &Move));

scramble += getRepresentation(&Move) + ' ';
TwoPrevMove = PrevMove;
PrevMove = Move;
}

// Generate last 3 moves. Make sure that the first R' is compatible with the last 2 moves.

do
{
createMove(Move, '3');
} while (!canUseMove(&PrevMove, &Move, &R_Prime));

scramble += getRepresentation(&Move) + ' ' + getRepresentation(&R_Prime) + ' ' + getRepresentation(&U_Prime) + ' ' + getRepresentation(&F) + ' ';

return scramble;
}

static std::string Four_By_Four(bool blind)
{
std::string scramble;
Expand Down Expand Up @@ -419,15 +462,22 @@ static std::string Clock()
}

// Use this one
inline std::string generate_scramble(const char cube, bool blind)
inline std::string generate_scramble(const char cube, const bool blind, const bool fmc)
{
switch (cube)
{
case '2':
return Two_By_Two();

case '3':
return Three_By_Three(blind);
if(fmc)
{
return FMC();
}
else
{
return Three_By_Three(blind);
}

case '4':
return Four_By_Four(blind);
Expand Down
35 changes: 33 additions & 2 deletions src/cmdLineParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct should
bool shouldShowAvg;
bool needEnter;
bool blindfolded;
bool fmc;
};

static char getCubeType(std::vector<std::string> &args)
Expand Down Expand Up @@ -170,15 +171,43 @@ static bool blindfolded(std::vector<std::string> &args){
return false;
}

static bool fmc(std::vector<std::string> &args){
for (size_t i = 0; i < args.size(); i++)
{
if (args.at(i).substr(0, 2) == "-f" || args.at(i).substr(0, 2) == "-F")
{
if (getCubeType(args) == '3')
{
if (!blindfolded(args))
{
return true;
}
else
{
std::cout << "Incompatible arguments: -f cannot be used with non-blindfolded cubes.\n";
return false;
}
}
else
{
std::cout << "Incompatible arguments: -f can only be used with 3x3 cubes.\n";
return false;
}
}
}
return false;
}

inline void setup(struct should &Options, cmdLineArgs)
{
// Pre-checks
// These are for like `help` or `--version`

std::string helpMSG{"How to use CLI_Timer.\nCLI_Timer (cube type) [-b] [--count{number}] [--no_enter] | [c] | [-s{session name}] | [--no_prompt] | [--no_avg] \
std::string helpMSG{"How to use CLI_Timer.\nCLI_Timer (cube type) [-b] | [-f(mc))] [--count{number}] [--no_enter] | [c] | [-s{session name}] | [--no_prompt] | [--no_avg] \
\n\nArgument (cube type) means an NxN of (2)x2 (3)x3 to (7)x7 or (S)kewb, (P)yraminx, (M)egaminx, (C)lock or s(Q)uare-1.\
It is required (why else would you use it?)\n\n[c] means [c]ontinuous, meaning it won't stop after generating one scramble.\
\n\nArgument [-b] gives scrambles for blindfolded solves for 3x3, 4x4 and 5x5\
\n\nArgument [-b] gives scrambles for blindfolded solves for 3x3, 4x4 and 5x5 \
\n\nArgument [-f(mc)] gives scrambles for fmc for 3x3. \
\n--count{number} can be used to specify how many scrambles you want. Continuous is impiled. It will then quit (with code 0).\
\n\nArgument [-s] is for saving to a file which name will come directly after [-s] (e.g. CLI_Timer 3 -s3x3_One_Handed).\
\nIt will save to a .CLI_T_S (CLI_Timer_Session) file. Check README.md to see where it goes on your OS.\
Expand Down Expand Up @@ -217,6 +246,7 @@ inline void setup(struct should &Options, cmdLineArgs)
std::cout << "CLI_Timer version: 1.13.1\n\n";
std::cout << "Did some formatting." << std::endl;
std::cout << "Added: blindfolded for 3x3, 4x4 and 5x5." << std::endl;
std::cout << "Added: FMC (The ugliest function ever!)" << std::endl;

exit(EXIT_SUCCESS);
}
Expand All @@ -230,4 +260,5 @@ inline void setup(struct should &Options, cmdLineArgs)
Options.shouldShowAvg = shouldShowAvg(arguments);
Options.needEnter = needEnter(arguments);
Options.blindfolded = blindfolded(arguments);
Options.fmc = fmc(arguments);
}
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ int main(int argc, char const *argv[])
return 1;
}

struct should Args
{
};
struct should Args{};

setup(Args, argc, argv);
std::vector<float> timesVector;

do
{ // while (Args.shouldContinue);
string currentScramble = generate_scramble(Args.cubeType, Args.blindfolded);
string currentScramble = generate_scramble(Args.cubeType, Args.blindfolded, Args.fmc);
// Get scramble

cout << currentScramble;
Expand Down

0 comments on commit a38166f

Please sign in to comment.