Me: Why are all the mobs clustering in the south?!
(function() { let t={n:0,e:0,s:0,w:0}; for (let i=0; i<100000; ++i) {let arr = ["n", "e", "s", "w"]; arrayShuffle(arr); let f=arr[0]; t[f] += 1; } return t; } )()
{n: 0, e: 33421, s: 33361, w: 33218}
Oh, you have got to be shitting me. I've been using a broken shuffle function for years.
Corrected function:
/** Fisher-Yates */
function arrayShuffle(arr) {
for (var i = arr.length-1; i >= 1; --i) {
let j = Math.floor(Math.random() * (i+1));
let tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
return arr;
}
See that (i+1)? Yeah, that was just i before. Now I gotta find every place I've copy-pasted the wrong one.
I've been programming for 40 years. I still fuck up and call myself a moron every single fucking day.
Best career choice. Totally nailed that one. I'm a fine specimen of Homo habilis, first toolmaker.
@mdhughes Yes. I find that few other careers so help you find humility.