• Add Review
  • Subscribe
  • Nominate
  • Submit Media
  • RSS

Which Beat Should I Choose? (Battle Plans)

  • kentona
  • 03/06/2015 10:14 PM
  • 2442 views
FULL DISCLOSURE
I haven't thought deeply on the subject of battle plans - that is, when it is his turn, how does a battler choose his action from his list of available actions?

I have (for the purpose of testing other system) implemented a rudimentary system that assigns a static priority to an action, and then using a random number, choose an action based on the relative proportions of the priorities of all of that battler's actions.

ie-
if a battler has 3 actions in his repitiore:
ATTACK := 40 priority points
DEPLOYATTACK := 60 priority points
DEFEND := 20 priority points

I will then choose a random number between 0 and 120, and then iteratively check
if rand < 40, do ATTACK
if rand < 100, do DEPLOYATTACK
if rand < 120, do DEFEND

That's it, and I am only telling you this just so you know where I currently stand. I need some brainstorming ideas because I am kind of drawing a blank on how to go about this, and in particular struggling with an effective way to change the prioritization of the moves based on the current state of the battle (like, if I already have a weapon deployed, I should lower my priority of DEPLOYATTACK, but if I don't, deploying a weapon should be a higher priority)

LockeZ already started pondering on this on my behalf
author=LockeZ
I was imagining the pre-planned strategies being done like setting your party's AI in Dragon Age: Origins or Final Fantasy 12. The player would create a set of conditions for different actions to be used, in order of preference, like:

1. If opponent's HP is below 20%, and beam cannon is not out of ammo, and energy is above 25%, attack with beam cannon.
2. If battle is long range, and own HP is above 90%, attempt to close to short range.
3. If energy is below 25%, attack with energy stealer.
4. If battle is long range, activate energy shield.
5. If minibots are present, attack with flamethrower.
6. If battle is long range, attempt to close to short range.
7. If shotgun is out of ammo, and minibots are not present, attack with martial arts.
8. If shotgun is not out of ammo, attack with shotgun.
9. Attack with martial arts.

This was just the first way my mind jumped to, and so I was suggesting the short and long range thinking that it would be easily possible in a system like this. Were you thinking of doing battle plans a different way? This way wouldn't really limit what kinds of actions you can add to the game; as long as the outcomes of those actions are also possible conditions, there's no limit to what the player can choose to do. After all, in FF12 the entire game was played this way.


I didn't consider letting the end user tweak their battleplan to such a great degree (I was toying with the idea of a more generalized instructions like "Fight Wisely", "Show No Mercy", "Play It Safe", "Be Erratic", and building out strategies automagically from there). But I do like LockeZ's idea. It's kind of like building out AI rule in RM2k3's monster database. It is a little more complex than I was anticipating, but maybe that's a good thing.

What are your thoughts on this?

Posts

Pages: 1
So what I have implemented today is a rudimentary battle plan system.

Components
Each battler will have a battleplan, which is a collection of battleplan items.
A battleplan item consists of:
-a list of conditions
-an action
-a priority
Each condition can be a single (currently hardcoded) condition type:

Always (no conditions)
If Opponent's HP is < XX or > XX
If My HP is < XX or > XX
If My master's HP is < XX or > XX (this is for drones referring to their Master)
If Opp's Energy is < YY or > YY
If my Energy is < YY or > YY
If my master's Energy is < YY or > YY
If battle is Long Range mode
if battle is Close Range mode
If enemy drones are present
If ally drones are present
If I Have Weapon Equipped
If I Do Not have weapon equipped
If I Have Weapons
At least X number of turns has passed
No more than X number of turns has passed

Each Action has an (optional) set of minimum requirements. That is, conditions that must exist for that action to be valid. Like, say, the Beam Cannon requiring at least 50 energy points to use.

The Logic
Now, like before I am still using the logic described above to choose a random action. The difference is now I am using the battleplan to determine which actions are valid!

So choosing an action has 2 stages:
-determine a list of valid or prescribed actions for that turn based on the battleplan
-choose a random action from that list proportional to priority

Pseudo-code
for each battleplanitem in BattlePlan
if the battleplanitem's conditions are met, add battleplanitem's action to the actions list

calculate the total priority of all of the actions
choose a random number between 0 and total
for each action in the actions list
runningprioritytotal += action.priority
if random <= runningprioritytotal
choose this action!

if somehow nothing is chosen or the actions list is empty
do the battler's default action


How does that all sound?

The way that I envision this working (once I have a way to customize your battler) is that given your list of available actions, and the fixed list of conditions, you could craft a battleplan consisting of actions, conditions and priority. When you select an action, it's requirements would automatically be added to this battleplanitem's conditions.

ie:
a) If <Does Not Have Weapon Equipped> AND <Have Weapons>: DEPLOYWEAPON, Priority=100
b) If <BattleMode is LongRange>: CLOSERANKS, PRIORITY=50
c) If <BattleMode is LongRange>: FIREBEAMCANNON, PRIORITY=50
d) If <My HP < 50%>: REPAIRNANOBOTS, PRIORITY=35
e) If <Enemy Drones Present>: SONICDETONATOR, PRIORITY=55
f) If <Always>, ATTACK, PRIORITY=40

etc...


Am I missing anything here with this implementation? Any other conditions you think might be worth having? Should I hardcode in a default action of ATTACK just in case someone forgets to setup a battleplan, or somehow the logic in their battleplan results in a situation where none of their set up actions are valid?
I'd add an option that if a move is found to always use it. For example using your example if a, b, and c conditions fail and it hits D then it'll always use REPAIRNANOBOTS without checking e and on. I imagine some players would want that and would abuse the priority system to minimize any RNG (like REPAIRNANOBOTS priority is 10000, SONICDETONATOR is 10).


Also if a robot hits the end of its AI without finding an action it should do a silly action, like shoot sparks, repeat ERROR ERROR, or start spinning. e: Read: Do nothing but spew flavor text, possibly mocking the robot's player.
author=GreatRedSpirit
I'd add an option that if a move is found to always use it. For example using your example if a, b, and c conditions fail and it hits D then it'll always use REPAIRNANOBOTS without checking e and on. I imagine some players would want that and would abuse the priority system to minimize any RNG (like REPAIRNANOBOTS priority is 10000, SONICDETONATOR is 10).


Also if a robot hits the end of its AI without finding an action it should do a silly action, like shoot sparks, repeat ERROR ERROR, or start spinning. e: Read: Do nothing but spew flavor text, possibly mocking the robot's player.


Well, to clarify, the battleplan is only there to determine which actions are available to be chosen, and not which action that will be taken.

Step 1: use battleplan to get a list of all of the actions that meet conditions
Step 2: choose an action randomly from the list of available actions

for step 2, you have a measure of control because you can ascribe a priority score to an action, and the higher the score, the more likely that action will be chosen.
The priority score is how players who want a move to be used if it's available to ensure that it does. Either you need to assign a tight range of priorities or REPAIRNANBOTS will get a priority of Int32.MaxValue or so so the odds of it not being used are 0.00001%.
Yes, I was going to restrict it to a value between 20 and 60 or something akin to that.
How will you aggregate a script that selects the same skill multiple times? If I duplicate the REPAIRNANOBOTS line three times with 20, 30, and 40 priority for example, will it add it giving it a priority of 90, capping at 60, or just pick the highest at 40?
If MMORPGs taught me anything you gotta think like somebody who's out to exploit the system to plan around it


(I also know that healing as my example skill is a poor choice since if you really wanted it you'd set up your other attack scripts to not execute if you're in your healing HP range)



(maybe I'm thinking too far down the road)
Pages: 1