Release v0.2.0: Enemy AI Improvement
Previously, the enemy character was controlled by a model that selected a random command from a list of possible commands. While this proved that the command system was working, the model was not fun and did not convey any sort of intelligent behavior in the characters actions.
The new update uses Behavior Trees (see the corresponding section in Game AIPro), albeit for now a simple one, to model a more intelligent and hopefully engaging behavior. The new model reasons about the state of the world and according to the rules of the behavior tree, takes an appropriate action.
The implementation for the behavior tree I used can be found in my Playdate Lua Libraries repository.
Following is a simplified example for the behaviour tree used in this update. Here, the enemy takes a sophisticated guess on the incoming attack state, based on previous observations, and aggressively follows and attacks the player. Note, that the stance is not changed for attacking actions, yet.
local behaviorTree = bh.BehaviorTree(
-- A sequence executes the child behaviours
-- until all are executed or one fails (AND)
bh.Sequence({
bhCollectBlackboard,
bhGuessNextEnemyStance,
-- A select executes the child behaviours
-- until one succeeds or all fail (OR)
bh.Selector({
-- A Filter only execute second child
-- if first child succeeds
bh.Filter(bhShouldBlock,
bh.Sequence({
-- A Do block always returns success
bh.Do(bh.Filter(bhShouldChangeStance,
bhTakeNextGuessedEnemyStanceType
)),
bhDoHoldBlock
})
),
bhDoReleaseBlock
}),
-- Execute one of the childs at random
bh.Random({ -- Random movement
bhMoveIntoAttackRange,
bhMoveOutOfAttackRange,
bhDoMoveStop
}),
bh.Filter(bhCheckWantAttack,
bhDoAttack
)
})
)
The current uploaded enemy behavior is a first, simple approach and more improvements to the enemy AI will be coming in future releases.
Files
Get Eclipse: Samurai Showdown
Eclipse: Samurai Showdown
Single-hit fighting game for the Playdate
More posts
- Release v0.3.1: Major UpdateAug 13, 2024
- Update on project statusMar 19, 2024
- Publishing the source codeFeb 15, 2024
- Update v0.2.1: Notes from AI HellFeb 13, 2024
- Project Launch - PrototypeJan 31, 2024
Leave a comment
Log in with itch.io to leave a comment.