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

Rules

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

!roguelikedev@programming.dev

Credits

founded 3 years ago
MODERATORS
 

This may be interesting for people to read. Just a warning, all AGPL, so using this code snippets will make your source open. Hope you like the reading.

you are viewing a single comment's thread
view the rest of the comments
[–] petrol_sniff_king@lemmy.blahaj.zone 2 points 4 days ago (1 children)

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.

[–] Shin@piefed.social 0 points 3 days ago (1 children)

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 CombatManager to keep it with its data. But having a resource for the combat_context would 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. :)