Warrior: craft_paper
Hill: Beginner Standard 94
Author: physsio
Redcode
;redcode-94b
;name craft_paper
;author physsio
;assert CORESIZE == 8000
;strategy Paper + Bomber
;strategy Picks one strategy based on previous rounds
step equ 4437
ORG start
result dat #0, #0 ;a contains result, b contains pick
score dat #0, #0 ;a contains paper score, b contains bomber score, score = wins - loss
start ldp.a #0, result
ldp.ab #1, result
ldp.a #2, score ;load paper score
ldp.ab #3, score ;load bomber score
sne.a #-1, result ;do init on first round
jmp init
jmp record
init stp.ab #100, #2 ;set initial scores equal to number of rounds to avoid negative numbers
stp.ab #100, #3
jmp ppaper
record sne.a #1, result ;record the result into p space
jmp recordw
sne.a #2, result
jmp max ;was a tie don't record anything just pick next
;jmp recordl
recordl sne.ab #2, result ;record the loss.
jmp bombl
;jmp paperl
paperl sub.a #1, score
stp.ab score, #2 ;store paper score
jmp max
recordw sne.ab #2, result ;record the win
jmp bombw
;jmp paperw
paperw add.a #1, score
stp.ab score, #2 ;store paper score
jmp max
bombw add.ab #1, score
stp.b score, #3 ;store bomber score
jmp max
bombl sub.ab #1, score
stp.b score, #3 ;store bomber score
;jmp max
max slt.ab score, score
jmp ppaper
;jmp pbomber
pbomber mov.ab #2, result
save stp.b result, #1
protect mov.i result, init
mov.i result, init+1
mov.i result, paperl+1
mov.i result, paperw+1
mov.i result, bombl+1
mov.i result, bombw+1
mov.i result, save
same sne.ab #1, result
jmp paper
jmp bomber
ppaper mov.ab #1, result
jmp save
paper mov.ab #fin+1, #0 ;paper contains the length of the program in A
scan add.ab #step, #step ;scan is the ptr to area being scanned
jmz.f scan, @scan
slt paper, scan ;do not overwrite yourself, it may overwrite other copies
jmp scan
add.ab paper, scan ;copy back to front ending where we found data
copy mov.i <paper, <scan
jmn copy, paper
spl @scan ;spawn child
fin jmp paper ;repeat
bomber spl sec, {-43
spl thrd, <-441
spl forth, {-37
first add #16, 3
mov 2, @2
jmp first, <-399
dat #0, #0
sec add #-16, 3
mov 2, @2
jmp sec, <-399
dat #0, #0
thrd add #16, 3
mov 2, @2
jmp thrd, <-399
dat #0, #0
forth add #-16, 3
mov 2, @2
jmp forth, >56
dat #0, #0