diff core.js @ 678:1e736dc124ab

Added in randomiseOrder function in core.js. Updated calls in ape.js to randomise order of tests and elements.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 17 Apr 2015 09:41:31 +0100
parents e604ee22185b
children ab56aa2fe064
line wrap: on
line diff
--- a/core.js	Mon Apr 13 11:46:21 2015 +0100
+++ b/core.js	Fri Apr 17 09:41:31 2015 +0100
@@ -340,4 +340,22 @@
 			this.listenStart = 0;
 		}
 	};
+}
+
+function randomiseOrder(input)
+{
+	// This takes an array of information and randomises the order
+	var N = input.length;
+	var K = N;
+	var holdArr = [];
+	for (var n=0; n<N; n++)
+	{
+		// First pick a random number
+		var r = Math.random();
+		// Multiply and floor by the number of elements left
+		r = Math.floor(r*input.length);
+		// Pick out that element and delete from the array
+		holdArr.push(input.splice(r,1)[0]);
+	}
+	return holdArr;
 }
\ No newline at end of file