The PokéCommunity Forums Fan Games ROM Hacks Studio PokéCommunity ROM Hack Planning
Engine Designing the Battle AI

Planning Where all the hard work happens. Got an idea? You don't have to be part of the team to share it with us.

Reply
 
Thread Tools
  #1    
Old October 25th, 2016 (11:31 AM).
FBI's Avatar
FBI FBI is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,867
Just to preface, in the battle engine upgrades being working on, tag battles are now in FireRed. It works fine right now, except that the AI is kind of crappy, and the design makes the AIs play like free for all in these modes. So after some discussion, Touched and I thought it'd be a good idea to make our own AI, and while at it improve the existing one and that is what this thread is about.

Things to know about what the AI is capable of:
- It's a cheater, knows the player's Pokemon, available moves and ability
- The AI picks it's move before the player, so it does not read what the player decided to do this turn
- The AI shouldn't log the past. Too complicated to consider what happened X moves ago to
- There should be clear differences between the AI based on the trainer it's facing difficulty wise

Without going into too much detail, the current framework I've got setup will allow us to plug-in different AI logic trees for different trainers. Specifically, the AI for a gym leader with a particular party will play differently than the AI for a route trainer. Weather teams will play to their weather, ect. The problem lies with the default AI's design. Here is a rough idea of the logic we have right now:

Code:
Battle start:
	Pick my most favorable lead
		-> Considers status inducing with toxic ect to wear down tanks
	
Battle (AI asks itself):
	Based on the opponent's available moves, am I favored this matchup?
		No: swap logic flagset
	Do I have time to status?
		sleep status only if opponent will take 2 hits to KO. 
		Other status if opponent takes more than 2 hits to KO.
	Can I setup?
		No: makes this decision if it loses too much health to beat opponent
		Yes: setup, don't evaluate lower questions
	Can I KO the opponent before it KOs me?
		Yes: KO it, don't evaluate lower questions
		No: swap logic flagset
	Should I go for stat reduction?
		If opponent beats me, next two turns and status is effective against it
	Should I setup field hazards?
		If I am favored after taking 1 attack, yes
	What is my best move?
		If I have no offensive move options, swap logic flagset
		if swap logic flag is not set: 
			execute my best move against best opponent target
		
Swap logic:
	Will I die switching back in?
		-> check last ticks of damage status, entry hazards, my speed compared to remaining opponent's speeds
		Yes: don't switch, execute stat reduction, offense move, or entry hazard setup
	Pick my most favorable lead
Any ideas to improve it would be nice. It's kind of complicated, because it needs to be tailored for generic parties against the player. The idea to tone difficulty levels in the world is to cut certain decisions from the table. Starting with swap logic, setup and hazards.
__________________
...
Reply With Quote
  #2    
Old October 26th, 2016 (1:38 AM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
     
    Join Date: Feb 2014
    Location: Poland
    Age: 21
    Gender: Male
    Nature: Quiet
    Posts: 750
    Are you gonna get rid of the old scripting AI system?
    __________________
    Support Pokeruby!

    My works:
    Battle Engine Upgrade
    Pokemon Expansion
    Items/TMs/Tutors Expansion
    Various Features(Evo Methods, BW Repel, Levels Above 100, Trainers with EV, Nature Colored Stats)

    Emerald Features:
    Form Changes (KDS)
    Reply With Quote
      #3    
    Old October 26th, 2016 (2:53 AM).
    C me's Avatar
    C me C me is offline
    Creator of Pokemon League Of Legends
       
      Join Date: Jan 2014
      Age: 21
      Gender: Male
      Posts: 683
      Moves used by the AI should also check for the player and the AI's abilities and items. Don't want to Thunder Wave someone with Motor Drive or Earthquake someone with an Air Balloon for example.
      Reply With Quote
        #4    
      Old October 26th, 2016 (6:53 PM).
      Uncommon's Avatar
      Uncommon Uncommon is online now
      Oozma Kappa
         
        Join Date: Jun 2015
        Location: Johto
        Nature: Careful
        Posts: 184
        Quote:
        Originally Posted by FBI View Post
        stuff
        This framework looks like it will promote a much more competitive-style, switch-heavy form of battling. As much as it would make opposing trainers better and (arguably) make battles more exciting, this style of battling is not really conducive to the cartridge games where you have to trek through the overworld and battle many times without healing in between. It's designed for "winner-take-all" battles where the only thing that matters is whether you win or lose, not what shape your Pokemon are in afterward.

        Don't get me wrong, I'm in favor of this in general and certainly for "boss battles" like Gym Leaders, just want to make sure it doesn't get out of control with every Trainer turning the game into a grind-fest.

        EDIT: just noticed that you said swap logic will be the first to go in difficulty tuning. Highly agree. Just pointing out that swap logic on versus swap logic off will have a massive effect on battle style.
        __________________
        My work: HM type-check system hack (FireRed) | Turbo Test patch (FireRed)

        Reply With Quote
          #5    
        Old October 28th, 2016 (8:41 AM).
        FBI's Avatar
        FBI FBI is offline
        Free supporter
         
        Join Date: Jan 2013
        Location: Unknown Island
        Gender: Male
        Posts: 1,867
        Quote:
        Originally Posted by DizzyEgg View Post
        Are you gonna get rid of the old scripting AI system?
        Yes. For now the AI is only broken for partners, because the partner doesn't pick a move intellegently and instead just uses random(). The AI in the game is hard coded to be from the opponent side in FR, so we were having some issues with it, and the way touched implemented his multi battles had allowed us to "plug in" an AI. We're taking the opportunity to improve the old AI while we're at it with an expectiminimax tree design.

        Quote:
        Originally Posted by C me View Post
        Moves used by the AI should also check for the player and the AI's abilities and items. Don't want to Thunder Wave someone with Motor Drive or Earthquake someone with an Air Balloon for example.
        Yeah, evaluating abilities is a good idea. I'll add those in as clauses to check once we get the dex completed and know what kind of abilities we're dealing with.

        Quote:
        Originally Posted by Uncommon View Post
        This framework looks like it will promote a much more competitive-style, switch-heavy form of battling. As much as it would make opposing trainers better and (arguably) make battles more exciting, this style of battling is not really conducive to the cartridge games where you have to trek through the overworld and battle many times without healing in between. It's designed for "winner-take-all" battles where the only thing that matters is whether you win or lose, not what shape your Pokemon are in afterward.

        Don't get me wrong, I'm in favor of this in general and certainly for "boss battles" like Gym Leaders, just want to make sure it doesn't get out of control with every Trainer turning the game into a grind-fest.

        EDIT: just noticed that you said swap logic will be the first to go in difficulty tuning. Highly agree. Just pointing out that swap logic on versus swap logic off will have a massive effect on battle style.
        Yeah, the goal of the AI is the introduce some challenge, maintain human-like unpredictability while still keeping up strategization. It's easier to make a smart AI and lower it's margin of consideration than make an easy AI and scale it up imo.

        Anyways, the design on the first post is no longer relevant because of a design shift we've made. More updates on that much later, it's not exactly a priority feature yet because the current AI is working fine for everything except partners.
        __________________
        ...
        Reply With Quote
        Reply

        Quick Reply

        Join the conversation!

        Create an account to post a reply in this thread, participate in other discussions, and more!

        Create a PokéCommunity Account
        Thread Tools

        Posting Rules
        You may not post new threads
        You may not post replies
        You may not post attachments
        You may not edit your posts

        BB code is On
        Smilies are On
        [IMG] code is On
        HTML code is Off

        Forum Jump


        All times are GMT -8. The time now is 7:03 PM.