Tuesday, 11 September 2007

ripples in space-time

While looking through the breakdown of nano warriors by strategy I
noticed the absence of a decent 4 line paper, despite the success of
5-liners like Fluffy's Black Sun III. I quickly hacked something up
and added a quick-bomb to the beginning.


I tested with some hand-picked constants against Metcalf's nano
benchmark. It scored 139.2, or 129.8 with the quick-bomb removed.



;redcode-nano
;name hand coded paper
;author S.Fernandes
;strategy paper
;assert CORESIZE == 80

pstep equ 15
ipos equ 40
cpos equ -5
dpos equ 35

mov >60 , 10
paper spl #0 , <pstep
mov }paper , >paper
mov >ipos , <cpos
djn.f *pstep-2 , <dpos
end

Optimization


In the first round of optimization 400 warriors are generated with
all constants randomized. A small script is run over the source
below replacing each exclamation mark with a random number. The
quick-bomb will be disabled until the final stage.



org paper

pstep equ (4+!%73) ; range 4-76
ipos equ (2+!%70) ; range 2-71
cpos equ (8+!%70) ; range 8-77
dpos equ (7+!%70) ; range 7-76

mov >27 , 54
paper spl #0 , <pstep
mov }paper , >paper
mov >ipos , <cpos
djn.f *pstep-2 , <dpos
end

I've use modulo to restrict the range of random values to prevent
self-bombing. This reduces the search space by approximately 40%.
While this may stop some interesting self-mutation or interaction
being found, it's really the author's job not the optimizer's to
discover these.


The peak score is 139.5. Now we take a closer look at the top 10
results to compare the paper step. -17 occurs four times, -18 twice
and -15, -22, -25 and 33 once.


For stage 2 we generate 100 warriors for each of the above paper
steps with all other constants randomized. The peak score is 145.8
with pstep -22 followed by 145.0 with pstep -17.


The top two warriors from stage 2 are taken and their cpos
optimized in stage 3. All 70 values are tested for each warrior.
The peak score for the warrior with pstep -22 remains at
145.8. The score for the warrior with pstep -17 improves
to 145.7.


In stage 4 we take the top warrior for each pstep from
stage 3 and optimize dpos. The scores increase to 146.2
(pstep -22) and 145.8 (pstep -17).


In stage 5 we optimize ipos. The scores go up to 146.8
(pstep -22) and 149.2 (pstep -17).


Finally the quick-bomb is enabled and its two constants optimized.
400 random pair of quick-bomb constants are generated. The final
benchmark scores are 158.3 (pstep -22) and 159.2
(pstep -17).


Submission to SAL's Nano Hill


Although the benchmark scores are impressive, the hill contains 50
completely different warriors. If the benchmark reflects the hill
well, the scores should be within 10%.


The paper with pstep -22 scores 146.2 and takes 6th
place. With pstep -17 however the score is 152.3 and 4th
place.



;redcode-nano
;name ripples in space-time
;author S.Fernandes
;strategy paper
;assert CORESIZE == 80

pstep equ -17
ipos equ 10
cpos equ -33
dpos equ 36

mov >-39 , 25
paper spl #0 , <pstep
mov }paper , >paper
mov >ipos , <cpos
djn.f *pstep-2 , <dpos
end


;redcode-nano
;name ripples 22
;author S.Fernandes
;strategy paper
;assert CORESIZE == 80

pstep equ -22
ipos equ -34
cpos equ 17
dpos equ -29

mov >-38 , 25
paper spl #0 , <pstep
mov }paper , >paper
mov >ipos , <cpos
djn.f *pstep-2 , <dpos
end

No comments: