cpowell / cppgoap Goto Github PK
View Code? Open in Web Editor NEWA simple GOAP (goal-oriented action planner) useful for game AI
License: Other
A simple GOAP (goal-oriented action planner) useful for game AI
License: Other
So, let's say that we have 3 actions:
chopLogs
4
true
true
getAxe
1
true
collectBranches
8
true
Our goal is to get wood, so:
And our world state is something like this:
false
false
And the planner will choose collectBranches
(cost: 8) over getAxe, chopLogs
(cost: 5)
If there's two actions with the same preconditions and effects but different costs, it doesn't choose the cheapest option. Instead it seems to choose the first option in the Actions vector.
From the war_game example (with typo fixed in scoutRunning):
Action scout("scoutStealthily", 999);
scout.setPrecondition(enemy_sighted, false);
scout.setPrecondition(weapon_in_hand, true);
scout.setEffect(enemy_sighted, true);
actions.push_back(scout);
Action run("scoutRunning", 15);
run.setPrecondition(enemy_sighted, false);
run.setPrecondition(weapon_in_hand, true);
run.setEffect(enemy_sighted, true);
actions.push_back(run);
As both actions do the same thing but scoutRunning costs less, I'd expect it to be selected - but instead scoutStealthily is always selected regardless of the costs! And if I put actions.push_back(scout)
after actions.push_back(run)
then scoutRunning is always selected regardless of the costs.
(I've spent the evening implementing multi-dimensional costs, so scoutStealthily can be slow and safe and scoutRunning can be fast but risky, and the agent can be configured to put more weight on the time cost vs the risk cost (vs the ammo cost vs the health cost... etc). But this error occurs with the code as provided.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.