-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial integration of behavior tree into monster AI.
- Loading branch information
1 parent
31dcaec
commit 10f474d
Showing
12 changed files
with
165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[ | ||
{ | ||
"type": "behavior", | ||
"id": "monster_goals", | ||
"strategy": "sequential_until_done", | ||
"children": [ "absorb_items", "monster_special" ] | ||
}, | ||
{ | ||
"type": "behavior", | ||
"id": "absorb_items", | ||
"strategy": "sequential", | ||
"predicate": "monster_not_hallucination", | ||
"children": [ "do_absorb" ] | ||
}, | ||
{ | ||
"type": "behavior", | ||
"id": "do_absorb", | ||
"predicate": "monster_items_available", | ||
"goal": "consume_items" | ||
}, | ||
{ | ||
"type": "behavior", | ||
"id": "monster_special", | ||
"predicate": "monster_has_special", | ||
"goal": "do_special" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <string> | ||
|
||
#include "behavior.h" | ||
#include "game.h" | ||
#include "map.h" | ||
#include "monster.h" | ||
#include "monster_oracle.h" | ||
|
||
namespace behavior | ||
{ | ||
|
||
status_t monster_oracle_t::has_special() const | ||
{ | ||
if( subject->shortest_special_cooldown() == 0 ) { | ||
return running; | ||
} | ||
return failure; | ||
} | ||
|
||
status_t monster_oracle_t::not_hallucination() const | ||
{ | ||
return subject->is_hallucination() ? failure : running; | ||
} | ||
|
||
status_t monster_oracle_t::items_available() const | ||
{ | ||
if( !g->m.has_flag( TFLAG_SEALED, subject->pos() ) && g->m.has_items( subject->pos() ) ) { | ||
return running; | ||
} | ||
return failure; | ||
} | ||
|
||
} // namespace behavior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#ifndef CATA_SRC_MONSTER_ORACLE_H | ||
#define CATA_SRC_MONSTER_ORACLE_H | ||
|
||
#include "behavior_oracle.h" | ||
|
||
class monster; | ||
|
||
namespace behavior | ||
{ | ||
|
||
class monster_oracle_t : public oracle_t | ||
{ | ||
public: | ||
monster_oracle_t( const monster *subject ) { | ||
this->subject = subject; | ||
} | ||
/** | ||
* Predicates used by AI to determine goals. | ||
*/ | ||
status_t has_special() const; | ||
status_t not_hallucination() const; | ||
status_t items_available() const; | ||
private: | ||
const monster *subject; | ||
}; | ||
|
||
} // namespace behavior | ||
#endif // CATA_SRC_MONSTER_ORACLE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters