mirror of
https://github.com/Pecusx/scorch_src.git
synced 2026-05-21 14:49:40 +02:00
More AI optimization (59b saved :) )
This commit is contained in:
@@ -8,26 +8,6 @@
|
|||||||
; - shoots random direction and force
|
; - shoots random direction and force
|
||||||
; greeeting to myself 10 years older in 2013-11-09... still no idea
|
; greeeting to myself 10 years older in 2013-11-09... still no idea
|
||||||
|
|
||||||
;----------------------------------------------
|
|
||||||
.proc MakeLowResDistances
|
|
||||||
; create low precision table of positions
|
|
||||||
; by dividing positions by 4
|
|
||||||
|
|
||||||
ldy #MaxPlayers-1
|
|
||||||
loop
|
|
||||||
lda xtankstableL,y
|
|
||||||
sta temp
|
|
||||||
lda xtankstableH,y
|
|
||||||
sta temp+1
|
|
||||||
|
|
||||||
;= /4
|
|
||||||
:2 lsrw temp
|
|
||||||
lda temp
|
|
||||||
sta LowResDistances,y
|
|
||||||
dey
|
|
||||||
bpl loop
|
|
||||||
rts
|
|
||||||
.endp
|
|
||||||
|
|
||||||
;----------------------------------------------
|
;----------------------------------------------
|
||||||
.proc ArtificialIntelligence ;
|
.proc ArtificialIntelligence ;
|
||||||
@@ -43,6 +23,25 @@ loop
|
|||||||
lda AIRoutines,y
|
lda AIRoutines,y
|
||||||
pha
|
pha
|
||||||
|
|
||||||
|
;----------------------------------------------
|
||||||
|
;.proc MakeLowResDistances
|
||||||
|
; create low precision table of positions
|
||||||
|
; by dividing positions by 4
|
||||||
|
ldy #MaxPlayers-1
|
||||||
|
loop
|
||||||
|
lda xtankstableL,y
|
||||||
|
sta temp
|
||||||
|
lda xtankstableH,y
|
||||||
|
sta temp+1
|
||||||
|
;= /4
|
||||||
|
:2 lsrw temp
|
||||||
|
lda temp
|
||||||
|
sta LowResDistances,y
|
||||||
|
dey
|
||||||
|
bpl loop
|
||||||
|
; rts
|
||||||
|
;.endp
|
||||||
|
|
||||||
; common values used in AI routines
|
; common values used in AI routines
|
||||||
; address of weapons table (for future use)
|
; address of weapons table (for future use)
|
||||||
lda TanksWeaponsTableL,x
|
lda TanksWeaponsTableL,x
|
||||||
@@ -326,7 +325,7 @@ NotNegativeEnergy
|
|||||||
jsr RandomizeForce
|
jsr RandomizeForce
|
||||||
; if target distance lower than 24 - set weapon to Baby Missile (for security :)
|
; if target distance lower than 24 - set weapon to Baby Missile (for security :)
|
||||||
jsr GetDistance
|
jsr GetDistance
|
||||||
cpw temp2 #24
|
cmp #6 ; 24/4
|
||||||
bcs HighForce
|
bcs HighForce
|
||||||
lda #ind_Baby_Missile___
|
lda #ind_Baby_Missile___
|
||||||
sta ActiveWeapon,x
|
sta ActiveWeapon,x
|
||||||
@@ -358,7 +357,7 @@ NotNegativeEnergy
|
|||||||
jsr RandomizeForce
|
jsr RandomizeForce
|
||||||
; if target distance lower than 24 - set weapon to Baby Missile (for security :)
|
; if target distance lower than 24 - set weapon to Baby Missile (for security :)
|
||||||
jsr GetDistance
|
jsr GetDistance
|
||||||
cpw temp2 #24
|
cmp #6 ; 24/4
|
||||||
bcs HighForce
|
bcs HighForce
|
||||||
lda #ind_Baby_Missile___
|
lda #ind_Baby_Missile___
|
||||||
sta ActiveWeapon,x
|
sta ActiveWeapon,x
|
||||||
@@ -378,7 +377,7 @@ HighForce
|
|||||||
jsr TakeAim ; direction still in A (0 - left, >0 - right)
|
jsr TakeAim ; direction still in A (0 - left, >0 - right)
|
||||||
|
|
||||||
; choose the best weapon
|
; choose the best weapon
|
||||||
ldy ind_Nuke___________+1
|
ldy #ind_Nuke___________+1
|
||||||
jsr ChooseBestOffensive.NotFromAll
|
jsr ChooseBestOffensive.NotFromAll
|
||||||
|
|
||||||
lda Force
|
lda Force
|
||||||
@@ -387,7 +386,7 @@ HighForce
|
|||||||
sta ForceTableH,x
|
sta ForceTableH,x
|
||||||
; if target distance lower than 32 - set weapon to Baby Missile (for security :)
|
; if target distance lower than 32 - set weapon to Baby Missile (for security :)
|
||||||
jsr GetDistance
|
jsr GetDistance
|
||||||
cpw temp2 #32
|
cmp #8 ;32/4
|
||||||
bcs HighForce
|
bcs HighForce
|
||||||
lda #ind_Baby_Missile___
|
lda #ind_Baby_Missile___
|
||||||
sta ActiveWeapon,x
|
sta ActiveWeapon,x
|
||||||
@@ -404,7 +403,7 @@ HighForce
|
|||||||
; direcion of shoot in A (0 - left, >0 - right)
|
; direcion of shoot in A (0 - left, >0 - right)
|
||||||
;----------------------------------------------
|
;----------------------------------------------
|
||||||
sta PreferHumansFlag
|
sta PreferHumansFlag
|
||||||
jsr MakeLowResDistances
|
; jsr MakeLowResDistances
|
||||||
lda #202
|
lda #202
|
||||||
sta temp2 ; max possible energy
|
sta temp2 ; max possible energy
|
||||||
lda #0
|
lda #0
|
||||||
@@ -456,7 +455,7 @@ skipThisPlayer
|
|||||||
; returns target tank number in Y and
|
; returns target tank number in Y and
|
||||||
; direcion of shoot in A (0 - left, >0 - right)
|
; direcion of shoot in A (0 - left, >0 - right)
|
||||||
;----------------------------------------------
|
;----------------------------------------------
|
||||||
jsr MakeLowResDistances
|
; jsr MakeLowResDistances
|
||||||
mva #$ff temp2 ; min possible distance
|
mva #$ff temp2 ; min possible distance
|
||||||
mva #0 tempor2 ; direction of shoot
|
mva #0 tempor2 ; direction of shoot
|
||||||
|
|
||||||
@@ -1033,30 +1032,19 @@ loop
|
|||||||
.endp
|
.endp
|
||||||
;----------------------------------------------
|
;----------------------------------------------
|
||||||
.proc GetDistance
|
.proc GetDistance
|
||||||
; calculates distance from tank X to TargetTankNr(Y)
|
; calculates lores ( /4 ) distance from tank X to TargetTankNr(Y)
|
||||||
; result in temp2
|
; result in A
|
||||||
;----------------------------------------------
|
;----------------------------------------------
|
||||||
ldy TargetTankNr
|
ldy TargetTankNr
|
||||||
lda xTanksTableH,x
|
lda LowResDistances,x
|
||||||
cmp xTanksTableH,y
|
cmp LowResDistances,y
|
||||||
bne @+
|
|
||||||
lda xTanksTableL,x
|
|
||||||
cmp xTanksTableL,y
|
|
||||||
@ bcs YisLower
|
@ bcs YisLower
|
||||||
sec
|
sec
|
||||||
lda xTanksTableL,y
|
lda LowResDistances,y
|
||||||
sbc xTanksTableL,x
|
sbc LowResDistances,x
|
||||||
sta temp2
|
|
||||||
lda xTanksTableH,y
|
|
||||||
sbc xTanksTableH,x
|
|
||||||
sta temp2+1
|
|
||||||
rts
|
rts
|
||||||
YisLower
|
YisLower
|
||||||
lda xTanksTableL,x
|
lda LowResDistances,x
|
||||||
sbc xTanksTableL,y
|
sbc LowResDistances,y
|
||||||
sta temp2
|
|
||||||
lda xTanksTableH,x
|
|
||||||
sbc xTanksTableH,y
|
|
||||||
sta temp2+1
|
|
||||||
rts
|
rts
|
||||||
.endp
|
.endp
|
||||||
BIN
Binary file not shown.
Reference in New Issue
Block a user