@rbxts/htn-shop 1.0.2 → 1.0.3
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/README.md +4 -4
- package/out/init.luau +5 -15
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
a simple HTN, SHOP-like planner written in js, based on [Pyhop](https://bitbucket.org/dananau/pyhop)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
jshop was easy to implement (less than 50 lines of code), and if you understand the basic ideas of HTN planning ([this presentation](http://www.cs.umd.edu/~nau/papers/nau2013game.pdf) contains a quick summary), jshop should be easy to understand.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
jshop's planning algorithm is like the one in SHOP, but with several differences that should make it easier to integrate it with ordinary computer programs:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
jshop represents states of the world using ordinary variable bindings, not logical propositions. A state is just a js object. For example, you might write s.loc['v'] = 'd' to say that vehicle v is at location d in state s.
|
|
10
10
|
|
|
11
|
-
To write HTN operators and methods
|
|
11
|
+
To write HTN operators and methods for jshop, you don't need to learn a specialized planning language. Instead, you write them as ordinary js functions. The current state (e.g., s in the above example) is passed to them as an argument.
|
|
12
12
|
|
|
13
13
|
## Module Usage
|
|
14
14
|
|
package/out/init.luau
CHANGED
|
@@ -4,32 +4,22 @@ local _util = TS.import(script, script, "util")
|
|
|
4
4
|
local extend = _util.extend
|
|
5
5
|
local deepClone = _util.deepClone
|
|
6
6
|
local tail = _util.tail
|
|
7
|
-
local
|
|
7
|
+
local seekPlan
|
|
8
8
|
local function create()
|
|
9
9
|
local operators = {}
|
|
10
10
|
local taskMethods = {}
|
|
11
11
|
return {
|
|
12
12
|
operators = function(toAdd)
|
|
13
|
-
return
|
|
13
|
+
return extend(operators, toAdd)
|
|
14
14
|
end,
|
|
15
|
-
setMethods = function(taskName,
|
|
16
|
-
|
|
15
|
+
setMethods = function(taskName, toAdd)
|
|
16
|
+
taskMethods[taskName] = toAdd
|
|
17
17
|
end,
|
|
18
18
|
solve = function(state, tasks)
|
|
19
|
-
return
|
|
19
|
+
return seekPlan(operators, taskMethods, state, tasks, {}, 0)
|
|
20
20
|
end,
|
|
21
21
|
}
|
|
22
22
|
end
|
|
23
|
-
function addOperators(currentOperators, toAdd)
|
|
24
|
-
extend(currentOperators, toAdd)
|
|
25
|
-
end
|
|
26
|
-
function setMethods(currentTaskMethods, taskName, toAdd)
|
|
27
|
-
currentTaskMethods[taskName] = toAdd
|
|
28
|
-
end
|
|
29
|
-
local seekPlan
|
|
30
|
-
function solve(operators, taskMethods, state, tasks)
|
|
31
|
-
return seekPlan(operators, taskMethods, state, tasks, {}, 0)
|
|
32
|
-
end
|
|
33
23
|
function seekPlan(operators, taskMethods, state, tasks, plan, depth)
|
|
34
24
|
if #tasks == 0 then
|
|
35
25
|
return plan
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/htn-shop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "a simple HTN SHOP-like planner",
|
|
5
5
|
"author": "shrjrd",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,10 +35,11 @@
|
|
|
35
35
|
"typescript": "^5.9.3"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
|
+
"prepack": "npm run build",
|
|
38
39
|
"build": "rbxtsc",
|
|
39
|
-
"
|
|
40
|
+
"compile:rbxl": "rbxtsc --type game --rojo default.project.json",
|
|
40
41
|
"build:rbxl": "rojo sourcemap -o sourcemap.json && rojo build -o place.rbxl",
|
|
41
|
-
"watch": "npm run
|
|
42
|
+
"watch:rbxl": "npm run compile:rbxl && npx concurrently \"npm run compile:rbxl -- -w\" \"rojo serve\""
|
|
42
43
|
},
|
|
43
44
|
"repository": {
|
|
44
45
|
"type": "git",
|