Skip to content

Commit

Permalink
Move handler problem resolved issue : in scramble read we were changi…
Browse files Browse the repository at this point in the history
…ng the original array since only the reference of array was stored
  • Loading branch information
adityaganesh2k committed Mar 5, 2022
1 parent 2e1b97a commit 6744b69
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/CubeD/CubeThree/cube_scramble_read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
/**
FUNCTION NAME : SCRAMBLE READ
DESC : THIS GIVES A FORMATTED ARRAY FOR THE MOVES ARRAY PASSED
INPUT PARAMETERS : scramble - MOVES TBD IN ( string[] )
INPUT PARAMETERS : moves - MOVES TBD IN ( string[] )
url1 - MOVES TBD IN ( STRING )
cube - MOVES ALREADY DONE ON THE CUBE ( STRING )
but - 0- TBD IN NORMAL SEQUENCE 1- TBD IN REVERSE SEQUENCE
OUTPUT PARAMETERS : LEGAL MOVES ARRAY ( FORMAT( -1/1_MOVES_1/2 ) : 1: - CLOCKWISE FOR ( F,R,U,X,Y,Z,S ), -1 : - CLOCKWISE FOR ( L,D,B,M,E ) , MOVES , NO.OF ROTATIONS )
*/
function scramble_read(
scramble: string[],
moves: string[],
but: number,
): string[] {
var flag = 0;//USED TO KEEP TRACK HOW MANY MOVES HAVE BEEN EXECUTED ON THE CUBE
//var ar = 0;
var lay = [];

var scramble = [];
/***********USED FOR GENERATING ARRAY FOR INVERSING MOVES *************/
if (but == 1) {
scramble = scramble.reverse();
scramble = moves.reverse();

for (var i = 0; i < scramble.length; i++)
{
Expand Down Expand Up @@ -268,6 +268,7 @@ function scramble_read(
/***********USED FOR GENERATING ARRAY FOR LEGAL MOVES NORMAL SEQUENCE*************/
if (but == 0)
{
scramble = moves.slice();
for (var i = 0; i < scramble.length; i++)
{
//CLOCKWISE MOVES ALONG R,F,U,x,y,z,S
Expand Down

0 comments on commit 6744b69

Please sign in to comment.