Use percentages for AI scoring logic

Define MAX_DAY_CARE_EXP
This commit is contained in:
Remy Oukaour 2017-12-25 16:18:05 -05:00
parent 2e200ce85e
commit 85aa236c34
3 changed files with 46 additions and 44 deletions

View File

@ -141,7 +141,7 @@ AI_Setup: ; 385e0
.discourage .discourage
call Random call Random
cp 30 cp 12 percent
jr c, .checkmove jr c, .checkmove
inc [hl] inc [hl]
inc [hl] inc [hl]
@ -453,7 +453,7 @@ AI_Smart_LeechHit: ; 387f7
.asm_38815 .asm_38815
call Random call Random
cp 100 cp 39 percent + 1
ret c ret c
inc [hl] inc [hl]
@ -594,7 +594,7 @@ AI_Smart_Selfdestruct: ; 388a6
; If enemy's HP is between 25% and 50%, ; If enemy's HP is between 25% and 50%,
; over 90% chance to greatly discourage this move. ; over 90% chance to greatly discourage this move.
call Random call Random
cp 20 cp 9 percent - 2
ret c ret c
.asm_388c6 .asm_388c6
@ -610,7 +610,7 @@ AI_Smart_DreamEater: ; 388ca
; The AI_Basic layer will make sure that ; The AI_Basic layer will make sure that
; Dream Eater is only used against sleeping targets. ; Dream Eater is only used against sleeping targets.
call Random call Random
cp 25 cp 10 percent
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -637,7 +637,7 @@ AI_Smart_EvasionUp: ; 388d4
; ...70% chance to greatly encourage this move if player is not badly poisoned. ; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random call Random
cp $b2 cp 70 percent
jr nc, .asm_38911 jr nc, .asm_38911
.asm_388ef .asm_388ef
@ -653,7 +653,7 @@ AI_Smart_EvasionUp: ; 388d4
; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move. ; If enemy's HP is above 25% but not full, 4% chance to greatly encourage this move.
call Random call Random
cp $a cp 4 percent
jr c, .asm_388ef jr c, .asm_388ef
; If enemy's HP is between 25% and 50%,... ; If enemy's HP is between 25% and 50%,...
@ -710,11 +710,11 @@ AI_Smart_EvasionUp: ; 388d4
ret ret
; Player is badly poisoned. ; Player is badly poisoned.
; 80% chance to greatly encourage this move. ; 70% chance to greatly encourage this move.
; This would counter any previous discouragement. ; This would counter any previous discouragement.
.asm_38938 .asm_38938
call Random call Random
cp $50 cp 31 percent + 1
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -791,7 +791,7 @@ AI_Smart_MirrorMove: ; 3895b
ret nc ret nc
call Random call Random
cp $19 cp 10 percent
ret c ret c
dec [hl] dec [hl]
@ -816,7 +816,7 @@ AI_Smart_AccuracyDown: ; 38985
; ...70% chance to greatly encourage this move if player is not badly poisoned. ; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random call Random
cp $b2 cp 70 percent
jr nc, .asm_389bf jr nc, .asm_389bf
.asm_3899d .asm_3899d
@ -832,7 +832,7 @@ AI_Smart_AccuracyDown: ; 38985
; If player's HP is above 25% but not full, 4% chance to greatly encourage this move. ; If player's HP is above 25% but not full, 4% chance to greatly encourage this move.
call Random call Random
cp $a cp 4 percent
jr c, .asm_3899d jr c, .asm_3899d
; If player's HP is between 25% and 50%,... ; If player's HP is between 25% and 50%,...
@ -884,11 +884,11 @@ AI_Smart_AccuracyDown: ; 38985
ret ret
; Player is badly poisoned. ; Player is badly poisoned.
; 80% chance to greatly encourage this move. ; 70% chance to greatly encourage this move.
; This would counter any previous discouragement. ; This would counter any previous discouragement.
.asm_389e6 .asm_389e6
call Random call Random
cp $50 cp 31 percent + 1
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -934,7 +934,7 @@ AI_Smart_ResetStats: ; 389f5
.asm_38a12 .asm_38a12
pop hl pop hl
call Random call Random
cp $28 cp 16 percent
ret c ret c
dec [hl] dec [hl]
ret ret
@ -955,7 +955,7 @@ AI_Smart_Bide: ; 38a1e
call AICheckEnemyMaxHP call AICheckEnemyMaxHP
ret c ret c
call Random call Random
cp $19 cp 10 percent
ret c ret c
inc [hl] inc [hl]
ret ret
@ -997,7 +997,7 @@ AI_Smart_Moonlight: ; 38a3a
.asm_38a45 .asm_38a45
call Random call Random
cp $19 cp 10 percent
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -1023,7 +1023,7 @@ AI_Smart_Reflect: ; 38a54
call AICheckEnemyMaxHP call AICheckEnemyMaxHP
ret c ret c
call Random call Random
cp $14 cp 8 percent
ret c ret c
inc [hl] inc [hl]
ret ret
@ -1126,7 +1126,7 @@ AI_Smart_Unused2B: ; 38a9c
.asm_38acd .asm_38acd
call Random call Random
cp $c8 cp 79 percent - 1
ret c ret c
.asm_38ad3 .asm_38ad3
@ -1148,7 +1148,7 @@ AI_Smart_Confuse: ; 38adb
call AICheckPlayerHalfHP call AICheckPlayerHalfHP
ret c ret c
call Random call Random
cp $19 cp 10 percent
jr c, .asm_38ae7 jr c, .asm_38ae7
inc [hl] inc [hl]
@ -1272,7 +1272,7 @@ AI_Smart_SpeedDownHit: ; 38b40
call AICompareSpeed call AICompareSpeed
ret c ret c
call Random call Random
cp 30 cp 12 percent
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -1304,7 +1304,7 @@ AI_Smart_HyperBeam: ; 38b63
.asm_38b72 .asm_38b72
; If enemy's HP is above 50%, discourage this move at random ; If enemy's HP is above 50%, discourage this move at random
call Random call Random
cp 40 cp 16 percent
ret c ret c
inc [hl] inc [hl]
call AI_50_50 call AI_50_50
@ -1457,7 +1457,7 @@ AI_Smart_Counter: ; 38bf1
.asm_38c30 .asm_38c30
call Random call Random
cp $64 cp 39 percent + 1
jr c, .asm_38c38 jr c, .asm_38c38
dec [hl] dec [hl]
@ -1510,7 +1510,7 @@ AI_Smart_Encore: ; 38c3b
.asm_38c78 .asm_38c78
call Random call Random
cp $46 cp 28 percent - 1
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -1657,7 +1657,7 @@ AI_Smart_Spite: ; 38cd5
jr nc, .asm_38d0b jr nc, .asm_38d0b
call Random call Random
cp $64 cp 39 percent + 1
ret nc ret nc
.asm_38d0b .asm_38d0b
@ -1666,7 +1666,7 @@ AI_Smart_Spite: ; 38cd5
.asm_38d0d .asm_38d0d
call Random call Random
cp $64 cp 39 percent + 1
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -1827,7 +1827,7 @@ AI_Smart_Conversion2: ; 38d98
.asm_38dc9 .asm_38dc9
call Random call Random
cp 25 cp 10 percent
ret c ret c
inc [hl] inc [hl]
ret ret
@ -1848,7 +1848,7 @@ AI_Smart_Disable: ; 38dd1
jr nc, .asm_38dee jr nc, .asm_38dee
call Random call Random
cp 100 cp 39 percent + 1
ret c ret c
dec [hl] dec [hl]
ret ret
@ -1860,7 +1860,7 @@ AI_Smart_Disable: ; 38dd1
.asm_38df3 .asm_38df3
call Random call Random
cp 20 cp 8 percent
ret c ret c
inc [hl] inc [hl]
ret ret
@ -2096,7 +2096,7 @@ AI_Smart_Protect: ; 38ed2
.asm_38f14 .asm_38f14
call Random call Random
cp 20 cp 8 percent
ret c ret c
inc [hl] inc [hl]
inc [hl] inc [hl]
@ -2120,14 +2120,14 @@ AI_Smart_Foresight: ; 38f1d
jr z, .asm_38f41 jr z, .asm_38f41
call Random call Random
cp 20 cp 8 percent
ret c ret c
inc [hl] inc [hl]
ret ret
.asm_38f41 .asm_38f41
call Random call Random
cp 100 cp 39 percent + 1
ret c ret c
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -2317,7 +2317,7 @@ AI_Smart_Rollout: ; 38fef
; Otherwise, 80% chance to greatly encourage this move. ; Otherwise, 80% chance to greatly encourage this move.
call Random call Random
cp 200 cp 79 percent - 1
ret nc ret nc
dec [hl] dec [hl]
dec [hl] dec [hl]
@ -2347,7 +2347,7 @@ AI_Smart_Attract: ; 39026
.first_turn .first_turn
call Random call Random
cp 200 cp 79 percent - 1
ret nc ret nc
dec [hl] dec [hl]
ret ret
@ -2850,7 +2850,7 @@ AI_Smart_Solarbeam: ; 3920b
ret nz ret nz
call Random call Random
cp 25 ; 1/10 cp 10 percent
ret c ret c
inc [hl] inc [hl]
@ -2875,7 +2875,7 @@ AI_Smart_Thunder: ; 39225
ret nz ret nz
call Random call Random
cp 25 ; 1/10 cp 10 percent
ret c ret c
inc [hl] inc [hl]
@ -3387,7 +3387,7 @@ AI_Cautious: ; 39418
jr nc, .asm_39425 jr nc, .asm_39425
call Random call Random
cp 230 cp 90 percent + 1
ret nc ret nc
inc [hl] inc [hl]
@ -3513,7 +3513,7 @@ AI_Risky: ; 394a9
; Else, 80% chance to exclude them. ; Else, 80% chance to exclude them.
call Random call Random
cp 200 ; 1/5 cp 79 percent - 1
jr c, .nextmove jr c, .nextmove
.checkko .checkko
@ -3586,13 +3586,13 @@ AIGetEnemyMove: ; 39508
AI_80_20: ; 39521 AI_80_20: ; 39521
call Random call Random
cp 50 ; 1/5 cp 20 percent - 1
ret ret
; 39527 ; 39527
AI_50_50: ; 39527 AI_50_50: ; 39527
call Random call Random
cp $80 ; 1/2 cp 50 percent + 1
ret ret
; 3952d ; 3952d

