Simple question, but I'm interested in the nuances here.
I'm generating random booleans using the following method I came up with myself:
const rand = Boolean(Math.round(Math.random()));
Whenever random()
shows up, it seems there's always a pitfall - it's not truly random, it's compromised by something or other, etc. So, I'd like to know:
a) Is the above the best-practice way to do it?
b) Am I overthinking things?
c) Am I underthinking things?
d) Is there a better/faster/elegant-er way I don't know of?
(Also somewhat interested if B and C are mutually exclusive.)
Update
If it makes a difference, I'm using this for movement of an AI character.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…