Love the way the light shines through it like that
The General Prototype
const CAPACITY = 8; | |
class QuadTree { | |
constructor(x, y, w, h) { | |
// the rect (x,y,w,h) defines the product of two half-open intervals: [x, x+w) × [y, y+h) | |
this.x = x; this.xe = x + w; | |
this.y = y; this.ye = y + h; | |
this.w = w; | |
this.h = h; | |
this.pts = []; |
// RNG = Math.random | |
RNG = xorshift128 | |
function nonsense() { | |
// if all you need | |
// is a random seed | |
// of type string | |
// then this thing | |
// does the deed, hey | |
xorshift128_seed(Date.now() + ''); |
in stevige grote pan aanbakken/fruiten tot het bruin begint te worden. ondertusen oven voorverwarmen. daarna toevoegen:
If the docs don't specify the cycle length, IMHO better not use it in situations where it matters.
65**5 is about 30 bits. if the PRNG-state is 32 bits, and the PRNG algorithm doesn't cycle through the full state, that may already be too little.
In many languages the default PRNG is implemented as a LCG, which are just 2-3 lines of code, and just not very good on their own. Computational science has found much, much better algorithms that are (almost) just as tiny to implement. Maybe 4-5 lines, see PCG-random.org.
I recently used a Java port of CMWC4096 from StackOverflow, for a numerical simulation in Java (where the default Math.random() has a stupid-bad cycle length, and the Java crypto-PRNG might have been too slow). It worked great. Not quite as tiny as PCG-random, but still short and it was ready-to-use Java-code that fit my needs.
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
#define PROCESSING_TEXTURE_SHADER | |
uniform sampler2D texture; | |
uniform vec2 C; | |
uniform vec2 P; | |
uniform vec2 M; |
import java.lang.Math; // de functies in java.lang.Math zijn een stuk sneller | |
// dan die van Processing zelf. | |
class Blobs { | |
int N; | |
int[] rrr; | |
float[] cx, cy, cr; | |
private float time; | |
Blobs(int N) { |
import java.lang.Math; // de functies in java.lang.Math zijn een stuk sneller | |
// dan die van Processing zelf. | |
class Blobs { | |
int N; | |
int[] rrr; | |
float[] cx, cy, cr; | |
private float time; | |
Blobs(int N) { | |
this.N = N; |
lol, sam snapt mijn gameloop niet ofzo :P "die while loop is niet goed ofzo" stel je pc loopt vast dan zou ie oneindig veel updates kunnen krijgen
http://gameprogrammingpatterns.com/game-loop.html hmm ik zie toch echt dat ze t hier ook doen XD
Ah nice dus ik had het goed onthouden? :-) Volgens mij was dat ook precies het artikel waar ik dit uit geleerd heb.