@akashic/akashic-engine
Advanced tools
Comparing version 3.9.3 to 3.10.0
@@ -141,2 +141,6 @@ import type { AssetConfigurationMap, AudioSystemConfigurationMap, ModuleMainScriptsMap, AssetConfigurationCommonBase, ImageAssetConfigurationBase, ScriptAssetConfigurationBase, TextAssetConfigurationBase, AudioAssetConfigurationBase, VideoAssetConfigurationBase, VectorImageAssetConfigurationBase } from "@akashic/game-configuration"; | ||
/** | ||
* プリロードすべきスクリプトアセットのIDを全て返す。 | ||
*/ | ||
preloadScriptAssetIds(): string[]; | ||
/** | ||
* パターンまたはフィルタに合致するパスを持つアセットIDを全て返す。 | ||
@@ -143,0 +147,0 @@ * |
@@ -176,2 +176,16 @@ "use strict"; | ||
/** | ||
* プリロードすべきスクリプトアセットのIDを全て返す。 | ||
*/ | ||
AssetManager.prototype.preloadScriptAssetIds = function () { | ||
return Object.entries(this.configuration) | ||
.filter(function (_a) { | ||
var conf = _a[1]; | ||
return conf.type === "script" && conf.global && conf.preload; | ||
}) | ||
.map(function (_a) { | ||
var assetId = _a[0]; | ||
return assetId; | ||
}); | ||
}; | ||
/** | ||
* パターンまたはフィルタに合致するパスを持つアセットIDを全て返す。 | ||
@@ -178,0 +192,0 @@ * |
@@ -1080,2 +1080,10 @@ "use strict"; | ||
this.operationPlugins = this.operationPluginManager.plugins; | ||
var preloadAssetIds = this._assetManager.preloadScriptAssetIds(); | ||
for (var _a = 0, preloadAssetIds_1 = preloadAssetIds; _a < preloadAssetIds_1.length; _a++) { | ||
var preloadAssetId = preloadAssetIds_1[_a]; | ||
var fun = this._moduleManager._require(preloadAssetId); | ||
if (!fun || typeof fun !== "function") | ||
throw ExceptionFactory_1.ExceptionFactory.createAssertionError("Game#_handleLoad: ".concat(preloadAssetId, " has no-exported function.")); | ||
fun(); | ||
} | ||
if (this._mainFunc) { | ||
@@ -1082,0 +1090,0 @@ this._mainFunc(this._runtimeValueBase, this._mainParameter || {}); |
@@ -7,8 +7,9 @@ export declare class Xorshift { | ||
static deserialize(ser: XorshiftSerialization): Xorshift; | ||
constructor(seed: number); | ||
constructor(seed: number | [number, number, number, number]); | ||
initState(seed: number): void; | ||
randomInt(): number[]; | ||
randomInt(): [number, number]; | ||
random(): number; | ||
nextInt(min: number, sup: number): number; | ||
serialize(): XorshiftSerialization; | ||
private generateSeeds; | ||
} | ||
@@ -15,0 +16,0 @@ /** |
@@ -10,28 +10,18 @@ "use strict"; | ||
function Xorshift(seed) { | ||
this.initState(seed); | ||
var seeds = Array.isArray(seed) ? seed : this.generateSeeds(seed); | ||
this._state0U = seeds[0] | 0; | ||
this._state0L = seeds[1] | 0; | ||
this._state1U = seeds[2] | 0; | ||
this._state1L = seeds[3] | 0; | ||
} | ||
Xorshift.deserialize = function (ser) { | ||
var ret = new Xorshift(0); | ||
ret._state0U = ser._state0U; | ||
ret._state0L = ser._state0L; | ||
ret._state1U = ser._state1U; | ||
ret._state1L = ser._state1L; | ||
var ret = new Xorshift([ser._state0U, ser._state0L, ser._state1U, ser._state1L]); | ||
return ret; | ||
}; | ||
// シード値が1つの場合にどのようにして初期状態を定義するかは特に定まっていない | ||
// このコードはロジック的な裏付けは無いが採用例が多いために採用した | ||
// 以下採用例 | ||
// http://meme.biology.tohoku.ac.jp/klabo-wiki/index.php?cmd=read&page=%B7%D7%BB%BB%B5%A1%2FC%2B%2B#y919a7e1 | ||
// http://hexadrive.sblo.jp/article/63660775.html | ||
// http://meme.biology.tohoku.ac.jp/students/iwasaki/cxx/random.html#xorshift | ||
Xorshift.prototype.initState = function (seed) { | ||
var factor = 1812433253; | ||
seed = factor * (seed ^ (seed >> 30)) + 1; | ||
this._state0U = seed; | ||
seed = factor * (seed ^ (seed >> 30)) + 2; | ||
this._state0L = seed; | ||
seed = factor * (seed ^ (seed >> 30)) + 3; | ||
this._state1U = seed; | ||
seed = factor * (seed ^ (seed >> 30)) + 4; | ||
this._state1L = seed; | ||
var seeds = this.generateSeeds(seed); | ||
this._state0L = seeds[0] | 0; | ||
this._state0U = seeds[1] | 0; | ||
this._state1L = seeds[2] | 0; | ||
this._state1U = seeds[3] | 0; | ||
}; | ||
@@ -43,2 +33,5 @@ Xorshift.prototype.randomInt = function () { | ||
var s0L = this._state1L; | ||
var sumL = (s0L >>> 0) + (s1L >>> 0); | ||
var resU = (s0U + s1U + ((sumL / 2) >>> 31)) >>> 0; | ||
var resL = sumL >>> 0; | ||
this._state0U = s0U; | ||
@@ -58,3 +51,3 @@ this._state0L = s0L; | ||
t1L = s1L ^ s0L; | ||
var a2 = 17; | ||
var a2 = 18; | ||
var m2 = 0xffffffff >>> (32 - a2); | ||
@@ -65,3 +58,3 @@ t2U = s1U >>> a2; | ||
t1L = t1L ^ t2L; | ||
var a3 = 26; | ||
var a3 = 5; | ||
var m3 = 0xffffffff >>> (32 - a3); | ||
@@ -74,10 +67,9 @@ t2U = s0U >>> a3; | ||
this._state1L = t1L; | ||
var sumL = (t1L >>> 0) + (s0L >>> 0); | ||
t2U = (t1U + s0U + ((sumL / 2) >>> 31)) >>> 0; | ||
t2L = sumL >>> 0; | ||
return [t2U, t2L]; | ||
return [resU, resL]; | ||
}; | ||
Xorshift.prototype.random = function () { | ||
var t2 = this.randomInt(); | ||
return (t2[0] * 4294967296 + t2[1]) / 18446744073709551616; | ||
// Math.pow(2, -32) = 2.3283064365386963e-10 | ||
// Math.pow(2, -52) = 2.220446049250313e-16 | ||
return t2[0] * 2.3283064365386963e-10 + (t2[1] >>> 12) * 2.220446049250313e-16; | ||
}; | ||
@@ -95,2 +87,20 @@ Xorshift.prototype.nextInt = function (min, sup) { | ||
}; | ||
// シード値が1つの場合にどのようにして初期状態を定義するかは特に定まっていない | ||
// このコードはロジック的な裏付けは無いが採用例が多いために採用した | ||
// 以下採用例 | ||
// http://meme.biology.tohoku.ac.jp/klabo-wiki/index.php?cmd=read&page=%B7%D7%BB%BB%B5%A1%2FC%2B%2B#y919a7e1 | ||
// http://hexadrive.sblo.jp/article/63660775.html | ||
// http://meme.biology.tohoku.ac.jp/students/iwasaki/cxx/random.html#xorshift | ||
Xorshift.prototype.generateSeeds = function (seed) { | ||
var factor = 1812433253; | ||
seed = factor * (seed ^ (seed >> 30)) + 1; | ||
var seed1 = seed; | ||
seed = factor * (seed ^ (seed >> 30)) + 2; | ||
var seed2 = seed; | ||
seed = factor * (seed ^ (seed >> 30)) + 3; | ||
var seed3 = seed; | ||
seed = factor * (seed ^ (seed >> 30)) + 4; | ||
var seed4 = seed; | ||
return [seed1, seed2, seed3, seed4]; | ||
}; | ||
return Xorshift; | ||
@@ -97,0 +107,0 @@ }()); |
{ | ||
"name": "@akashic/akashic-engine", | ||
"version": "3.9.3", | ||
"version": "3.10.0", | ||
"description": "The core library of Akashic Engine", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@akashic/game-configuration": "~1.8.0", | ||
"@akashic/game-configuration": "~1.9.0", | ||
"@akashic/pdi-types": "~1.6.0", | ||
@@ -36,3 +36,3 @@ "@akashic/playlog": "~3.1.0", | ||
"typescript": "^4.7.4", | ||
"xorshift": "0.2.0" | ||
"xorshift": "1.2.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1588792
27622
+ Added@akashic/game-configuration@1.9.0(transitive)
- Removed@akashic/game-configuration@1.8.0(transitive)