Bots and Simulations > DNA - General
Swapping the top two stack values?
abyaly:
Do you think you can reduce the amount of inflation your DNA compiler causes? I forsee a grim future where every bot lags the sim like guardian and one man bucket.
Trafalgar:
--- Quote from: abyaly ---Do you think you can reduce the amount of inflation your DNA compiler causes? I forsee a grim future where every bot lags the sim like guardian and one man bucket.
--- End quote ---
That's what the purpose of implementing branching conditionals was - By using that, I got the DNA length for that bot down from around 15K to around 9K. And it would be even smaller if there was a stack swap operator.
But the main reason Guardian's DNA is so large is that I attached a large number of conditions to a large number of stores. I also let PyBot check almost every store to make sure it wasn't already being set, but that doesn't add a huge amount to code size - it uses dup to avoid recalculating the value. It changes the output code like so:
from: blah blah value calculation here .address conditions mult store
to: blah blah value calculation here dup *.address sub sgn abs conditions & .address mult store
The only things added are one dup, *.address, and sub sgn abs and an &. So that doesn't add a lot.
Yes, there is some potential inflation, though, of course, where a human author would hand optimize something. For example, fairly early in Aura's code, you have it do '*.refypos *.ypos sub *.refveldn add dup mult'. If someone wrote that for PyBot using '((refypos-ypos)+refveldn)*((refypos-ypos)+refveldn)', it would be larger. However, in light of that, I have made it possible to use dup in PyBot. '((refypos-ypos)+refveldn)*dup' would compile exactly to what's in Aura's code there.
(I'm translating Aura's code by hand to be PyBot-compilable to see how it will come out, and to see whether there is anything I can do to reduce the amount of inflation - like adding dup support)
Edit: So far, it looks like it would run faster, but that's mainly because you used sqr in (> and probably <) comparisons, and mult for anding conditions, and PyBot uses floor and & for those purposes instead (it only uses mult to multiply the 1 or 0 result of combining all the conditions by the address).
abyaly:
Please forgive any mistakes you find; some have already been pointed out to me >.>
I also think Aura is far from optimized, since I have a lot of "0 sub" type things in there. Thankfully it didn't grow complex enough to need it.
Also, I dont think I used < at all, since it looks ugly to have both kinds sitting there next to each other.
Navigation
[0] Message Index
[*] Previous page
Go to full version