Skip to content

AI reference (draft)

ElectroDeoxys edited this page Jun 23, 2024 · 1 revision

This page aims to provide the most complete and comprehensive AI reference guide for Pokémon TCG.

Overview

The AI in the game works in the context of the deck that the opponent has. Each deck will have an associated AI, though a lot of the inner working and logic is shared between them. The "non-important" decks all have a common general AI system which make generic decisions, not relying on a specific gameplay style. On the other hand, "important" decks (known in the codebase as "Boss decks") each have their own unique AI routines that reflect their overarching strategy, with intricate logic that effects the opponent's decision and actions throughout a duel.

Action table

In a high-level view, AI actions are split into the following table of actions:

  • Doing a turn, which includes playing a card from the hand, using a Pkmn Power and attacking;
  • Starting a duel and setting up the initial Play Area Pokémon cards;
  • Picking a Bench card resulting from a forced switch;
  • Picking a Bench card resulting from the Arena card being knocked out;
  • Picking Prize cards after knocking out a player Pokémon card.

Each deck AI is expected to implement a subroutine that handles each one of these actions in their respective AIActionTable_* functions. As an example, here's the code that implements this action table for the case of general decks:

AIActionTable_GeneralDecks:
	dw .do_turn ; unused
	dw .do_turn
	dw .start_duel
	dw .forced_switch
	dw .ko_switch
	dw .take_prize

.do_turn
	call AIMainTurnLogic
	ret

.start_duel
	call InitAIDuelVars
	call AIPlayInitialBasicCards
	ret

.forced_switch
	call AIDecideBenchPokemonToSwitchTo
	ret

.ko_switch
	call AIDecideBenchPokemonToSwitchTo
	ret

.take_prize:
	call AIPickPrizeCards
	ret

As can be seen, the subroutines are calls to functions that handle each action. We will look into each of these more in detail in their respective sections.

Do Turn

As is evident, the main turn logic is located in this section, and encompasses the majority of the AI engine and logic. TODO

Start duel

TODO

Forced switch

TODO

KO switch

TODO

Take prize

TODO