@esengine/pathfinding 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/source.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.vscode/tasks.json +13 -0
- package/.wing/settings.json +3 -0
- package/README.md +245 -0
- package/bin/README.md +245 -0
- package/bin/modules/astar.js +559 -0
- package/bin/modules/astar.min.js +1 -0
- package/bin/modules/breadth-first.js +559 -0
- package/bin/modules/breadth-first.min.js +1 -0
- package/bin/package.json +54 -0
- package/bin/pathfinding.d.ts +167 -0
- package/bin/pathfinding.js +559 -0
- package/bin/pathfinding.min.js +1 -0
- package/gulpfile.js +137 -0
- package/lib/wxgame.d.ts +3945 -0
- package/package.json +52 -0
- package/src/AI/Pathfinding/AStar/AStarPathfinder.ts +244 -0
- package/src/AI/Pathfinding/AStar/AstarGridGraph.ts +183 -0
- package/src/AI/Pathfinding/AStar/IAstarGraph.ts +30 -0
- package/src/AI/Pathfinding/BreadthFirst/BreadthFirstPathfinder.ts +109 -0
- package/src/AI/Pathfinding/BreadthFirst/IUnweightedGraph.ts +14 -0
- package/src/AI/Pathfinding/BreadthFirst/UnweightedGraph.ts +29 -0
- package/src/AI/Pathfinding/BreadthFirst/UnweightedGridGraph.ts +81 -0
- package/src/Types/IVector2.ts +102 -0
- package/src/Utils/PriorityQueue.ts +121 -0
- package/src/index.ts +49 -0
- package/tsconfig.json +34 -0
package/gulpfile.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const gulp = require("gulp");
|
|
3
|
+
const terser = require('gulp-terser');
|
|
4
|
+
const inject = require("gulp-inject-string");
|
|
5
|
+
const ts = require('gulp-typescript');
|
|
6
|
+
const concat = require('gulp-concat');
|
|
7
|
+
const { deleteAsync } = require('del');
|
|
8
|
+
const tsProject = ts.createProject('tsconfig.json');
|
|
9
|
+
|
|
10
|
+
// 清理构建目录
|
|
11
|
+
function clean() {
|
|
12
|
+
return deleteAsync(['bin/**/*']);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 构建完整版本(包含所有算法)
|
|
16
|
+
function buildComplete() {
|
|
17
|
+
return tsProject.src()
|
|
18
|
+
.pipe(tsProject())
|
|
19
|
+
.js.pipe(concat('pathfinding.js'))
|
|
20
|
+
.pipe(inject.prepend('// 高性能寻路算法库 - 完整版 v1.0.1\n'))
|
|
21
|
+
.pipe(gulp.dest('./bin'))
|
|
22
|
+
.pipe(terser({
|
|
23
|
+
compress: {
|
|
24
|
+
drop_console: true,
|
|
25
|
+
drop_debugger: true
|
|
26
|
+
},
|
|
27
|
+
mangle: {
|
|
28
|
+
toplevel: true
|
|
29
|
+
}
|
|
30
|
+
}))
|
|
31
|
+
.pipe(concat('pathfinding.min.js'))
|
|
32
|
+
.pipe(gulp.dest('./bin'));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 构建A*算法模块
|
|
36
|
+
function buildAStar() {
|
|
37
|
+
const astarProject = ts.createProject('tsconfig.json', {
|
|
38
|
+
include: [
|
|
39
|
+
"src/Types/**/*",
|
|
40
|
+
"src/Utils/**/*",
|
|
41
|
+
"src/AI/Pathfinding/AStar/**/*"
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return astarProject.src()
|
|
46
|
+
.pipe(astarProject())
|
|
47
|
+
.js.pipe(concat('astar.js'))
|
|
48
|
+
.pipe(inject.prepend('// A*寻路算法模块 v1.0.1\n'))
|
|
49
|
+
.pipe(gulp.dest('./bin/modules'))
|
|
50
|
+
.pipe(terser({
|
|
51
|
+
compress: {
|
|
52
|
+
drop_console: true,
|
|
53
|
+
drop_debugger: true
|
|
54
|
+
},
|
|
55
|
+
mangle: {
|
|
56
|
+
toplevel: true
|
|
57
|
+
}
|
|
58
|
+
}))
|
|
59
|
+
.pipe(concat('astar.min.js'))
|
|
60
|
+
.pipe(gulp.dest('./bin/modules'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 构建广度优先算法模块
|
|
64
|
+
function buildBFS() {
|
|
65
|
+
const bfsProject = ts.createProject('tsconfig.json', {
|
|
66
|
+
include: [
|
|
67
|
+
"src/Types/**/*",
|
|
68
|
+
"src/Utils/**/*",
|
|
69
|
+
"src/AI/Pathfinding/BreadthFirst/**/*"
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return bfsProject.src()
|
|
74
|
+
.pipe(bfsProject())
|
|
75
|
+
.js.pipe(concat('breadth-first.js'))
|
|
76
|
+
.pipe(inject.prepend('// 广度优先搜索算法模块 v1.0.1\n'))
|
|
77
|
+
.pipe(gulp.dest('./bin/modules'))
|
|
78
|
+
.pipe(terser({
|
|
79
|
+
compress: {
|
|
80
|
+
drop_console: true,
|
|
81
|
+
drop_debugger: true
|
|
82
|
+
},
|
|
83
|
+
mangle: {
|
|
84
|
+
toplevel: true
|
|
85
|
+
}
|
|
86
|
+
}))
|
|
87
|
+
.pipe(concat('breadth-first.min.js'))
|
|
88
|
+
.pipe(gulp.dest('./bin/modules'));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 构建类型定义文件
|
|
92
|
+
function buildDts() {
|
|
93
|
+
return tsProject.src()
|
|
94
|
+
.pipe(tsProject())
|
|
95
|
+
.dts.pipe(concat('pathfinding.d.ts'))
|
|
96
|
+
.pipe(gulp.dest('./bin'));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 复制包文件
|
|
100
|
+
function copyPackageFiles() {
|
|
101
|
+
return gulp.src(['package.json', 'README.md'])
|
|
102
|
+
.pipe(gulp.dest('./bin'));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 创建模块目录
|
|
106
|
+
function createModuleDir() {
|
|
107
|
+
return gulp.src('*.*', {read: false})
|
|
108
|
+
.pipe(gulp.dest('./bin/modules'));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function build() {
|
|
112
|
+
return gulp.src('bin/**/*');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 导出任务
|
|
116
|
+
exports.clean = clean;
|
|
117
|
+
exports.buildComplete = buildComplete;
|
|
118
|
+
exports.buildAStar = buildAStar;
|
|
119
|
+
exports.buildBFS = buildBFS;
|
|
120
|
+
exports.buildDts = buildDts;
|
|
121
|
+
exports.copyPackageFiles = copyPackageFiles;
|
|
122
|
+
exports.createModuleDir = createModuleDir;
|
|
123
|
+
|
|
124
|
+
// 构建所有模块
|
|
125
|
+
exports.buildModules = gulp.series(createModuleDir, gulp.parallel(buildAStar, buildBFS));
|
|
126
|
+
|
|
127
|
+
// 完整构建
|
|
128
|
+
exports.build = gulp.series(
|
|
129
|
+
clean,
|
|
130
|
+
buildComplete,
|
|
131
|
+
buildDts,
|
|
132
|
+
copyPackageFiles,
|
|
133
|
+
exports.buildModules,
|
|
134
|
+
build
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
exports.default = exports.build;
|