Bots and Simulations > Tips and Tricks
Hibernation
Trafalgar:
--- Quote from: abyaly ---Convert all conditional operators as follows:
> -> sub sqr dup div
--- End quote ---
I don't get this. Why wouldn't dup div always return 1 (unless the value was 0), since any number (except 0) divided by itself is 1?
(In other words, it looks to me like it would act like a != instead of a >)
abyaly:
sqr turns a positive number into the square root of that number. it turns a negative number into 0
Jez:
What are the chances of luring you into rewriting the conditionless bots part of the Wiki Abylaly? Apart from being (IMO anyway) the best 1g bot writer out there you also have a really simple and accessible way of explaining how it's done.
Not to mention your skill with viruses and venom...
That post above showing how to convert a standard bot into a 1G bot really deserves to be added to the Wiki at least.
Trafalgar:
--- Quote from: abyaly ---sqr turns a positive number into the square root of that number. it turns a negative number into 0
--- End quote ---
Ohh, silly me. I thought it was *squaring*, not square rooting.
Edit: Avoiding double-posting.
There is already an article about how to do that (entitled "Conditionless Bots"), of course, but it doesn't give good solutions for and/or/xor/not. That said, a few of the solutions in the post above are kind of pointless, too (or perhaps out of date? How old are the "new math operators"?). It says:
--- Quote ---Connect all of the gene's conditions with boolean operations.
or -> add sgn
and -> mult
not -> 1 sub dup div
xor -> sub dup div
--- End quote ---
But when the things you're using them on are going to be only either 0 or 1, you can use these instead:
or becomes |
and becomes &
not becomes - ++
xor becomes ^
Those are just the bitwise versions of those operators, except for not, since the bitwise not operator (~, the complement operator) would (if it works like it does in asm) turn 0 into -1 (0xffffffff) and 1 into 0xfffffffe (-2).
("x - ++" is identical to "1 x sub")
For the other operators, I'm doing this:
> becomes 'sub sgn 0 floor'
< becomes 'sub sgn - 0 floor'
>= becomes 'sub 1 add sgn 0 floor'
<= becomes 'sub 1 sub sgn - 0 floor'
= becomes 'sub sgn abs - ++'
!= becomes 'sub sgn abs'
I haven't given much thought to what ~= and %= and the like could be converted to, since the wiki says that they're more or less useless.
abyaly:
Actually, the ones posted there aren't the same ones I use now, but it all amounts to the same thing in the end. What's important is that it's readable to the creator and accomplishes what is needed
I could write something about that, Jez.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version