Seed the Random Number Generator
Solution from davidbau.com Random Seeds, Coded Hints, and Quintillions
Add the following code to code_JS.
N.B. This code is “minified”. The full version (and any updates of this version) come from GitHub - davidbau/seedrandom: seeded random number generator for Javascript
If you seed using Math.seedrandom(“hello.”); the first two numbers generated by random() will be 0.9282578795792454 and then 0.3752569768646784.
seedString = Math.seedrandom(); will seed based on current time, dom state, and other accumulated local entropy. The seed generated is saved to seedString so you can restart the sequence using Math.seedrandom(seedString);
If you want to create random numbers with a custom seed without affecting Math.random, add var myrng = new Math.seedrandom(‘hello.’); to code_JS and then retrieve random numbers using myrng().
Python PsychoJS
!function(a,b,c,d,e,f,g,h,i){function j(a){var b,c=a.length,e=this,f=0,g=e.i=e.j=0,h=e.S=;for(c (a=[c++]);d>f;)h[f]=f++;for(f=0;d>f;f++)h[f]=h[g=s&g+a[f%c]+(b=h[f])],h[g]=b;(e.g=function(a){for(var b,c=0,f=e.i,g=e.j,h=e.S;a–;)b=h[f=s&f+1],c=cd+h[s&(h[f]=h[g=s&g+b])+(h[g]=b)];return e.i=f,e.j=g,c})(d)}function k(a,b){var c,d=[],e=typeof a;if(b&&“object”==e)for(c in a)try{d.push(k(a[c],b-1))}catch(f){}return d.length?d:“string”==e?a:a+"\0"}function l(a,b){for(var c,d=a+"",e=0;e<d.length;)b[s&e]=s&(c^=19b[s&e])+d.charCodeAt(e++);return n(b)}function m(c){try{return o?n(o.randomBytes(d)):(a.crypto.getRandomValues(c=new Uint8Array(d)),n(c))}catch(e){return[+new Date,a,(c=a.navigator)&&c.plugins,a.screen,n(b)]}}function n(a){return String.fromCharCode.apply(0,a)}var o,p=c.pow(d,e),q=c.pow(2,f),r=2*q,s=d-1,t=c[“seed”+i]=function(a,f,g){var h=;f=1==f?{entropy:!0}:f {};var o=l(k(f.entropy?[a,n(b)]:null==a?m():a,3),h),s=new j(h);return l(n(s.S),b),(f.pass g function(a,b,d){return d?(c[i]=a,b):a})(function(){for(var a=s.g(e),b=p,c=0;q>a;)a=(a+c)d,b=d,c=s.g(1);for(;a>=r;)a/=2,b/=2,c>>>=1;return(a+c)/b},o,"global"in f?f.global:this==c)};if(l(ci,b),g&&g.exports){g.exports=t;try{o=require(“crypto”)}catch(u){}}else h&&h.amd&&h(function(){return t})}(this,,Math,256,6,52,“object”==typeof module&&module,“function”==typeof define&&define,“random”);
seedString = Math.seedrandom();