From 7d9ea8a30d19fae6a39bb36981e27db6edbea5e7 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Tue, 28 Apr 2020 20:20:20 +0100 Subject: AI routines and Energy Trans logic --- src/constants/duel_constants.asm | 41 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'src/constants') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 65f58e3..b667c50 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -232,21 +232,32 @@ AI_FLAG_USED_PROFESSOR_OAK EQU 1 << 2 AI_FLAG_MODIFIED_HAND EQU 1 << 3 AI_FLAG_USED_GUST_OF_WIND EQU 1 << 4 +; used as input for AIProcessEnergyCards to determine what to check +; and whether to play card after the routine is over. +; I suspect AI_ENERGY_FLAG_DONT_PLAY to be a flag to signal the routine +; not to actually play the energy card after it's finished, +; but AIProcessEnergyCards checks whether ANY flag is set in order +; to decide not to play it, so it's redundant in the presence of another flag. +AI_ENERGY_FLAG_DONT_PLAY EQU 1 << 0 ; whether to play energy card (?) +AI_ENERGY_FLAG_SKIP_EVOLUTION EQU 1 << 1 ; whether to check if card has evolutions +AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in determining which card to attach energy + ; used to determine which Trainer cards for AI ; to process in AIProcessHandTrainerCards. ; aside from a few exceptions, these go in chronological order. -AI_TRAINER_CARD_PHASE_01 EQU $1 -AI_TRAINER_CARD_PHASE_02 EQU $2 -AI_TRAINER_CARD_PHASE_03 EQU $3 -AI_TRAINER_CARD_PHASE_04 EQU $4 -AI_TRAINER_CARD_PHASE_05 EQU $5 -AI_TRAINER_CARD_PHASE_06 EQU $6 -AI_TRAINER_CARD_PHASE_07 EQU $7 -AI_TRAINER_CARD_PHASE_08 EQU $8 -AI_TRAINER_CARD_PHASE_09 EQU $9 -AI_TRAINER_CARD_PHASE_10 EQU $a -AI_TRAINER_CARD_PHASE_11 EQU $b -AI_TRAINER_CARD_PHASE_12 EQU $c -AI_TRAINER_CARD_PHASE_13 EQU $d -AI_TRAINER_CARD_PHASE_14 EQU $e -AI_TRAINER_CARD_PHASE_15 EQU $f + const_def 1 + const AI_TRAINER_CARD_PHASE_01 ; $1 + const AI_TRAINER_CARD_PHASE_02 ; $2 + const AI_TRAINER_CARD_PHASE_03 ; $3 + const AI_TRAINER_CARD_PHASE_04 ; $4 + const AI_TRAINER_CARD_PHASE_05 ; $5 + const AI_TRAINER_CARD_PHASE_06 ; $6 + const AI_TRAINER_CARD_PHASE_07 ; $7 + const AI_TRAINER_CARD_PHASE_08 ; $8 + const AI_TRAINER_CARD_PHASE_09 ; $9 + const AI_TRAINER_CARD_PHASE_10 ; $a + const AI_TRAINER_CARD_PHASE_11 ; $b + const AI_TRAINER_CARD_PHASE_12 ; $c + const AI_TRAINER_CARD_PHASE_13 ; $d + const AI_TRAINER_CARD_PHASE_14 ; $e + const AI_TRAINER_CARD_PHASE_15 ; $f -- cgit v1.2.3 From cf9a3c313b63c78ebcb4077e827eeff9a5940ba0 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 30 Apr 2020 16:04:07 +0100 Subject: Unpack Legendary Moltres AI --- src/constants/duel_constants.asm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/constants') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index b667c50..9cdc73b 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -3,6 +3,8 @@ MAX_PLAY_AREA_POKEMON EQU 6 ; arena + bench MAX_HP EQU 120 HP_BAR_LENGTH EQU MAX_HP / 10 +STARTING_HAND_SIZE EQU 7 + ; hWhoseTurn constants PLAYER_TURN EQUS "HIGH(wPlayerDuelVariables)" OPPONENT_TURN EQUS "HIGH(wOpponentDuelVariables)" -- cgit v1.2.3 From 17b8a2fdc29ff221b18533f06966b02ad0883fb2 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 1 May 2020 17:28:57 +0100 Subject: Document AI Anti Mill strategy --- src/constants/duel_constants.asm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/constants') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 9cdc73b..47ca1ad 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -263,3 +263,8 @@ AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in det const AI_TRAINER_CARD_PHASE_13 ; $d const AI_TRAINER_CARD_PHASE_14 ; $e const AI_TRAINER_CARD_PHASE_15 ; $f + +; used by wAIBarrierFlagCounter to determine +; whether Player is running Mewtwo1 mill deck. +; flag set means true, flag not set means false. +AI_FLAG_MEWTWO_MILL EQU 1 << 7 -- cgit v1.2.3 From c4183f69cd8cb0fe1482cac8487efaf68160a411 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 7 May 2020 15:42:13 +0100 Subject: Deck AI macros and tidying --- src/constants/duel_constants.asm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/constants') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 47ca1ad..dd692d0 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -246,7 +246,11 @@ AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in det ; used to determine which Trainer cards for AI ; to process in AIProcessHandTrainerCards. -; aside from a few exceptions, these go in chronological order. +; these go in chronological order, except for +; AI_TRAINER_CARD_PHASE_14 which happens just before AI attacks. +; AI_TRAINER_CARD_PHASE_15 is reserved for Professor Oak card. +; if Professor Oak is played, all other Trainer card phases +; are processed again except AI_TRAINER_CARD_PHASE_15. const_def 1 const AI_TRAINER_CARD_PHASE_01 ; $1 const AI_TRAINER_CARD_PHASE_02 ; $2 @@ -261,10 +265,17 @@ AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in det const AI_TRAINER_CARD_PHASE_11 ; $b const AI_TRAINER_CARD_PHASE_12 ; $c const AI_TRAINER_CARD_PHASE_13 ; $d - const AI_TRAINER_CARD_PHASE_14 ; $e - const AI_TRAINER_CARD_PHASE_15 ; $f + const AI_TRAINER_CARD_PHASE_14 ; $e, just before attack + const AI_TRAINER_CARD_PHASE_15 ; $f, for Professor Oak ; used by wAIBarrierFlagCounter to determine ; whether Player is running Mewtwo1 mill deck. ; flag set means true, flag not set means false. AI_FLAG_MEWTWO_MILL EQU 1 << 7 + +; defines the behaviour of HandleAIEnergyTrans, for determining +; whether to move energy cards from the Bench to the Arena or vice-versa +; and the number of energy cards needed for achieving that. +AI_ENERGY_TRANS_RETREAT EQU $9 ; moves energy cards needed for Retreat Cost +AI_ENERGY_TRANS_ATTACK EQU $d ; moves energy cards needed for second attack +AI_ENERGY_TRANS_TO_BENCH EQU $e ; moves energy cards away from Arena card -- cgit v1.2.3 From 86d8cfb0fd86326e4534fc33c7bb384d515bbe0e Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 9 May 2020 12:11:05 +0100 Subject: Separate AI constants and new AIACTION_* --- src/constants/deck_ai_constants.asm | 61 +++++++++++++++++++++++++++++++++++++ src/constants/duel_constants.asm | 53 -------------------------------- 2 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 src/constants/deck_ai_constants.asm (limited to 'src/constants') diff --git a/src/constants/deck_ai_constants.asm b/src/constants/deck_ai_constants.asm new file mode 100644 index 0000000..ceae8ed --- /dev/null +++ b/src/constants/deck_ai_constants.asm @@ -0,0 +1,61 @@ +; wPreviousAIFlags and wCurrentAIFlags constants +AI_FLAG_USED_PLUSPOWER EQU 1 << 0 +AI_FLAG_USED_SWITCH EQU 1 << 1 +AI_FLAG_USED_PROFESSOR_OAK EQU 1 << 2 +AI_FLAG_MODIFIED_HAND EQU 1 << 3 +AI_FLAG_USED_GUST_OF_WIND EQU 1 << 4 + +; used as input for AIProcessEnergyCards to determine what to check +; and whether to play card after the routine is over. +; I suspect AI_ENERGY_FLAG_DONT_PLAY to be a flag to signal the routine +; not to actually play the energy card after it's finished, +; but AIProcessEnergyCards checks whether ANY flag is set in order +; to decide not to play it, so it's redundant in the presence of another flag. +AI_ENERGY_FLAG_DONT_PLAY EQU 1 << 0 ; whether to play energy card (?) +AI_ENERGY_FLAG_SKIP_EVOLUTION EQU 1 << 1 ; whether to check if card has evolutions +AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in determining which card to attach energy + +; used to determine which Trainer cards for AI +; to process in AIProcessHandTrainerCards. +; these go in chronological order, except for +; AI_TRAINER_CARD_PHASE_14 which happens just before AI attacks. +; AI_TRAINER_CARD_PHASE_15 is reserved for Professor Oak card. +; if Professor Oak is played, all other Trainer card phases +; are processed again except AI_TRAINER_CARD_PHASE_15. + const_def 1 + const AI_TRAINER_CARD_PHASE_01 ; $1 + const AI_TRAINER_CARD_PHASE_02 ; $2 + const AI_TRAINER_CARD_PHASE_03 ; $3 + const AI_TRAINER_CARD_PHASE_04 ; $4 + const AI_TRAINER_CARD_PHASE_05 ; $5 + const AI_TRAINER_CARD_PHASE_06 ; $6 + const AI_TRAINER_CARD_PHASE_07 ; $7 + const AI_TRAINER_CARD_PHASE_08 ; $8 + const AI_TRAINER_CARD_PHASE_09 ; $9 + const AI_TRAINER_CARD_PHASE_10 ; $a + const AI_TRAINER_CARD_PHASE_11 ; $b + const AI_TRAINER_CARD_PHASE_12 ; $c + const AI_TRAINER_CARD_PHASE_13 ; $d + const AI_TRAINER_CARD_PHASE_14 ; $e, just before attack + const AI_TRAINER_CARD_PHASE_15 ; $f, for Professor Oak + +; used by wAIBarrierFlagCounter to determine +; whether Player is running Mewtwo1 mill deck. +; flag set means true, flag not set means false. +AI_FLAG_MEWTWO_MILL EQU 1 << 7 + +; defines the behaviour of HandleAIEnergyTrans, for determining +; whether to move energy cards from the Bench to the Arena or vice-versa +; and the number of energy cards needed for achieving that. +AI_ENERGY_TRANS_RETREAT EQU $9 ; moves energy cards needed for Retreat Cost +AI_ENERGY_TRANS_ATTACK EQU $d ; moves energy cards needed for second attack +AI_ENERGY_TRANS_TO_BENCH EQU $e ; moves energy cards away from Arena card + +; used to know which AI routine to call in +; the AIAction pointer tables in AIDoAction + const_def 1 + const AIACTION_DO_TURN ; $1 + const AIACTION_START_DUEL ; $2 + const AIACTION_FORCED_SWITCH ; $3 + const AIACTION_KO_SWITCH ; $4 + const AIACTION_TAKE_PRIZE ; $5 diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index dd692d0..d461d24 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -226,56 +226,3 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02 ; wAnimationQueue length ANIMATION_QUEUE_LENGTH EQU 7 - -; wPreviousAIFlags and wCurrentAIFlags constants -AI_FLAG_USED_PLUSPOWER EQU 1 << 0 -AI_FLAG_USED_SWITCH EQU 1 << 1 -AI_FLAG_USED_PROFESSOR_OAK EQU 1 << 2 -AI_FLAG_MODIFIED_HAND EQU 1 << 3 -AI_FLAG_USED_GUST_OF_WIND EQU 1 << 4 - -; used as input for AIProcessEnergyCards to determine what to check -; and whether to play card after the routine is over. -; I suspect AI_ENERGY_FLAG_DONT_PLAY to be a flag to signal the routine -; not to actually play the energy card after it's finished, -; but AIProcessEnergyCards checks whether ANY flag is set in order -; to decide not to play it, so it's redundant in the presence of another flag. -AI_ENERGY_FLAG_DONT_PLAY EQU 1 << 0 ; whether to play energy card (?) -AI_ENERGY_FLAG_SKIP_EVOLUTION EQU 1 << 1 ; whether to check if card has evolutions -AI_ENERGY_FLAG_SKIP_ARENA_CARD EQU 1 << 7 ; whether to include Arena card in determining which card to attach energy - -; used to determine which Trainer cards for AI -; to process in AIProcessHandTrainerCards. -; these go in chronological order, except for -; AI_TRAINER_CARD_PHASE_14 which happens just before AI attacks. -; AI_TRAINER_CARD_PHASE_15 is reserved for Professor Oak card. -; if Professor Oak is played, all other Trainer card phases -; are processed again except AI_TRAINER_CARD_PHASE_15. - const_def 1 - const AI_TRAINER_CARD_PHASE_01 ; $1 - const AI_TRAINER_CARD_PHASE_02 ; $2 - const AI_TRAINER_CARD_PHASE_03 ; $3 - const AI_TRAINER_CARD_PHASE_04 ; $4 - const AI_TRAINER_CARD_PHASE_05 ; $5 - const AI_TRAINER_CARD_PHASE_06 ; $6 - const AI_TRAINER_CARD_PHASE_07 ; $7 - const AI_TRAINER_CARD_PHASE_08 ; $8 - const AI_TRAINER_CARD_PHASE_09 ; $9 - const AI_TRAINER_CARD_PHASE_10 ; $a - const AI_TRAINER_CARD_PHASE_11 ; $b - const AI_TRAINER_CARD_PHASE_12 ; $c - const AI_TRAINER_CARD_PHASE_13 ; $d - const AI_TRAINER_CARD_PHASE_14 ; $e, just before attack - const AI_TRAINER_CARD_PHASE_15 ; $f, for Professor Oak - -; used by wAIBarrierFlagCounter to determine -; whether Player is running Mewtwo1 mill deck. -; flag set means true, flag not set means false. -AI_FLAG_MEWTWO_MILL EQU 1 << 7 - -; defines the behaviour of HandleAIEnergyTrans, for determining -; whether to move energy cards from the Bench to the Arena or vice-versa -; and the number of energy cards needed for achieving that. -AI_ENERGY_TRANS_RETREAT EQU $9 ; moves energy cards needed for Retreat Cost -AI_ENERGY_TRANS_ATTACK EQU $d ; moves energy cards needed for second attack -AI_ENERGY_TRANS_TO_BENCH EQU $e ; moves energy cards away from Arena card -- cgit v1.2.3