News:

The forum has been updated to SMF (2.1.3)!
Please be patient as we work to polish up the place and update features as we can.

Main Menu

Enemy AI Research (answering questions plus abuse tips)

Started by Salanewt, 02, April, 2017, 03:21:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Salanewt

So I've been doing some AI research over the past couple days and found some things.

General: An ability is selected first, then a target. At least from what I can tell. I'm not sure how to summarize the relationship between formulas and effects but I think the formula is prioritized if an ability can cause damage; I'll look into this one more later.

Defend: If an enemy has no valid or useful moves, then it will always defend. Even when it doesn't have it in its movepool.

Items: Caledor found a while ago that the checkboxes beside abilities are an item priority thing, meaning that if one of those is checked and an enemy has an item, then it will swap that ability out for an item. Item quantities in the editor decide how many inventory slots to fill with a particular item. Enemies use items in a sequential order, meaning that they will only ever use the first item in their inventory. This means that if an enemy has 10 smoke bombs in its inventory that are listed before a single potion, it will not use that potion to heal itself or its allies until all of those bombs have been used. Also, only single-use/consumable items can be used by enemies.

Also Items: Enemies can use stacked items (meaning a stack of 30, with the potential for multiple stacks of 30); the editor does not actually let you input the number of items in a stack, only number of stacks. This is not new knowledge. However, it also looks like their AI is incapable of using items that are broken. A shame there are no effects that let you break items or else this would be a pretty easy way to abuse certain bosses. This does mean that enemies are capable of using breakable items like unicorn rings, or at least they would be if not for an arbitrary restriction set for them in the code.

IQ: The unknown value in the enemy editor works almost like a general intelligence scale, so I'm calling it IQ. It ranges from 0-2 and affects a monster's behaviour depending on how high it is. So far all we know is that it affects item priority behaviour and spell casting.

IQ 0: The dumbest.
- An item priority slot is always treated as an item, meaning that the ability in that slot will never be used; if you have 7 item priority slots and one normal one, and are out of items, then only that last ability will be used.
- If it can cast spells and selects one to use, then it will try to use it regardless of whether it has enough PP or is sealed.

IQ 1: Average intelligence.
- An item priority slot is treated as an item until there are no items left, then it gets used as an ability.
- If it can cast spells and selects one to use, then it will still try to execute it if sealed but not if its PP is too low.

IQ 2: The smartest.
- Item priority slots work the same as IQ 1.
- If it can cast spells and selects one to use while it has insufficient PP or is sealed, then it will try to pick a different ability that it can use.

Healing: An enemy will not use a healing effect (the percentage ones) or formula unless the target's current HP is less than their maximum by any amount. The PP healing formula works like this too, but not the percentage effects since they don't seem to be listed.

Status Restore: Any ability that has effects #4 or #64 (restore ailments and cure all), the AI will not check to see if it or any of its allies are affected by stun. This means that any attempt to use something like Restore or an elixir will fail unless the enemy or its allies are affected by a different ailment. It does cure stun if the ability effect is used (i.e. if a target has both stun and another compatible ailment like sleep, then both will be cured). Charm and confuse are actually checked for, so inflicting an enemy with either of those two means that it will be targeted by Restore if that or a similar ability is selected.

Ailments: Some ailments, like Poison and Venom, will check to see if their target is already afflicted with it. Charm, confuse, delusion, and seal don't seem to be among them. Venom is prioritized over poison, meaning that an enemy will not try to use a status-only poison ability if their target is already afflicted with poison or venom, but it will use venom if they are afflicted with poison.

Effect Only(+ priority)/Utility Formulas: Abilities with these formulas behave a little weird if their base power is greater than 0, are set to friendly fire, and have certain ability effects like #4 (Restore). Just a heads up.

Increased priority: It's pretty well known that combining the Effect Only (priority/always first) formula only works with two effects; it adds 10,000 agility to a character's turn data when this move is selected. However, it has some strange behaviour due to the way the game calculates turn data. An enemy's turn order will thus be arranged based on the agility calculated for it at the beginning of the round while the particular ability or action will be dependent on what it decides on its turn, meaning that you can have normal priority Counter-Rush and heightened priority Restore if an enemy has both in its arsenal. What is even stranger is that the heightened-priority ability can be locked behind an item (using the checkboxes in the editor) and still influence turn order.

Mystic Call: Every enemy will summon Sea Fighter (#73) except for Star Magician, which has an exception set out for it. We have already known about this for a while and I have even toyed with it in the past but I figured I would restate it here.

Multiple/Expanded Movesets: Are handled as part of the AI (meaning Poseidon, Dullahan, and Doom Dragon) and are decided by their turn count.

Block x% of damage: The 90% and 95% effects are treated the same but the 50% and 60% ones are not listed with them. I need to do more research on what this means.

Advanced Priority: Guard Aura and Counterattack ability effects (#74, #88) use the following calculation to have advanced priority if they have the priority formula: Agility + 10000.


I'll update as I find stuff; feel free to ask questions or discuss if you wish.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

leaf

QuoteBlock x% of damage: The 90% and 95% effects are treated the same but the 50% and 60% ones are not listed with them. I need to do more research on what this means.

Now that I think about it, this might make sense. These checks are for enemy-side effects, right? Is it checking if an enemy has this or if a player has this? Because block 95% is an enemy-only effect. And I'm not sure, but there might be a block 90% for enemies, too (or there was planned to be?). If it *is* a player-side check, then maybe the devs decided that block 50%/60% wasn't worth altering the AI for, but blocking 90% is? I've never actually noticed the AI change their behavior as a result of using barrier djinn, though, including flash.
[spoiler=quotes]
[9:00:50 PM] Randel Peltier: Ok...what did I do last night?
[9:01:19 PM] Kain: Something boring, repetitive, and lasted for about sixty seconds.
---
[10:45:08 AM] Salanewt: But yeah, the elemental phalluses are being... Stroked up by Saturos and co., and the energy will go towards... Mt. Muffin, where the Golden Climax will arise.
[7:28:42 PM] Salanewt: An added bonus is that Isaac and co. were trying to stop Saturos and co. because their beliefs state that Mt. Muffin should remain a virgin.
---
[9:54:21 PM] Randel Peltier: Guess the number in my head an you get to pick what I say. Number between 1-10
[9:54:28 PM] leaf: 11
[9:54:36 PM] Randel Peltier: @#$%!
---
[8:38:13 PM] Randel Peltier: Shes like this queen up on a pedastal that I have yet to court.
[8:38:29 PM] Kain: You've tried courting her.
[8:38:43 PM] leaf: and failed spectacularly
[8:38:44 PM] Randel Peltier: Ive tried...shes the best dating game ever.
---
[12:24:35 AM] Salanewt: I need to find a picture of a naked person to put on the Christmas tree next year.
---
[2:19:06 PM] Zeadra: wait... Rief's a guy???
---
[1:09:57 PM] Zeadra: well if you want to know if its a new effect or something weird, just check GS1, if side step is there maby it is the nimble dodge thing
[1:10:35 PM] Kioll: For once, you've contributed something useful.  o.O[/spoiler]

Daddy Poi's Oily Gorillas

If IQ is 3+ what does it default to?
Defend? Or does it get auto-reset to 0 or 2?

QuoteMultiple/Expanded Movesets: Are handled as part of the AI (meaning Poseidon, Dullahan, and Doom Dragon).
If I recall, I think that had something to do with Turns. Each turn number being a different "enemy" of the same enemy. ... and that bit would be hard-coded specifically for those enemies.
Which makes me think we could have another patch! (So that whenever an enemy has more than 1 Turn.... it uses the moves in the next enemies....)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Salanewt

I may have to double check the code but from what I can tell IQ 3+ is treated the same as 1.

That kind of patch could work, but I feel like it should have some other kind of check in place than turn count. I'm also not entirely sure about Poseidon because it changes its moveset entirely after being hit with Trident? Unless I am forgetting something.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Daddy Poi's Oily Gorillas

@3+ being one: Interesting.... So that would "break" the scale... except that 3+ is unused....

@Poseidon: In that case... he'd be one of the exceptions, maybe.... The main point of basing one patch on turns is to make it simple... (and accessible to those who don't hex edit).... I suppose you could have a more complex one, if needed. Assuming you can think of the right type of check to put in place?
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Salanewt

Well, it's a scale with a hard cap because there are three behaviours that are coded for specific values (items and PP costs for 0, seal for 2) with every other value essentially being identical.

Poseidon: I'm pretty sure Dullahan also doesn't use multiple movesets unless he switches one out with an ability, no?

Turns: Well, it could even be something as simple as including another value or using the IQ value to also allow for multiple movesets rather than just turns. The issue with setting it to turn count is that it forces you to waste enemy slots for the sake of expanded movesets. Put another way, it forces you to carefully consider them should you decide to give more turns to another enemy. By linking it to turn count, you now have to edit the 1-3 enemy slots that follow it if you want them to be four unique enemies, just like you have to edit other enemy slots if you want to keep those monsters in the game.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Daddy Poi's Oily Gorillas

I figured it was something similar to that....

Poseidon: Hm... I think my memory comes from Doom Dragon, and not of any other enemies. ... Pretty long time ago that I researched it, though. - So yes, I should probably identify which portions of the code are for Dullahan/Poseidon. (Unless you have those addresses already?)

Turns:
Not sure, but I would imagine this to be a rare use (where people are still mostly doing 1 turn?)
And depending on organization, I can see 1-turn enemies at the beginning, 2-4 turn enemies at the end....

It's about as dirty as Superstar Saga's way of picking a random battle (except that multiple turns wouldn't use the same moveset UNLESS we followed something similar to Atrius's Class patch. e.g. Turns 20+ and such....)....

A separate value may be best, I guess....? The initial thinking was that you wouldn't have to repoint to free-space (which I don't really like doing.) ... you might still not have to in your case? Dunno?  ... any solution that doesn't require such is better than nothing.
May or may not take more patch-thinking time, though...  - If it takes too much time, then you might as well just extract the game and hand it to everyone?

