Author Topic: Hibernation  (Read 8873 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7715
    • View Profile
Hibernation
« Reply #15 on: April 15, 2006, 07:14:28 PM »
A little behind the times aren't we?  

I changed it so that store commands cost energy the moment thye're used.  I believe that was 2.37.  It's what allowed Spanish Conquistador and other short bots to explode in complexity and efficiency.

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Hibernation
« Reply #16 on: April 15, 2006, 08:06:14 PM »
Yep, great little guys. Normally I'll do the initial code regular, then SG'ize it afterwards. Useful also for general cost saving in Multi-gene bots, since every bit of nrg helps.  

Here's a tutorial on the whole concept.

Conditionless bots


You could just make a normal condition send them into hibernation. It would effectivly act as a overall state regulator, costs some nrg, but would make the coding easier. Only downside is that the antiviral stuff wouldn't work.  

Maybe it would be useful for bots near death. They could hibernate until a conspec gives them enough nrg to get going again.

Offline Elite

  • Bot Overlord
  • ****
  • Posts: 532
    • View Profile
Hibernation
« Reply #17 on: April 16, 2006, 05:58:34 AM »
Damn. I ran a test, and in 2.37.6 hibernation does work, but in 2.4X it doesn't
No wonder Una was dying in 2.4 - there's a lot of stores in there

Grrrrrr ... change it back    

Here's SWARM SGified:

Code: [Select]
' SWARM
'
' Forms swarms to its tactical advantage

cond
start
.tie *.robage 1 add mult inc
.deltie inc
.fixpos *.fixed mult dec
*.refaim .setaim *.refkills *.kills sub sgn 1 add sgn mult *.eye5 sgn mult *.refeye *.myeye sub abs sgn -1 mult 1 add mult store
10 .up *.eye5 sgn mult *.refeye *.myeye sub abs sgn -1 mult 1 add mult store
10 .up *.eye5 -1 mult 1 add mult store
*.eye9 2 mult *.eye8 add *.eye1 2 mult *.eye2 add sub *.eye5 1 add div .aimdx store
*.refvelup 50 add .up 45 *.eye5 sub sgn mult *.eye5 sgn mult *.refeye *.myeye sub abs sgn mult store
*.refxpos *.refypos angle .setaim *.robage sgn mult *.eye5 sgn mult *.refeye *.myeye sub abs sgn mult store
-6 .shoot *.refeye *.myeye sub abs sgn mult *.eye5 34 sub sgn mult store
16 .shootval *.refeye *.myeye sub abs sgn mult *.eye5 34 sub sgn mult store
*.refveldx .dx *.refeye *.myeye sub abs sgn mult *.eye5 34 sub sgn mult *.refveldx *.veldx sub abs 5 sub sgn mult store
30 .repro *.nrg 750 sub sgn mult store
100 .strbody *.nrg 500 sub sgn mult store
*.body 0 floor .fdbody *.body sgn mult 100 *.nrg sub sgn mult store
*.tiepres .tienum *.numties sgn mult *.robage 1 sub sgn mult store
.tieval .tieloc *.numties sgn mult *.robage 1 sub sgn mult store
1000 .tieval *.numties sgn mult *.robage 1 sub sgn mult store
.delgene inc .delgene inc
stop

end

Notice the antivirus code on the end

SG bots with double .delgene inc are totally immune to viruses - the virus is deleted before it can execute

There's a topic here about conditionless coding. There's also my Animal Minimalis SGified in there
« Last Edit: April 16, 2006, 05:58:59 AM by Elite »

Offline Welwordion

  • Bot Destroyer
  • ***
  • Posts: 324
    • View Profile
Hibernation
« Reply #18 on: April 16, 2006, 08:31:45 AM »
Hm, I just realized you could build a bot without store commands, instead it would rely on inc dec and information/venom shots it fires at itself(he could be a MB to do that).
However it would be quite complicated and energy expensive.
« Last Edit: April 16, 2006, 08:34:55 AM by Welwordion »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7715
    • View Profile
Hibernation
« Reply #19 on: April 16, 2006, 10:36:57 AM »
In 2.4 at least inc and dec are no longer free.  They cost 1 / 10th of a store I believe.

If Eric doesn't, I'll try and figure out what makes hibernation no longer work after church.

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2554
    • View Profile
    • http://kuro-tejina.com
Hibernation
« Reply #20 on: April 16, 2006, 11:26:31 AM »
Quote from: Numsgil
A little behind the times aren't we?  

I changed it so that store commands cost energy the moment thye're used.  I believe that was 2.37.  It's what allowed Spanish Conquistador and other short bots to explode in complexity and efficiency.
Apparently so.
it's been about 6 months since I had the time to delve into the code and since you joined the programming team, everything has been moving at incredible speed.
There are 10 kinds of people in the world

Those who understand binary.

and those who don't

:D PY :D

Offline Henk

  • Bot Destroyer
  • ***
  • Posts: 110
    • View Profile
    • http://www.henkx.net
Hibernation
« Reply #21 on: April 16, 2006, 12:48:01 PM »
Quote from: Elite
Here's SWARM SGified:

That thing is EVIL

Single-gened bots nowadays are just as good as recent multi-gened ones. Maybe even better...
cond
*.DBbugs 0 =
start
.rejoice inc
stop

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7715
    • View Profile
Hibernation
« Reply #22 on: April 16, 2006, 12:50:23 PM »
Really throws the whole SG league on end doesn't it?  

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
Hibernation
« Reply #23 on: May 01, 2006, 07:06:52 PM »
Quote from: Henk
That thing is EVIL

Single-gened bots nowadays are just as good as recent multi-gened ones. Maybe even better...
Why wouldnt they be? Any bot that has an empty stack after the end of each gene can easily be made into an SG.
Step 1:
Convert all conditional operators as follows:
>   -> sub sqr dup div
<   -> sub -1 mult sqr dup div
!=  -> sub dup div
=   -> sub dup div 1 sub abs
Step 2:
Connect all of the gene's conditions with boolean operations.
or   -> add sgn
and -> mult
not  -> 1 sub dup div
xor -> sub dup div
Step 3:
Find every store, inc, or dec command inside the gene.
Multiply the address being modified by the value from step 2.
Step 4:
After doing this to every gene, put everything together into a conditionless gene.

Bots that don't fit the criteria wont work with that algorithm, but with some effort I think those could be converted to SG bots too  
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Hibernation
« Reply #24 on: May 01, 2006, 08:41:19 PM »
Quote from: Numsgil
In 2.4 at least inc and dec are no longer free.  They cost 1 / 10th of a store I believe.

In all versions of 2.4, inc and dec cost 1/10th of a store as long as the value on the stack is between 1 and 1000 inclusive.  (0 inc costs nothing,  same with 0 dec).

Beginning with 2.42.3, stores have symmetric behaviour (stores to locations outside 1 to 1000 inclusive cost nothing).  In previous versions of 2.4, any store would cost you, including attempted stores to location 0.

In short, if I understand the concept sufficiently, hybernation should once again work in 2.42.3.
Many beers....

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
Hibernation
« Reply #25 on: July 09, 2007, 11:28:26 AM »
Quote from: abyaly
Convert all conditional operators as follows:
>   -> sub sqr dup div
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 >)
« Last Edit: July 09, 2007, 01:31:59 PM by Trafalgar »

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
Hibernation
« Reply #26 on: July 09, 2007, 04:58:40 PM »
sqr turns a positive number into the square root of that number. it turns a negative number into 0
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Hibernation
« Reply #27 on: July 09, 2007, 06:25:25 PM »
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.  
« Last Edit: July 09, 2007, 06:29:58 PM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
Hibernation
« Reply #28 on: July 09, 2007, 08:58:20 PM »
Quote from: abyaly
sqr turns a positive number into the square root of that number. it turns a negative number into 0

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

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.
« Last Edit: July 09, 2007, 09:21:39 PM by Trafalgar »

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
Hibernation
« Reply #29 on: July 10, 2007, 09:54:02 AM »
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.
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)