this post was submitted on 29 May 2026
8 points (100.0% liked)
Godot
7645 readers
30 users here now
Welcome to the programming.dev Godot community!
This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.
Make sure to follow the Godot CoC while chatting
We have a matrix room that can be used for chatting with other members of the community here
Links
Other Communities
- !inat@programming.dev
- !play_my_game@programming.dev
- !destroy_my_game@programming.dev
- !voxel_dev@programming.dev
- !roguelikedev@programming.dev
- !game_design@programming.dev
- !gamedev@programming.dev
Rules
- Posts need to be in english
- Posts with explicit content must be tagged with nsfw
- We do not condone harassment inside the community as well as trolling or equivalent behaviour
- Do not post illegal materials or post things encouraging actions such as pirating games
We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent
Wormhole
Credits
- The icon is a modified version of the official godot engine logo (changing the colors to a gradient and black background)
- The banner is from Godot Design
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Hey, Shin!
You seem pretty excited about your weighted selection strategy for choosing enemy actions, and I thought I'd share with you some other cool tricks.
I'm going to hide them in a spoiler, though, in case you're like me and you really love figuring things out on your own.
Tap for spoiler
If you get your action weight from a function call, something like:
action_heal.get_weight(battle_context) => float;You can use the information in battle_context (remaining HP, for instance) to dynamically change how likely each action is to be chosen, which seemed to be something you wanted to look into.
You can even return a weight of 0 if the battle_context would suggest the action would be useless.
For something much more complicated, you might want to look into a concept called a Behavior Tree. Even if you don't use one, you might learn a lot from how they're constructed. Video game AI, robotics, and all kinds of other stuff use them pretty often.
If you want to see an example of a what a really simple behavior tree is capable of (so simple it might be more accurately called a Decision Tree), you should look into Final Fantasy 12's Gambit system. This game actually lets players program their own party member AI to do certain things when certain conditions are met, and it ends up being a really useful if barebones model that I've based a few AI systems on. If you wanted to combine that with the weighted random-choice trick to add a little more decision variety, I'm sure there's a cool way to do that.
I didn't hat the opportunity to write on this comment yesterday, so I'll do it today. Freaking awesome idea. Right now when I need to make some more "complex" logic for the AI, I'm using the singleton for the
CombatManagerto keep it with its data. But having a resource for thecombat_contextwould solve and make it able to have more isolated, and for sure create even a replicable combat (since each turn is "predictable")... Love it. Thanks for the comment.You're welcome, my friend. :)