diff core.js @ 898:070a90d1117c

Merge from the default branch
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Tue, 16 Jun 2015 14:14:08 +0100
parents b7f262db9886
children d350e20bddd1
line wrap: on
line diff
--- a/core.js	Thu Jun 11 10:06:58 2015 +0100
+++ b/core.js	Tue Jun 16 14:14:08 2015 +0100
@@ -1100,8 +1100,14 @@
 {
 	// This takes an array of information and randomises the order
 	var N = input.length;
-	var K = N;
+	
+	var inputSequence = []; // For safety purposes: keep track of randomisation
+	for (var counter = 0; counter < N; ++counter) 
+		inputSequence.push(counter) // Fill array
+	var inputSequenceClone = inputSequence.slice(0);
+	
 	var holdArr = [];
+	var outputSequence = [];
 	for (var n=0; n<N; n++)
 	{
 		// First pick a random number
@@ -1110,7 +1116,11 @@
 		r = Math.floor(r*input.length);
 		// Pick out that element and delete from the array
 		holdArr.push(input.splice(r,1)[0]);
+		// Do the same with sequence
+		outputSequence.push(inputSequence.splice(r,1)[0]);
 	}
+	console.log(inputSequenceClone.toString()); // print original array to console
+	console.log(outputSequence.toString()); 	// print randomised array to console
 	return holdArr;
 }