1. DLP Flash Christmas Competition + Writing Marathon 2024!

    Competition topic: Magical New Year!

    Marathon goal? Crank out words!

    Check the marathon thread or competition thread for details.

    Dismiss Notice
  2. Hi there, Guest

    Only registered users can really experience what DLP has to offer. Many forums are only accessible if you have an account. Why don't you register?
    Dismiss Notice
  3. Introducing for your Perusing Pleasure

    New Thread Thursday
    +
    Shit Post Sunday

    READ ME
    Dismiss Notice

Fixing Pokemon AI

Discussion in 'Pokémon' started by Lungs, Oct 3, 2013.

  1. Lungs

    Lungs KT Loser ~ Prestige ~ DLP Supporter

    Joined:
    Jul 16, 2011
    Messages:
    206
    Gender:
    Male
    Location:
    i love girl's generation tbh
    High Score:
    1803
    Okay so I'm sick and tired of playing against the Pokemon AI.

    As a competitive battler, basically you need the lowest order of "skill" to beat the Pokemon AI:

    "Can I hit this pokemon supereffectively and probably kill it before it kills me?"

    If yes, proceed. Otherwise, switch to a pokemon that can.

    Proceed to win.

    What actually kills us in Nuzlocke? Explosion. LOL.

    ========

    Current AI (grabbed from pokemon wikis and shit):

    1. AI decides whether or not it should use an item. Items have usage priority (activated via battle clauses): "What do I have? I have Burn Heal, Antidote and 2 Potions. What does my pokemon look like? Burned, at high health? Use Burn Heal! Burned, at low health? Use Potion!" etc.

    2. AI has selected to not use an item. AI decides whether or not to withdraw a Pokemon. The AI cheats - knowing your moves, pretty much, whether or not it can use moves against your pokemon, whether it's going to be owned via status ailments/things like Perish Song/Yawn, etc. AI decides whether or not to switch.

    3. AI has selected to not switch. AI chooses a move, based on effectiveness, abilities, move effects, held items, status, what you can do to him/how essential it is that it uses a move which is "optimal". I.E., it'll play better if it's getting owned.

    ========

    Problems:

    1. Counterintuitive and linear item usage. Okay, either use Antidote or kill you. Pokemon's going to die from poison, but it can kill you with Flamethrower. LET'S USE ANTIDOTE AND GET WRECKED BY A DAMAGING MOVE. Herp. This is why items are given priority - i.e. Full Restore, in this case, will solve some of the AI's problems.

    2. Okay, so you're going to switch out a sleeping Metapod at 2 health, to let in a bug pokemon that's going to take a Brave Bird. Right, smart.

    3. Opposing trainer has one pokemon left? Well, obviously this is a time to calm down and start using Screech, because LOL HE'S SCREWED, RIGHT? RIGHT? Oh, is that a dragon dancing Dnite. Oops.

    Basically, this is artificial difficulty, on all orders of decisionmaking. It's obtuse as fuck. AI had nothing on 8 year old Lungs, who was certain that Surf was probably a good idea against Blaine.

    ========

    How do we fix this?

    Well, let's think like we're playing Pokemon Online.

    1. What is your reliable chance of defeating your opponent this instant?

    2. Is this Pokemon comparatively effective against the Pokemon in your opponent's team?

    3. What is the most damage this Pokemon can do against your opponent's team?

    4. Is the attempt to save this pokemon worth its trouble if it's in trouble?

    ==============

    Along the way, there's a continuous "adjustment" to your opponent's playing style - is it offensive, stallish, switch, trollish, etc… Obviously in-game, there are things like items to consider as well.

    With this in mind, let's think of a couple of "global variables". These are NOT calculated on the spot. AI does not have short term memory in Nintendo devices. Only Xion can into neuroplasticity.

    1. Trainer's Bench, which is no less than 0, never greater than 5.

    2. Max "Effectiveness" of each and every pokemon vs. each and every pokemon of Trainer.

    a. Max Damage Possible with Damaging Moves
    b. Max Damage Received from Damaging Moves
    c. Speed
    d. Max Damage Possible with Nondamaging Moves
    e. Player's Mean Damage Output Per Turn via Damaging Moves
    f. Player's Mean Damage Output Per Turn via non Damaging Moves
    g. Player's Mean Damage Intake Per Turn via Damaging Moves
    h. Player's Mean Damage Intake Per Turn via non Damaging Moves
    i. Player Switches Integer

    3. AI's Items.

    ==============

    So what would be some direct variables?

    1. Current Poke's Health
    2. Player Poke's Health
    3. Current Poke's Max Damage Output
    4. Current Poke's Status
    5. Player's Likelihood to Switch (this will be explained later)

    ==============

    And, maybe some discrete functions to ponder:

    1. Survivability (how many hits can this pokemon take from that pokemon, considering direct variables?)
    2. Kill Likelihood (basically the reverse of survivability)
    3. (some kind of) Effectiveness Constant (which weighs the "wins" each of your pokemon has against the "losses" each of your pokemon has - maybe a fairly high Effectiveness Constant would lead to merciless and safe play, something close to zero would be make the AI grab some higher risk and higher rewards, and a fairly negative one would force the AI into playing unpredictably)

    The idea of a continuously calculated Effectiveness Constant (which isn't a tiring operation) would probably make the AI better at pokemon than you. ;)

    ==============

    Well, first of all, we've solved one problem already, sort of.

    1. Win Con consideration.

    Pokemon in Player's Party = 0
    Pokemon Speed > Player Pokemon's Speed
    Current Max Damage Output > Player's Poke Current Health

    Attack and win.

    2. Grace

    If Peripheral Damage > Current Health AND Player Poke's Max Damage > Current Health AND Player Poke's Max Damage + Peripheral Damage > Highest Tier item + Current Health, then move on to Phase 3.

    If Max Health - Current Health > T1 item, don't use it.

    … T2, T3, etc

    If Max Health - Current Health < Tx (whatever you run it down to), then move on to Phase 4.

    3. Trade


    If Pokemon in Player's Party ≤ Pokemon in AI's Party AND AI's Poke Speed > Player's Poke Speed AND AI's Max Damage/Player Poke's Max Health > Player's Poke Current Health/Player's Poke Max Health, Attack with Max Damage. If this expression isn't true, move on to 3a.

    3a. Switch

    Some kind of function of Switch Survivability and Effectiveness Constant will probably come into play here. If the AI doesn't like the odds, then he'll stay in and select the "best" possible move in the hope that you might make a mistake.

    4. Smart Item Usage

    If Player Poke's Max Damage > Current Health AND 50%(Current Health + Tx) > Player Poke's Max Damage, use Tx item, otherwise 4a.

    4a.

    If Player Poke's Max Damage > Current Health AND 50%(Current Health + T(x+1)) > Player Poke's Max Damage, use T(x+1) item, otherwise 5.

    5. Strong Play

    If Speed > Player Poke's Speed AND Kill Likelihood ≥ Survivability, attack. Otherwise 5a.

    5a.

    If Speed < Player Poke's Speed AND Kill Likelihood ≥ Survivability - 1, attack. Otherwise 6.

    6. Powerful Play


    When Player Poke's Current Health - Max Dmg = Effectiveness Constant + X AND X > 0, attack. Otherwise, go to 3a.

    ==============

    Nondifficulties:

    1. The Game system has NO trouble handling the "thought" process or global/direct variables. Nintencode is fantastic for quick operations of arithmetic and comparison.

    2. Obviously, how to treat moves like Roost and Sunny Day and abilities that do things like Regenerator, etc, etc aren't written in. I have confidence that it wouldn't be quite very different from the above cases - just a bit tedious.

    Difficulties:

    1. I barely understand piecewise functions (basically, all three discrete functions, especially effectiveness) in real life and the "neat" trick around having calculus in number 6 won't fly in real life, just in reader space. Trying to program it will be a nightmare for me, I think.

    2. Things like abilities and stuff actually do add a whole bunch of complexity and it'll probably take a much larger amount of time putting that in than writing this up.

    3. I might have lied about the item usage being "smart", because moves like Rollout would fool it pretty easily if there wasn't some "direction of battle" check of some sort.

    Resolutions:

    3. There's a fair chance that there's already nintendocode for some of that stuff, though I rather not be hopeful.

    Other Things:

    Totally up to you guys to attempt to amend this - obviously I'm not going to just change anything without a reason and I reserve the right to argue against you. Also, I guess I'd like to hear thoughts about shifting the difficulty curve in the game.
     
  2. Oz

    Oz For Zombie. Moderator DLP Supporter

    Joined:
    Jan 31, 2008
    Messages:
    9,027
    Gender:
    Female
    Location:
    Baile Átha Cliath
    Alternatively, it's a kid's game and they don't want to add artificial difficulty on top of having to grind levels.

    I'll take a closer read later.
     
  3. Sechrima

    Sechrima Disappeared

    Joined:
    Sep 30, 2010
    Messages:
    841
    Location:
    NRW, Germany
    This would make a lot of little kiddies cry. But for older fans, it'd be awesome.
     
  4. KaiDASH

    KaiDASH Auror DLP Supporter

    Joined:
    Oct 6, 2010
    Messages:
    613
    Location:
    Australia
    Does this matter?

    If you know the AI algorithm you can game it. It's why playing vs people is so much better.
     
  5. LT2000

    LT2000 Heir

    Joined:
    Jun 5, 2005
    Messages:
    2,706
    Ze crithax.
     
  6. methor

    methor Fourth Year

    Joined:
    Nov 30, 2011
    Messages:
    138
    In roguelikes the theory is that a good AI is one that looks like it is making interesting decisions. So If the player says things like "He could have switched out but he was pissed and went for an all out attack", then you know that the AI is a success.
     
Loading...