View File

@ -120,3 +120,5 @@ const_value = 1
const HAPPINESS_REVIVALHERB ; 11 const HAPPINESS_REVIVALHERB ; 11
const HAPPINESS_MASSAGE ; 12 const HAPPINESS_MASSAGE ; 12
const HAPPINESS_GAINLEVELATHOME ; 13 const HAPPINESS_GAINLEVELATHOME ; 13
MAX_DAY_CARE_EXP EQU $500000

View File

@ -159,9 +159,9 @@ DayCareStep:: ; 7282
dec hl dec hl
inc [hl] inc [hl]
ld a, [hl] ld a, [hl]
cp HIGH($500000 >> 8) cp HIGH(MAX_DAY_CARE_EXP >> 8)
jr c, .day_care_lady jr c, .day_care_lady
ld a, HIGH($500000 >> 8) ld a, HIGH(MAX_DAY_CARE_EXP >> 8)
ld [hl], a ld [hl], a
.day_care_lady .day_care_lady
@ -181,9 +181,9 @@ DayCareStep:: ; 7282
dec hl dec hl
inc [hl] inc [hl]
ld a, [hl] ld a, [hl]
cp HIGH($500000 >> 8) cp HIGH(MAX_DAY_CARE_EXP >> 8)
jr c, .check_egg jr c, .check_egg
ld a, HIGH($500000 >> 8) ld a, HIGH(MAX_DAY_CARE_EXP >> 8)
ld [hl], a ld [hl], a
.check_egg .check_egg
@ -199,7 +199,7 @@ DayCareStep:: ; 7282
callfar CheckBreedmonCompatibility callfar CheckBreedmonCompatibility
ld a, [wd265] ld a, [wd265]
cp 230 cp 230
ld b, -1 + 32 percent ld b, 32 percent - 1
jr nc, .okay jr nc, .okay
ld a, [wd265] ld a, [wd265]
cp 170 cp 170