Skip to content

Commit a38166f

Browse files
committed
Added FMC, thus all WCA events are added!
1 parent 8435765 commit a38166f

File tree

4 files changed

+93
-10
lines changed

4 files changed

+93
-10
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ square-1
3535

3636
#### Event modifiers
3737
`-b` (or `-B`) will generate scrambles for blindfolded events for 3x3, 4x4 and 5x5.
38-
###### NOTE: May work on FMC
38+
39+
<hr>
40+
41+
`-f` will generate fmc scrambles. This will only work for 3x3
3942

4043
<hr>
4144

src/Scrambles.hpp

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static std::string Two_By_Two()
7777
return scramble;
7878
}
7979

80-
static std::string Three_By_Three(bool blind)
80+
static std::string Three_By_Three(const bool blind)
8181
{
8282
std::string scramble;
8383
puzzle_move Move{};
@@ -125,6 +125,49 @@ static std::string Three_By_Three(bool blind)
125125
return scramble;
126126
}
127127

128+
static std::string FMC(){
129+
// R' U' F ... R' U' F
130+
131+
std::string scramble;
132+
133+
const puzzle_move R_Prime{'R', '\'', ' '};
134+
const puzzle_move U_Prime{'U', '\'', ' '};
135+
const puzzle_move F {'F', ' ', ' '};
136+
137+
scramble += getRepresentation(&R_Prime) + ' ' + getRepresentation(&U_Prime) + ' ' + getRepresentation(&F) + ' ';
138+
139+
puzzle_move Move = F;
140+
puzzle_move PrevMove = U_Prime;
141+
puzzle_move TwoPrevMove = R_Prime;
142+
const int moveCount = getRandomNum(19, 27) - 6;
143+
144+
TwoPrevMove = PrevMove;
145+
PrevMove = Move;
146+
147+
for (int i = 0; i < moveCount-1; i++)
148+
{
149+
do
150+
{
151+
createMove(Move, '3');
152+
} while (!canUseMove(&TwoPrevMove, &PrevMove, &Move));
153+
154+
scramble += getRepresentation(&Move) + ' ';
155+
TwoPrevMove = PrevMove;
156+
PrevMove = Move;
157+
}
158+
159+
// Generate last 3 moves. Make sure that the first R' is compatible with the last 2 moves.
160+
161+
do
162+
{
163+
createMove(Move, '3');
164+
} while (!canUseMove(&PrevMove, &Move, &R_Prime));
165+
166+
scramble += getRepresentation(&Move) + ' ' + getRepresentation(&R_Prime) + ' ' + getRepresentation(&U_Prime) + ' ' + getRepresentation(&F) + ' ';
167+
168+
return scramble;
169+
}
170+
128171
static std::string Four_By_Four(bool blind)
129172
{
130173
std::string scramble;
@@ -419,15 +462,22 @@ static std::string Clock()
419462
}
420463

421464
// Use this one
422-
inline std::string generate_scramble(const char cube, bool blind)
465+
inline std::string generate_scramble(const char cube, const bool blind, const bool fmc)
423466
{
424467
switch (cube)
425468
{
426469
case '2':
427470
return Two_By_Two();
428471

429472
case '3':
430-
return Three_By_Three(blind);
473+
if(fmc)
474+
{
475+
return FMC();
476+
}
477+
else
478+
{
479+
return Three_By_Three(blind);
480+
}
431481

432482
case '4':
433483
return Four_By_Four(blind);

src/cmdLineParser.hpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct should
1616
bool shouldShowAvg;
1717
bool needEnter;
1818
bool blindfolded;
19+
bool fmc;
1920
};
2021

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

174+
static bool fmc(std::vector<std::string> &args){
175+
for (size_t i = 0; i < args.size(); i++)
176+
{
177+
if (args.at(i).substr(0, 2) == "-f" || args.at(i).substr(0, 2) == "-F")
178+
{
179+
if (getCubeType(args) == '3')
180+
{
181+
if (!blindfolded(args))
182+
{
183+
return true;
184+
}
185+
else
186+
{
187+
std::cout << "Incompatible arguments: -f cannot be used with non-blindfolded cubes.\n";
188+
return false;
189+
}
190+
}
191+
else
192+
{
193+
std::cout << "Incompatible arguments: -f can only be used with 3x3 cubes.\n";
194+
return false;
195+
}
196+
}
197+
}
198+
return false;
199+
}
200+
173201
inline void setup(struct should &Options, cmdLineArgs)
174202
{
175203
// Pre-checks
176204
// These are for like `help` or `--version`
177205

178-
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] \
206+
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] \
179207
\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.\
180208
It is required (why else would you use it?)\n\n[c] means [c]ontinuous, meaning it won't stop after generating one scramble.\
181-
\n\nArgument [-b] gives scrambles for blindfolded solves for 3x3, 4x4 and 5x5\
209+
\n\nArgument [-b] gives scrambles for blindfolded solves for 3x3, 4x4 and 5x5 \
210+
\n\nArgument [-f(mc)] gives scrambles for fmc for 3x3. \
182211
\n--count{number} can be used to specify how many scrambles you want. Continuous is impiled. It will then quit (with code 0).\
183212
\n\nArgument [-s] is for saving to a file which name will come directly after [-s] (e.g. CLI_Timer 3 -s3x3_One_Handed).\
184213
\nIt will save to a .CLI_T_S (CLI_Timer_Session) file. Check README.md to see where it goes on your OS.\
@@ -217,6 +246,7 @@ inline void setup(struct should &Options, cmdLineArgs)
217246
std::cout << "CLI_Timer version: 1.13.1\n\n";
218247
std::cout << "Did some formatting." << std::endl;
219248
std::cout << "Added: blindfolded for 3x3, 4x4 and 5x5." << std::endl;
249+
std::cout << "Added: FMC (The ugliest function ever!)" << std::endl;
220250

221251
exit(EXIT_SUCCESS);
222252
}
@@ -230,4 +260,5 @@ inline void setup(struct should &Options, cmdLineArgs)
230260
Options.shouldShowAvg = shouldShowAvg(arguments);
231261
Options.needEnter = needEnter(arguments);
232262
Options.blindfolded = blindfolded(arguments);
263+
Options.fmc = fmc(arguments);
233264
}

src/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ int main(int argc, char const *argv[])
6969
return 1;
7070
}
7171

72-
struct should Args
73-
{
74-
};
72+
struct should Args{};
73+
7574
setup(Args, argc, argv);
7675
std::vector<float> timesVector;
7776

7877
do
7978
{ // while (Args.shouldContinue);
80-
string currentScramble = generate_scramble(Args.cubeType, Args.blindfolded);
79+
string currentScramble = generate_scramble(Args.cubeType, Args.blindfolded, Args.fmc);
8180
// Get scramble
8281

8382
cout << currentScramble;

0 commit comments

Comments
 (0)