|
1208 | 1208 | /* initialisation */ |
1209 | 1209 | function reset() { |
1210 | 1210 | acc = brs = cnt = 0; |
1211 | | - for(var i = 0; i < 256; ++i) |
| 1211 | + for (var i = 0; i < 256; ++i) |
1212 | 1212 | m[i] = r[i] = 0; |
1213 | 1213 | gnt = 0; |
1214 | 1214 | } |
|
1225 | 1225 |
|
1226 | 1226 | if (s instanceof Array) { |
1227 | 1227 | reset(); |
1228 | | - for(i = 0; i < s.length; ++i) |
| 1228 | + for (i = 0; i < s.length; ++i) |
1229 | 1229 | r[i & 0xff] += typeof(s[i]) === 'number' ? s[i] : 0; |
1230 | 1230 | } |
1231 | 1231 |
|
|
1241 | 1241 | h ^= a >>> 9; c = add(c, h); a = add(a, b); |
1242 | 1242 | } |
1243 | 1243 |
|
1244 | | - for(i = 0; i < 4; i++) /* scramble it */ |
| 1244 | + for (i = 0; i < 4; i++) /* scramble it */ |
1245 | 1245 | seed_mix(); |
1246 | 1246 |
|
1247 | | - for(i = 0; i < 256; i += 8) { |
| 1247 | + for (i = 0; i < 256; i += 8) { |
1248 | 1248 | if (s) /* use all the information in the seed */ |
1249 | 1249 | a = add(a, r[i + 0]), b = add(b, r[i + 1]), |
1250 | 1250 | c = add(c, r[i + 2]), d = add(d, r[i + 3]), |
|
1255 | 1255 | m[i + 0] = a; m[i + 1] = b; m[i + 2] = c; m[i + 3] = d; |
1256 | 1256 | m[i + 4] = e; m[i + 5] = f; m[i + 6] = g; m[i + 7] = h; |
1257 | 1257 | } |
1258 | | - if(s) |
| 1258 | + if (s) |
1259 | 1259 | /* do a second pass to make all of the seed affect all of m[] */ |
1260 | | - for(i = 0; i < 256; i += 8) |
| 1260 | + for (i = 0; i < 256; i += 8) |
1261 | 1261 | a = add(a, m[i + 0]), b = add(b, m[i + 1]), |
1262 | 1262 | c = add(c, m[i + 2]), d = add(d, m[i + 3]), |
1263 | 1263 | e = add(e, m[i + 4]), f = add(f, m[i + 5]), |
|
1271 | 1271 | } |
1272 | 1272 |
|
1273 | 1273 | /* isaac generator, n = number of run */ |
1274 | | - function prng(n){ |
| 1274 | + function prng(n) { |
1275 | 1275 | var i, x, y; |
1276 | 1276 | n = n && typeof(n) === 'number' ? Math.abs(Math.floor(n)) : 1; |
1277 | | - while(n--) { |
| 1277 | + while (n--) { |
1278 | 1278 | cnt = add(cnt, 1); |
1279 | 1279 | brs = add(brs, cnt); |
1280 | 1280 | for(i = 0; i < 256; i++) { |
|
1293 | 1293 |
|
1294 | 1294 | /* return a random number between */ |
1295 | 1295 | return function() { |
1296 | | - if(!gnt--) |
| 1296 | + if (!gnt--) |
1297 | 1297 | prng(), gnt = 255; |
1298 | 1298 | return r[gnt]; |
1299 | 1299 | }; |
|
0 commit comments