Autowalker is working way better and now I have a plan for using the AI in the System.
This commit is contained in:
parent
0623170dbc
commit
ee804581a8
11 changed files with 197 additions and 127 deletions
29
ai_debug.cpp
29
ai_debug.cpp
|
@ -1,3 +1,4 @@
|
|||
#include "ai.hpp"
|
||||
#include "ai_debug.hpp"
|
||||
|
||||
namespace ai {
|
||||
|
@ -6,37 +7,39 @@ namespace ai {
|
|||
* Yeah this is weird but it's only to debug things like
|
||||
* the preconditions which are weirdly done.
|
||||
*/
|
||||
void dump_only(AIProfile& profile, State state, bool matching, bool show_as) {
|
||||
for(auto& [name, name_id] : profile) {
|
||||
void dump_only(State state, bool matching, bool show_as) {
|
||||
AIProfile* profile = ai::profile();
|
||||
for(auto& [name, name_id] : *profile) {
|
||||
if(state.test(name_id) == matching) {
|
||||
fmt::println("\t{}={}", name, show_as);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dump_state(AIProfile& profile, State state) {
|
||||
for(auto& [name, name_id] : profile) {
|
||||
void dump_state(State state) {
|
||||
AIProfile* profile = ai::profile();
|
||||
for(auto& [name, name_id] : *profile) {
|
||||
fmt::println("\t{}={}", name,
|
||||
state.test(name_id));
|
||||
}
|
||||
}
|
||||
|
||||
void dump_action(AIProfile& profile, Action& action) {
|
||||
void dump_action(Action& action) {
|
||||
fmt::println(" --ACTION: {}, cost={}", action.name, action.cost);
|
||||
|
||||
fmt::println(" PRECONDS:");
|
||||
dump_only(profile, action.$positive_preconds, true, true);
|
||||
dump_only(profile, action.$negative_preconds, true, false);
|
||||
dump_only(action.$positive_preconds, true, true);
|
||||
dump_only(action.$negative_preconds, true, false);
|
||||
|
||||
fmt::println(" EFFECTS:");
|
||||
dump_only(profile, action.$positive_effects, true, true);
|
||||
dump_only(profile, action.$negative_effects, true, false);
|
||||
dump_only(action.$positive_effects, true, true);
|
||||
dump_only(action.$negative_effects, true, false);
|
||||
}
|
||||
|
||||
State dump_script(AIProfile& profile, std::string msg, State start, Script& script) {
|
||||
State dump_script(std::string msg, State start, Script& script) {
|
||||
fmt::println("--SCRIPT DUMP: {}", msg);
|
||||
fmt::println("# STATE BEFORE:");
|
||||
dump_state(profile, start);
|
||||
dump_state(start);
|
||||
fmt::print("% ACTIONS PLANNED:");
|
||||
for(auto& action : script) {
|
||||
fmt::print("{} ", action.name);
|
||||
|
@ -44,11 +47,11 @@ namespace ai {
|
|||
fmt::print("\n");
|
||||
|
||||
for(auto& action : script) {
|
||||
dump_action(profile, action);
|
||||
dump_action(action);
|
||||
|
||||
start = action.apply_effect(start);
|
||||
fmt::println(" ## STATE AFTER:");
|
||||
dump_state(profile, start);
|
||||
dump_state(start);
|
||||
}
|
||||
|
||||
return start;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue