’Cause all games were better on the GBC

You are not logged in.

#1 2014-08-09 04:53:07

Registered: 2011-12-09
Post 38/79

Trainer Attributes (AI, Artificial Intelligence), Crystal

I am currently in the process of making a fairly challenging hack of pokemon crystal, and during my recent playtest, I came across an oddity involving Janine's AI.

I am confused with some choices two different AIs make in Crystal. Lt. Surge's AI is fine (the bytes are D3 03 44, in offset 3961d to 3961 , which is considered to be the best trainer AI attribute, as well as the default AI to gym leaders, based on this link: … ibutes.asm. )

This can utilize hidden power grass (I have changed Lt. Surge's and Janine's Trainer DVs to give out hidden power grass at 70 base power) and electric moves without failure. Such as consistantly using thunderbolt on dragonite, and hidden power grass on Golem. I'm aware that the trainer attribute "AI_SMART" is the one that handles Hidden Power variables (which is astronomically better than in third gen AI's handling of hidden power), and was happy to see that the Jolteon and Zapdos could use hidden power grass exceptionally well.

Janine on the other hand, who supposedly has the same AI trainer attribute, and the same bytes as Lt. Surge, (D3 03 44, located in offset  3964e to 39650, which is also default), had Weezing to keep using hidden power as opposed to STAB Sludge Bomb on raikou (raikou had weaker physical defense and higher special defense, wheezing had lower special attack vs attack... so it doesn't make sense why the AI chose hidden power over sludge bomb). It doesn't end there either, When I used Dragonite against Weezing, the smart thing the AI would and should do is use Sludge Bomb. Instead, it went for hidden power grass, which was 4x resisted. And at one other try, Janine's Weezing used Fire Blast instead of Sludge Bomb.

Is there something else to the trainer AI's? I've heard rumors that the amount of money the trainer gives affects the AI... but Lt. Surge and Janine gives out the same ratio, so that theory doesn't hold ground.

Bottom line, I would like Janine's AI to be as smart and as consistent as Lt. Surge's in choosing the correct moves, so the question is... is there another factor with Janine's AI? (As well as other boss AIs?) (The only other potential anomaly is Brock, and Red, Blue, Silver Fight 2, and Cal being very averse to using status moves.)

Last edited by SinisterHoodedFigure (2014-08-10 01:07:44)

SHF... The Most... Sinister Hooded Figure


#2 2014-08-10 04:30:58

Registered: 2012-04-09
Post 470/679

Re: Trainer Attributes (AI, Artificial Intelligence), Crystal

I consistently get Sludge Bomb from Janine using dvs 0xeeff, regardless of move order. Double-check your dvs (Janine's are at 9:7108). Recall that the ai picks its move before the player, so if you're testing with savestates you could be replaying the same result.

I don't get Fire Blast either. If you think there's something else going on, the easiest way to find out is by setting a breakpoint at line "call FarCall_hl" in AIChooseMove and following the move scores at Buffer1 (0xd1ea) in ram.


#3 2014-10-20 23:46:24

From: Spain
Registered: 2012-09-16
Post 220/450

Re: Trainer Attributes (AI, Artificial Intelligence), Crystal

Huh, I know I'm quite late, but in case you are still interested...

The AIScoring_Aggressive layer discourages all the damaging moves by one point except the move that does the most damage. It treats any move as a non-damaging move based on whether its base power is lower than 2 or not. Hidden Power's base power is hardcoded as 1, so hidden power is not affected by this layer.
This means that after this layer is executed moves' scores are affected like this:
- Most damaging move: +0 (if all damaging moves are immune, all of them will get +1)
- Other damaging moves: +1
- Hidden Power: +0
- Non-damaging moves: +0

Remember that the lower the better.

Now let's check hidden power's AI:

AIScoring_HiddenPower: ; 3909e
    push hl
    ld a, 1
    ld [hBattleTurn], a
    callab HiddenPowerDamage
    callab Function347c8
    pop hl

    ld a, [$d265]
    cp $a 
    jr c, .asm_390c9 ; discourage if not very effective

    ld a, d
    cp 50 
    jr c, .asm_390c9 ; discourage if power < 50

    ld a, [$d265]
    cp $b 
    jr nc, .asm_390c7 ; encourage if super effective

    ld a, d
    cp 70 ; encourage if power = 70
    ret c

.asm_390c7 ; encourage
    dec [hl]

.asm_390c9 ; discourage
    inc [hl]

In short:
+1 if base power < 50
+1 if type matchup is immune or not very effective
-1 if type matchup is super effective
-1 if type matchup is neutral AND base power = 70
+0 if none of these conditions meet

So let's analyze the cases you mentioned:

  • HP Grass 70 / Thunderbolt vs Golem: HP = -1 / Thunderbolt = 0 --> Use HP

  • HP Grass 70 / Thunderbolt vs Dragonite: HP = +1 / Thunderbolt = +0 --> Use Thunderbolt

  • HP Grass 70 / Sludge Bomb vs Raikou: HP = -1 / Sludge Bomb = +0 --> Use HP

As for Fire Blast / Hidden Power over Sludge Bomb on Dragonite, I'm a bit lost. The other five layers (AI_STATUS_RED | AI_STAT_MODS_RED | AI_CAUTIOUS | AI_STATUS_IMMUNE | AI_RISKY) should not affect the fact that sludge bomb is favored over HP/fire blast. Were Sludge Bomb's PP over by any chance? Even if so, the move picked should've always been Fire Blast, so I'm not sure.

Last edited by Crystal_ (2014-10-21 18:16:44)


#4 2014-12-28 04:49:18

Registered: 2011-12-09
Post 47/79

Re: Trainer Attributes (AI, Artificial Intelligence), Crystal

I think I know the problem there. It was the involvement of "Self-destruct" and "explosion" in the movesets and the AI feature "AI Risky"; the AI with the normal trainer AI (apart from team rocket's because of "type effectiveness", which factors in type matchups, means it will avoid using the explosion moves unless absolutely necessary, which may involve not using the strongest damaging move. I've seen this happen with Brock in the original GSC, where I thought he had bad AI because his graveler used not very effective moves, and it happened sometimes with pokemon that have explosion moves. The

I fixed this with Janine by just using the original team rocket executive AI, which had the most features, including type effectiveness, which does factor in not very effective damage.

SHF... The Most... Sinister Hooded Figure


Board footer

Powered by FluxBB