• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Discussion] AI discussions

  • 1,224
    Posts
    10
    Years
    I'm going to try doing some of the AI things Maruno said still needed to be done.

    Check if move will thaw the target
    Spoiler:


    Take additional effects into account:
    Spoiler:


    Opponent more likely to try and set up Light Screens/Reflects early in the battle
    Goes in PokeBattle_AI, replacing the appropriate when statements
    Spoiler:


    Slightly prefer status move if having Prankster (goes right after the additional effects snippet from above)
    Spoiler:
    Will add more to this as I go.
     
    Last edited:
    I'm going to try doing some of the AI things Maruno said still needed to be done.

    Check if move will thaw the target
    Spoiler:


    Take additional effects into account:
    Spoiler:


    Opponent more likely to try and set up Light Screens/Reflects early in the battle
    Goes in PokeBattle_AI, replacing the appropriate when statements
    Spoiler:


    Slightly prefer status move if having Prankster (goes right after the additional effects snippet from above)
    Spoiler:
    Will add more to this as I go.

    Nice work there Mej...
    But to be honest, I think AI just needs to call a few added defs:
    canOHKO
    attackSuperEffectiveOrNot
    canDefrost
    canDefeat
    shouldSwitchPoke
    shouldRecover
    canProtect
    shouldRaiseStat
    shouldLowerStat
    And you get the idea with that, I too have noticed some Pokémon using odd moves, I've specifically gave myself 5 Pokémon at a quick start to test some new scripts and 3 of the 5 start with 1HP... Sometimes when I go in to battle, the opponent uses Leer or Bide or Protect, things like this, it makes no sense, if AI were told, "look, players' Pokémon has <10HP, you could use Tackle, which is neither strong or weak, this could potentially KO the Pokémon", but as it is, it's sometimes like playing against Anime styled Slowpoke... The less and less HP you have, the more likely an opponent should use tougher attacks, even if that attack has an accuracy or 10 or 100... Who here would use a level 50 Raichu, with a moveset of Quick Attack, Thunder, Tail Whip and Double Team, then battle a level 70 Gyarados and not use Thunder for your first attack? Why should AI be so different?

    My suggestion is using a guys mind as is... Guys can't multi task, let's face it... Neither should an opponent, so splitting everything into separate definitions, a single score for such moves like Tackle, could potentially rise to 100 (or whatever), so a level 8 Rattata won't use Tail Whip on my 1HP Pokémon because the checks, canDefeat, canOHKO, attackSuperEffectiveOrNot, shouldLowerStat etc. etc. blah blah blah, should tell Rattata to use Tackle because it's score should be massive.

    With the way Essentials is going, once the AI has been given a personality, a mind, players will have to then think logically when playing and not just aimlessly using a 1 Pokémon team like I do in the official games because the AI are so stupid most of the time.
     
    Spoiler:

    That sort of stuff tends to be true already, if you're facing a trainer. Wild Pokemon and low level trainers wouldn't know the intricacies of battling, so there's some variance there as to what they're supposed to do. I would imagine you could change the difficulty setting somehow so that wild pokemon behaved like decent leveled trainers. Not sure though.

    Completely overhauling it isn't really something I nor a lot of other people are up for really.

    Edit: Speaking of which, does this line here mean that wild pokemon recieve a skill of 0? (which is then changed to the minimum skill level)
    Code:
    skill=pbGetOwner(attacker.index).skill || 0

    Edit 2: I see now that it returns a value of 30 when there is no trainer. This could be changed to improve the skill level of wild pokemon, I would imagine.
     
    Last edited:
    I always think extra defs are always better than adding extra lines... You have more control over defs but added lines can cause unwanted problems ie. 1 exp gain, battles don't battle but show messages, and so on... I'd feel more comfty if they were added, yes it's more work, but let's say v15 focuses soley on AI improvements and bug fixes, forget about any new suggestions and features... Does this become any more hard work than v14 already was... Personally I don't think so, I took a few months off, came back and with a little look at my game, and a little help from here, I've learned more about scripting already.

    Can we at least think of pros and cons before rejection... Do you actually feel editing lies of code would benefit better than adding new defs in... Could you at least code yourself, a means of using surf instead of ice beam, on a fire type, both inside the code and within a def and see which is preferred.

    If Maruno would like help on the latter, he could always create a new section and post here with the help from us, and add it at another date.

    Technically we are a team... Just not partners... If that makes sense to you haha
     
    AI (in this context) has to approach the battle by looking at each element in turn individually. There's switching, there's using an item, and there's using one of (up to) four moves. There's also Mega Evolution, but you're always going to want to do that.

    I think it needs overhauling. I'm sure we can reuse many parts of what's already there, but in different combinations and at different times. At the moment, the AI isn't aware enough to realise what a move will actually do (e.g. whether it will KO the target rather than just hurt it). I think a rethinking will help with the AI deciding what is best.

    I'm talking about the basics of decision-making here. I'm not thinking about "screens should be used immediately" - those are individual effects and aren't as fundamental as other factors. No, first the AI should be determining things like type immunities and targets, and coming up with a way to decide which is most preferable. Only then should it worry about individual effects. Effects can have a stronger weighting than the more general decisions do, of course, but they're so narrow in scope (and often linked to particular strategies) that I think it's a bad idea to start with them.

    There's also a matter, right at the start, of deciding if/how much the AI should be able to cheat. That is, how much information about the state of battle it can use. When I went through the AI for v14, I generally let higher skill levels know more things, e.g. what the target's ability and held item are, and what their stats are. Things the player is unlikely or unable to know. There's also the possibility of knowing what the opponent (the human) is about to do (e.g. if you know they're using Pursuit, you might not want to switch out), which is definitely cheating. I don't think AI will ever be as good as a person, so I don't think giving it advantages in the form of more information to compensate is necessarily a bad thing. How much, though? And how do we differentiate between the different levels of AI?

    No manipulating the calculations, though. That's just bad form. The AI will have the same chance of additional effects/thawing/damage dealt as human players do.

    So basically, I'd like to come up with a new set of logic for the AI, from start to finish. Some or even most of it may be similar to what there is already, but what's already there seems to me to be rough at best. It's all about getting a thought process together for the AI to follow. What Nickalooose said in her first post is a bit of that kind of thing.
     
    I definitly don't think AI should gain boosts in stats and things (other than when we set the PBS text anyway) but maybe in the trainers.txt, we could give the trainer a smartness rating, maybe out of 10:
    Code:
    BUGCATCHER
    Bob[COLOR="Red"],,4[/COLOR]
    3
    SURSKIT,26
    SPINARAK,27
    BEEDRILL,25
    The higher the rating, the smarter the trainer, so a professor and a scientist would have a rating of 10 and will more than likely prove to choose a more logical way of fighting and will then choose moves which will effect type advantages as it's first attack, if none exists, try for defensive tactics (light screens, protects, defense curl), with the lastmoveused script that is already available, a score could then be set to call whether a move would counter that attack unless it was a straight up hitting attack with no current effect (like Tackle).

    But saying that, AI should never be able to "cheat", knowing what move you're going to use is a fine example, however, if the opponent had an idea of what moves a player has (which we already know exists because as the code up there shows, I didn't define any moves, but the game will give them some anyway), the opponent could choose wiser, but if we were to add the smartness rating, the lower the number, the less likely they'd know what moves your Pokémon could have... Of course, it would read from the pokemon.txt PBS file, so if I had a Butterfree and was to have been taught Venoshock, how can the opponent counter, it wouldn't know to heal it's poison immediately if Butterfree were to use Poison Powder at turn 1... But Pokémon like Snorlax who can use rest, could potentially use that when it's life gets below 60% or 70% with a status effect and instead will not use it on turn 2 for no reason then again when it wakes up...

    What Maruno said about choosing target via type, OHKO and things like that is what I'm getting at, but not every trainer should be this smart... So I think somewhere we need to tell the game, this trainer is smart, this trainer is tough, this trainer defends, this trainer is not smart... So maybe instead of just adding 1 trainer stat as in smartness, why not give it 2:
    Code:
    SCIENTIST
    Bob[COLOR="Red"],,2,7[/COLOR]
    3
    VOLTORB,34
    VOLTORB,36
    ELECTRODE,38
    In this case, Bob is pretty silly, so he wouldn't really know what moves my Pokémon would have, but could still have a general idea I suppose (as if to say my Pikachu was level 29 and would more than likely just learned Thunderbolt, but the trainer doesn't know this at which it could possibly pick 4 random attacks from it's move list to guess what it will possibly use.)
    But the new number 7 here could mean he would use more tougher moves or in this case Selfdestruct (because he's just that silly), during the battle at any time, higher the number, the more likely they will use tougher moves, but a smarter trainer would wait until either his Pokémon are almost faint or the players Pokémon are almost faint (maybe).

    I don't know if anyone has seen on my game, but I gave characters personalities, so each trainer can do different specialties, Nurses healing effects are better than say an Engineer, but an Officer had better heart, thus Pokémon are happier with them more than being with a Team Rocket Grunt... It's little things like that which makes AI better, smarter, wiser, tougher...

    Which is why I think new defs should be made we could literally make trainers "think".

    Sorry for my essay, I just kept typing lol.
     
    Just a couple quick examples to think about.

    In Gen 4, Smogon made an AI that can battle pretty perfectly but it takes forever to make a decision. It was also designed to guess the opponent's team based on the metagame and typical team composition data, and make decisions with that in mind. It never "cheated", but rather made the statistically best decisions.

    Way back in Pokemon Stadium 2, high level AI played pretty well, but did so by cheating a lot. It was also predictable in the way it would cheat, making you often use counter intuitive attacks to beat them, like Tbolting the Rhydon knowing it would switch to Lapras every time or double/triple switching to get a matchup where the AI couldn't beat you even knowing your next move.

    Both of these were effective by knowing the right times to switch out of an unfavorable matchup. Gamefreak's AI rarely switches- the most common Battle Tower tactic is to trick a Choice Item and then setup while the opponent stays in indefinitely using a resisted attack.
     
    First of all, congratulations Maruno on the overhauling of the AI. It was definetly an improvement, and in fact I believe you've done a better job than yourself is thinking. The determination of each move's score seems pretty right to me (for those that haven't studided the code yet, it does consider type effectiveness, STAB, defrosting, abilities, switching out, etc).

    However the def "pbChooseMoves(index)" doesn't do justice to the improvements (and mind you, it was also improved by a lot in v14). To start things off, the code is too harsh deciding when a move is much better than others:

    Code:
        if !wildbattle && maxscore>100
          stdev=pbStdDev(scores)
          if [B]stdev>=75[/B] && pbAIRandom(10)!=0
            preferredMoves=[]
            for i in 0...4
              if attacker.moves[i].id!=0 && (scores[i]==maxscore || scores[i]>=250)
                preferredMoves.push(i)
                if scores[i]==maxscore
                  preferredMoves.push(i)
                end
              end
            end
            if preferredMoves.length>0
              i=preferredMoves[pbAIRandom(preferredMoves.length)]
              return
            end
          end
        end

    It expects a StdDev of 75 to pick a move without it being completely random (I will come to that later). That's WAY too much, that situation will only happen if there is one exceptionally good move and 3 crappy ones (by crappy I really mean it, low base damage resisted attacks against physical/special walls, and useless status moves that have no utility (that have already been used or something)). For example I did some calcs using 2 lvl 50 pokémon with 100 in each stat, no EVs, IVs and using only 100 accuraccy damaging moves with no extra effects. These were the results:

    #1 move: (super effective, 60BP) Score = 112 \ Damage = 29%
    #2 move: (regular effectiveness, 80BP) Score = 107 \ Damage = 18%
    #3 move: (resisted, 80BP) Score = 104 \ Damage = 9%
    #4 move: (super effective + STAB, 90BP) Score = 128 \ Damage = 65%

    Standard Deviation => 9.24

    As you can see, even though one move is MUCH better than the others (at least 2 times better) the scores don't have a StdDev nowhere near as high as they need to be so the AI actually chooses the move it will use. Now that this doesn't happen, the next thing the AI does is ask itself if it should switch. Using this simulation it won't happen, after all the scores weren't low, and they need to be REALLY so it even considers it (and to make it worse it also requires the pokémon to be in the field for at least for a number of turns (2-5) and also rolls a dice (if it gets through all those requirements it will only switch in 80% of the cases).
    What happens next is even more funny, if all 4 moves are completely crap and the pokémon can't switch it will choose randomly it's move, which is fair and isn't our case since our scores don't require this or switching the pokémon.
    Since our situation doesn't fit anywhere else, we get to the last part of the def, where the majority of times the AI will fall into since the other cases (the ones described above) are really hard to fall into:

    Code:
        else
          randnum=pbAIRandom(totalscore)
          cumtotal=0
          for i in 0...4
            if scores[i]>0
              cumtotal+=scores[i]
              if randnum<cumtotal
                pbRegisterMove(index,i,false)
                target=targets[i] if targets
                break
              end
            end
          end
        end

    So yeah, if you can understand this piece of code you can see how bad of an algorithm it is. It basically makes all the work the AI had of giving an score to each move useless by making it pretty much random. In fact it's not random, it favors the first items in the move's array. So using our example, it would be much more likely that moves #2 and #3 (the worst damaging ones by far!) would be used. and the move #1 would be more likely than #4 since it's checked first.

    What I suggest then? Work on this def and test the consequences of each change. Maybe we can see the true potential of the AI we have right now if we get this right. I will start tweaking this right away and see what I can get from it. If results are any good I will make a post about it or something. I hope this helps other people trying to figure out how to make the AI better!
     
    One question I have about the AI is how exactly is the AI difficulty selected? I know that the more money the Trainer type gives, the smarter the AI but can we get something more specific? What money amount do I need to give the Trainer Type to have the max difficulty? For example if I give a Trainer 100, is that the max I need to have the hardest AI? Or is it 300, or 1000? Really want to know this...
     
    One question I have about the AI is how exactly is the AI difficulty selected? I know that the more money the Trainer type gives, the smarter the AI but can we get something more specific? What money amount do I need to give the Trainer Type to have the max difficulty? For example if I give a Trainer 100, is that the max I need to have the hardest AI? Or is it 300, or 1000? Really want to know this...

    C+P from the first lines in the PokeBattle_AI script:

    # AI skill levels:
    # 0: Wild Pokémon
    # 1-31: Basic trainer (young/inexperienced)
    # 32-47: Some skill
    # 48-99: High skill
    # 100+: Gym Leaders, E4, Champion, highest level

    Yes, there are 5 categories, the level doesn't matter if it's higher than 100 or inside the same skill level group.
     
    C+P from the first lines in the PokeBattle_AI script:

    # AI skill levels:
    # 0: Wild Pokémon
    # 1-31: Basic trainer (young/inexperienced)
    # 32-47: Some skill
    # 48-99: High skill
    # 100+: Gym Leaders, E4, Champion, highest level

    Yes, there are 5 categories, the level doesn't matter if it's higher than 100 or inside the same skill level group.

    Okay, thanks for clearing that up for me.
     
    Which is why I think new defs should be made we could literally make trainers "think".
    In the rest of your post, you were talking about AI profiles, which would be modifications to the base AI to make it behave more like a particular personality (more aggressive, prefer healing, etc.). That's a possibility, but we need a base AI first before we can think about these modifications.

    As for the part I quoted, the question is when the "new defs" should apply. Each of the defs you suggested has a particular role (canOHKO, canProtectSelf, etc.). Should each of these goals be considered in turn, each time looking to see if there's an appropriate move? Or should each move be considered in turn, with the defs deciding how good it is (like what currently happens)? I think the latter.

    Talking about new defs isn't really helpful. Of course we'll have new defs if we need them, which are focussed on making particular calculations and determinations. What we need is to decide when to make those determinations, and how much one should trump another.

    I think it can work fairly similarly to how it already does. Any damaging move will go through a set of calculations to decide how much damage it will do (it should consider how devastating the move will be, not the literal damage values). Any move with a particular effect will decide whether that effect is possible or worthwhile (e.g. don't use Spikes if the opponent has no other Pokémon left) and alter the score of that move accordingly. Any move that hits multiple targets should be a bit more desired because it'll do more damage (I don't think I'm happy with the current way it does this). And so on. I just feel that it can be tidied up, making sure only and all the appropriate calculations are done for a given action.

    There's also the question of item versus switching versus move. These three currently have a definite order to them, and the next is only considered at all if the previous actions won't be done. Perhaps they can be merged together, e.g. a very weak AI foregoes using a Full Restore in order to finish off an opponent, which it currently wouldn't do because item usage comes first and it'll definitely (predictably) use the Full Restore if possible. Maybe this example would be default behaviour, maybe only aggressive AI profiles would do this, but should the possibility be there at all?

    In Gen 4, Smogon made an AI that can battle pretty perfectly but it takes forever to make a decision. It was also designed to guess the opponent's team based on the metagame and typical team composition data, and make decisions with that in mind. It never "cheated", but rather made the statistically best decisions.

    Way back in Pokemon Stadium 2, high level AI played pretty well, but did so by cheating a lot. It was also predictable in the way it would cheat, making you often use counter intuitive attacks to beat them, like Tbolting the Rhydon knowing it would switch to Lapras every time or double/triple switching to get a matchup where the AI couldn't beat you even knowing your next move.
    Some of that Smogon AI could be useful. It'd definitely show us how a bunch of serious players thought the decision-making process should work, and the relative strengths of different advantages (should causing poison be more or less preferable to lowering speed, etc.?), which would be very helpful. I'm sure we'd consider using a stripped-down version, with some minor cheating (knowing the opponent's moves/abilities/items and even next action) to counteract the dependence on metagame knowledge and loss of complexity.

    Code:
        else
          randnum=pbAIRandom(totalscore)
          cumtotal=0
          for i in 0...4
            if scores[i]>0
              cumtotal+=scores[i]
              if randnum<cumtotal
                pbRegisterMove(index,i,false)
                target=targets[i] if targets
                break
              end
            end
          end
        end
    So yeah, if you can understand this piece of code you can see how bad of an algorithm it is. It basically makes all the work the AI had of giving an score to each move useless by making it pretty much random. In fact it's not random, it favors the first items in the move's array. So using our example, it would be much more likely that moves #2 and #3 (the worst damaging ones by far!) would be used. and the move #1 would be more likely than #4 since it's checked first.
    I think you're misreading this code. All it does is choose a move to use at random, based on the score of each move. A move with score 200 is twice as likely to be picked as a move with score 100. That's all this does, and there's no bias to it.
     
    I think you're misreading this code. All it does is choose a move to use at random, based on the score of each move. A move with score 200 is twice as likely to be picked as a move with score 100. That's all this does, and there's no bias to it.

    The fact that it checks one move or another first it does make it a bit biased. But the main point of my post is that in the case of damaging moves, the damage each one deals has barely no weight in the final score as you could see with my example. That's why people complain why sometimes the AI chooses a really weak move when it could hurt you much more.

    A move that would deal 65% damage to a level 50 pokemon has 28,4% of being chosen, while one that does 9% damage has a 23,1% (considering that bit of the script isn't biased as you said). And mind you, that's for a level 50 pokemon. For lower levels the chances would be even more closer (to 25%) since the score bonus because of the damage is based on how much hit points the foe will lose.
     
    As for the part I quoted, the question is when the "new defs" should apply. Each of the defs you suggested has a particular role (canOHKO, canProtectSelf, etc.). Should each of these goals be considered in turn, each time looking to see if there's an appropriate move? Or should each move be considered in turn, with the defs deciding how good it is (like what currently happens)? I think the latter.
    I think each should have a particular "time", canOHKO for example should only be called at turn 1, is it worth using a OHKO attack at turn 18, I don't think so... But this shouldn't take away the fact they can use this, it just a specific check of course... Most of the time, specific moves would benefit a specific times in a battle, like why use recover if you've only lost 20 of your 150HP, while your opponent has less than you at comparison of HP bars, but sometimes AI does this... So checking opponent; type advantages, then opponent HP remaining, then user HP remaining, could be a viable check for recovery attacks, basically 0D5 and 0D6 attacks would use this... So maybe using move functions to pick what moves would/should be called... Is Poison Powder better then Stun Spore, in what cases are these decided? Butterfree learns these moves together... Which gets precedence? That's when these attacks could possibly check for type and stats for example (speed mainly I suppose), is opponent quicker? Is opponent susceptible to Poison at all?

    Talking about new defs isn't really helpful. Of course we'll have new defs if we need them, which are focussed on making particular calculations and determinations. What we need is to decide when to make those determinations, and how much one should trump another.

    In fact, could any of these be checked at each turn, since it's only 4 moves to go through it shouldn't lag up battles, I don't mean how it is currently (item>>>switch>>>attack), but at the start of each turn, finding out whether or not isPoisoned? isConfused? isStunned? isFrozen? isBurned? shouldHeal? canCounter? etc. etc. So this is the point where the attacks scores can be set, again and again.

    I think it can work fairly similarly to how it already does. Any damaging move will go through a set of calculations to decide how much damage it will do (it should consider how devastating the move will be, not the literal damage values). Any move with a particular effect will decide whether that effect is possible or worthwhile (e.g. don't use Spikes if the opponent has no other Pokémon left) and alter the score of that move accordingly. Any move that hits multiple targets should be a bit more desired because it'll do more damage (I don't think I'm happy with the current way it does this). And so on. I just feel that it can be tidied up, making sure only and all the appropriate calculations are done for a given action.
    Yeah, like somehow making Pokémon team up against one Pokémon, maybe the one with higher attack power or HP... Attacks that do damage to all Pokémon or multiples should get a higher score in my opinion but what if the 2 opposing Pokémon were both Water and Fire, should a Pokémon use Surf??? Especially if the Water type had Water Absorb... Should this matter? If things went in to account, then such moves can be used properly, like using it while the Water type has close to max HP and/or, the user is faster than it's partner.

    There's also the question of item versus switching versus move. These three currently have a definite order to them, and the next is only considered at all if the previous actions won't be done. Perhaps they can be merged together, e.g. a very weak AI foregoes using a Full Restore in order to finish off an opponent, which it currently wouldn't do because item usage comes first and it'll definitely (predictably) use the Full Restore if possible. Maybe this example would be default behaviour, maybe only aggressive AI profiles would do this, but should the possibility be there at all?
    The use of items should almost be last resort... Can opponent be KO'd? Can opponent be put to sleep? Can opponent self heal? Etc. And if all those fail, use items... But that's only in some cases, some trainers should use items just because they can, "well my Nidoran is at 3/4 HP but if I heal now, at least Nidoran will have more HP than the opponent."... If all were merged, that could possibly do exactly what it already does, is it worth the merge? Switching should probably be trainer specific, I.E Jugglers like to switch quite frequently, but then Gym Leaders don't switch at all (as far as I'm aware, but they've never really lasted long enough to find out), I know this doesn't come in to any sort of basis though.

    Some of that Smogon AI could be useful. It'd definitely show us how a bunch of serious players thought the decision-making process should work, and the relative strengths of different advantages (should causing poison be more or less preferable to lowering speed, etc.?), which would be very helpful. I'm sure we'd consider using a stripped-down version, with some minor cheating (knowing the opponent's moves/abilities/items and even next action) to counteract the dependence on metagame knowledge and loss of complexity.
    I actually answered this earlier, but minor cheating is a good tactic, like when I explained the knowing of a Pokémons 4 attacks if the AI smartness was high... Knowing of the opponents team however, this could mean a lot more cheating, but, could help for creating a "tactic", I'm not fond of this myself, but it may be beneficial.
     
    I think each should have a particular "time", canOHKO for example should only be called at turn 1, is it worth using a OHKO attack at turn 18, I don't think so... But this shouldn't take away the fact they can use this, it just a specific check of course... Most of the time, specific moves would benefit a specific times in a battle, like why use recover if you've only lost 20 of your 150HP, while your opponent has less than you at comparison of HP bars, but sometimes AI does this... So checking opponent; type advantages, then opponent HP remaining, then user HP remaining, could be a viable check for recovery attacks, basically 0D5 and 0D6 attacks would use this... So maybe using move functions to pick what moves would/should be called... Is Poison Powder better then Stun Spore, in what cases are these decided? Butterfree learns these moves together... Which gets precedence? That's when these attacks could possibly check for type and stats for example (speed mainly I suppose), is opponent quicker? Is opponent susceptible to Poison at all?



    In fact, could any of these be checked at each turn, since it's only 4 moves to go through it shouldn't lag up battles, I don't mean how it is currently (item>>>switch>>>attack), but at the start of each turn, finding out whether or not isPoisoned? isConfused? isStunned? isFrozen? isBurned? shouldHeal? canCounter? etc. etc. So this is the point where the attacks scores can be set, again and again.


    Yeah, like somehow making Pokémon team up against one Pokémon, maybe the one with higher attack power or HP... Attacks that do damage to all Pokémon or multiples should get a higher score in my opinion but what if the 2 opposing Pokémon were both Water and Fire, should a Pokémon use Surf??? Especially if the Water type had Water Absorb... Should this matter? If things went in to account, then such moves can be used properly, like using it while the Water type has close to max HP and/or, the user is faster than it's partner.


    The use of items should almost be last resort... Can opponent be KO'd? Can opponent be put to sleep? Can opponent self heal? Etc. And if all those fail, use items... But that's only in some cases, some trainers should use items just because they can, "well my Nidoran is at 3/4 HP but if I heal now, at least Nidoran will have more HP than the opponent."... If all were merged, that could possibly do exactly what it already does, is it worth the merge? Switching should probably be trainer specific, I.E Jugglers like to switch quite frequently, but then Gym Leaders don't switch at all (as far as I'm aware, but they've never really lasted long enough to find out), I know this doesn't come in to any sort of basis though.


    I actually answered this earlier, but minor cheating is a good tactic, like when I explained the knowing of a Pokémons 4 attacks if the AI smartness was high... Knowing of the opponents team however, this could mean a lot more cheating, but, could help for creating a "tactic", I'm not fond of this myself, but it may be beneficial.

    You should take a look at the code yourself, it isn't so hard to understand (at leats most of it). The current AI already handles pretty much all the situations you mentioned, including the ones regarding recovery moves:

    Code:
          when 0xD5, 0xD6
            if attacker.hp==attacker.totalhp
              score-=90
            else
              score+=50
              score-=(attacker.hp*100/attacker.totalhp)
            end

    Pretty cool right? The score is only decent when the pokémon hp is below 50%, how it should be. I still think we need to tweak how these scores are used to determine which move will be chosen beforehand. Reduce the amount of dice rolls the higher the trainer skill level is and adjust the weights on the scoring system (weak base 60 attacks that barely deal damage to a wall always have at least 100 of a score). I already got some pretty cool results by reducing the standard deviation needed so the AI smartly uses the best move available...

    After that we can add some basic defs that use handle speed, priority moves, if it can KO the foe, if it can be KOed etc.
     
    Yes I know.

    But my points being, changing how it is atm, switching from item>>>switching>>>attacking, could be better in some cases for example.

    You should take a look at the code yourself, it isn't so hard to understand (at leats most of it).

    If you could try to be less patronizing that would be great, I've helped people here for a long time, I know enough about the scripts thank you... Try making more of a discussion, like how to:

    Improve AI
    Give AI more personality
    A starting point in the right direction

    Something that could give us somewhere to begin, as Maruno has pretty much said, no point in thinking too far ahead, but let's find a base and move from there... There is no point in ripping apart the AI, but editing it, my opinion is that items should be used last, attacks should be chosen less at random, switching should be trainer specific... You know what I mean.
     
    Yes I know.

    But my points being, changing how it is atm, switching from item>>>switching>>>attacking, could be better in some cases for example.



    If you could try to be less patronizing that would be great, I've helped people here for a long time, I know enough about the scripts thank you... Try making more of a discussion, like how to:

    Improve AI
    Give AI more personality
    A starting point in the right direction

    Something that could give us somewhere to begin, as Maruno has pretty much said, no point in thinking too far ahead, but let's find a base and move from there... There is no point in ripping apart the AI, but editing it, my opinion is that items should be used last, attacks should be chosen less at random, switching should be trainer specific... You know what I mean.

    Sorry, it wasn't my intention to sound like that. It's just that those aspects are already covered by the AI, and I . In fact what it does actually is:

    Item >>> Attacking (unless moves are total crap, and even if they are it will roll a dice anyway) >>> Switching

    My entire point is that the base we have is already good, it's just the flaws it has hinders the good bits. But adding on a list of things we should add to the AI to handle in my opinion would be (in order of importance):

    -Make the AI aware if it is faster than the opposing pokémon. This is one of the pillars of pokémon battling, for example, a gym leader could refrain from using an item if his pokemon could KO the foe or recover. If it's slower it could consider using a priority move, switch or using an item.

    -I already mentioned above, but I think this deserves it's own topic. The AI should know if it uses a move it will knockout the opponent. Right now it only know how much damage it will deal. If a 60BP, 100acc move can KO a pokemon, there is no reason for it use Hi Jump Kick for example.

    -Rewrite the algorith that gives scores to damaging moves. My last post was about that, there is no sense in tackle always having a 100 score even if it deals 1 damage to a rock pokemon. The formula right now only adds to the score, it should detracts from it when the move is so bad of a choice. Also, the score bonus is based on the actual damage. This makes lower leveled pokemon dumber than higher leveled. It should be based on the percentage of HP it will damage.

    -Reduce the amount of dice rolls, please. Or at least make them inversely proportional to the trainer's skill level. Sometimes it just makes all the work redundant like in my damage example (partially due to the topic above as well).


    I think these would be a good starting point, I'd love if the AI had personality, but first we need to get the basics right. We could definetly make the AI know exactly what is the strategy of it's team (staller, baton pass... etc), but I think this should come later on.
     
    Don't worry about it, I'm good, I don't approve of such things, is all.

    That's what my post is about... Making moves have different scores depending on different things... For example.

    canOHKO
    attackSuperEffectiveOrNot
    canDefrost
    canDefeat
    shouldSwitchPoke
    shouldRecover
    canProtect
    shouldRaiseStat
    shouldLowerStat.

    These would do such things... And the point Maruno made was, "where to start?".

    And I think the order (excuse me if I'm wrong), shouldn't be item>>>switch>>>attack... At a second think, maybe Maruno is right, we should possibly merge them together, so it can create a wider range of effects... I looked at the scripts and noticed they bounce around a lot and the item one doesn't check specifics and again, as Maruno said, AI will predictably use items... But what if the AI could defeat your poke.

    Maybe start with a way to choose whether a trainer is a healer, booster, speedster, power house among other things, that way, we could then begin to work through defs to make sure moves are chosen correctly and at the right times.
     
    Maybe start with a way to choose whether a trainer is a healer, booster, speedster, power house among other things, that way, we could then begin to work through defs to make sure moves are chosen correctly and at the right times.
    Wouldn't those roles be better determined by their pokemon/movesets? Not to start there obviously, but long term. I'd imagine that might be more intricate.
     
    Erh guys, I've started really going deep into improving the AI by myself and I find 2 bugs that renders the damage calc completely useless, here they are:

    1- Not as problematic, but this one still ruins the calculations. The damage dealt is being calculated using the attacker pokemon defense/sp.def stats, and not it's opponents as it should, this obviously mess things up.

    Code:
        # Get base defense stat
        defense=pbRoughStat(attacker,PBStats::DEFENSE,skill)
        applysandstorm=false
        if type>=0 && move.pbIsSpecial?(type)
          if move.function!=0x122 # Psyshock
            defense=pbRoughStat(attacker,PBStats::SPDEF,skill)
            applysandstorm=true
          end
        end


    2- This one ruins everything, and it took me some time to figure out what was causing it. By using the debug console I realized that EVERY basedamage in the damage calculation bit was returning either 0 or 1 while it shouldn't obviously. The problem is here:

    Code:
            # Account for accuracy of move
            echo(basedamage.to_s+",")
            accuracy=pbRoughAccuracy(move,attacker,opponent,skill)
            basedamage*=accuracy/100
            echo(basedamage.to_s+",")

    The accuracy value already comes divided by 100, it's a value between 0 and 1. With that in mind you're taking any damage and dividing it by 100, returning a really low number that doesn't even influence in the final score.

    So, everyone, fixing these 2 bugs you will see a slightly improvement in the AI. It won't use any damaging move regardless if it's resisted or super effective!
     
    Back
    Top