on master help sign in
Annotate random child logic
commit8aed2cb562fde09a0ad5c20d1577b1b974d0bb36 authorFang <git@fang.io> dateWed 24 Jul 2019, 18:59 (7 years ago) parentae42df5
1 file changed+3−1
src/lib/child.js+3−1
src/lib/child.js+3−1
@@ -5,10 +5,12 @@ const MAX_GALAXY = MIN_STAR - 1;
55const MAX_STAR = MIN_PLANET - 1;
66
77const randomStarName = galaxy =>
8+ // ( random in range 0x1 .. 0xff ) * 0x100 + 0x??
89 (Math.floor(Math.random() * MAX_GALAXY) + 1) * MIN_STAR + galaxy;
910
1011const randomPlanetName = star =>
11− (Math.floor(Math.random() * MAX_STAR) + 1) * (MAX_STAR + 1) + star;
12+ // ( random in range 0x1 .. 0xffff ) * 0x10000 + 0x????
13+ (Math.floor(Math.random() * MAX_STAR) + 1) * MIN_PLANET + star;
1214
1315const getSpawnCandidate = point =>
1416 point >= MIN_GALAXY && point < MIN_STAR