goap sample
This commit is contained in:
@@ -1289,6 +1289,36 @@ var es;
|
||||
es.ActionPlanner = ActionPlanner;
|
||||
})(es || (es = {}));
|
||||
var es;
|
||||
(function (es) {
|
||||
var Agent = (function () {
|
||||
function Agent() {
|
||||
this._planner = new es.ActionPlanner();
|
||||
}
|
||||
Agent.prototype.plan = function (debugPlan) {
|
||||
if (debugPlan === void 0) { debugPlan = false; }
|
||||
var nodes = null;
|
||||
if (debugPlan)
|
||||
nodes = [];
|
||||
this.actions = this._planner.plan(this.getWorldState(), this.getGoalState(), nodes);
|
||||
if (nodes != null && nodes.length > 0) {
|
||||
console.log("---- ActionPlanner plan ----");
|
||||
console.log("plan cost = " + nodes[nodes.length - 1].costSoFar);
|
||||
console.log(" start" + "\t" + this.getWorldState().describe(this._planner));
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
console.log(i + ": " + nodes[i].action.name + "\t" + nodes[i].worldState.describe(this._planner));
|
||||
es.Pool.free(nodes[i]);
|
||||
}
|
||||
}
|
||||
return this.hasActionPlan();
|
||||
};
|
||||
Agent.prototype.hasActionPlan = function () {
|
||||
return this.actions != null && this.actions.length > 0;
|
||||
};
|
||||
return Agent;
|
||||
}());
|
||||
es.Agent = Agent;
|
||||
})(es || (es = {}));
|
||||
var es;
|
||||
(function (es) {
|
||||
var WorldState = (function () {
|
||||
function WorldState(planner, values, dontcare) {
|
||||
|
||||
Reference in New Issue
Block a user