---
Also.. should we be making patches, even?
armips, and code files should be enough, I recon?
The source and documentation all in one file..... to /encourage/ anyone to edit as they please if there's only one tiny thing they wanted to change about whatever "patch" was made...
And would also help with anyone who wants to repoint stuff elsewhere. (To avoid collisions between patches.)

Soo... armips>nightmare ?

[small]
@Lishy : I still haven't forgotten... Djinn fights with boss musics... just still haven't gotten to it yet... but when I do... it _might_ require some repointing.. which is why it still hasn't gotten done...... so ^ (armips)... is what I might plan to use for my release method. (Text file to use on armips... instead of patch to use with Lunar IPS/whatever...)
Easy repointing & coding mechanism. :)
Not sure if armips has a Linux build ? But armips IS open-sourced... so I imagine if not, someone could be capable.... / If it works with a WINE-like program... not sure if it matters or not... given armips simply applies the stuff... and it is not like a game where you have to worry about fps.


Thought:  armips + my icon compressor + source code template (that would need to be made/but should be short?)  = newbie friendly? (Since you no longer would have to waste extra time going to the addresses when you want to edit them... and can likely do faster organization/such.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Salanewt

Poseidon: I recorded a little bit but not a whole lot; mostly just monster ID checks and a little bit of what happens in each section of code.

Well, turn counts above a certain value could work I guess. I'm thinking 5+ turns if we do it that way. I was pretty tired when expressing my concerns with that idea before so I didn't give it a whole lot of thought.

Isn't armips much more technical and code-oriented?
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Daddy Poi's Oily Gorillas

Okay thanks... I'll check in a bit. (Could be an hour or so.) *checks* So you are putting the editor's id #? And not the original? Hmm....

@Switching to 5+: And that's kinda why I like the armips method... good for the user experience for those who want to change tiny things like such. (I probably would choose 10+ so it can look better?)

Armips is basically just a hacker's compiler..... It'll compile your asm and also insert any data files you "include" with it in your code.





EDIT:
Poseidon's moveset/enemy is based on Turn #.... so very much like Doom Dragon.
Dullahan is probably the -only- enemy that does it differently. - He does not base it on Turn #, instead... it is just an expanded moveset. (24 abilities, pick a random one, then increment through all 24 continuously.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Salanewt

#9
Okay, so I finally got off my butt and researched how IQ affects targeting.

There's a global rule that targets are chosen at rates of 6/5/4/3, depending on how many targets are around. This is done by calculating a random 16-bit value, shifting it around, and comparing it to thresholds of x05, x0A, and x0E, again depending on how many targets are around; the end RNG will be capped at x11, x0E, or x0A, yet again depending on how many targets are around.

How targets are assigned varies.

For IQ 0, the rules are:
- Targets are assigned from 0-3 based on their current HP;
- The enemy's top priority target will be whichever of the two left-most targets has the most HP; after that, it will look at everyone and rank them based on current HP, from most to least.
- This changes throughout battle, generally by getting damaged or through stat fluctuations caused by class changes.
- In a situation where two characters have the exact same HP, the enemy will prioritize the left-most of those characters.


IQ 1 works the same way, except that it compares max HP.

Let's take a look at a couple examples, using an enemy with IQ:1.



In this instance, Garet has the highest HP so he is Agatio's primary target. Felix becomes his second, Jenna third, and Sheba fourth.




However, in this case Jenna is prioritized as his top target because Garet is not in one of the two left-most slots. Garet therefore becomes his second pick.

In both scenarios, Sheba is the least likely to be chosen because she has the lowest max HP. Agatio is twice as likely to pick Garet in scenario 1, or Jenna in scenario 2, than he is Sheba.

However, if Agatio had an IQ of 0 instead, then Sheba would become his top priority in scenario 2 because she has the highest current HP out of the characters in the first two slots.


Everything above is ignored if:
- The chosen ability does not target enemies/the opposing party;
- If the ability is multi-target;
- If its formula is above #5 (base damage);
- The enemy has an IQ of 2, which I think just makes their target selection entirely random.



Stay tuned for more info at some point in the future I guess.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?