Darwinbots Forum

Welcome To Darwinbots => Newbie => Topic started by: Botsareus on April 14, 2009, 01:09:58 PM

Title: Need a little help with DB math
Post by: Botsareus on April 14, 2009, 01:09:58 PM
Is there a command  (call it “unpow”) that does the vb equivalent of “a ^ (1/b)”?

For example:

Quote
64
3
unpow
puts 4 on top of the stack
Title: Need a little help with DB math
Post by: Botsareus on April 14, 2009, 04:09:40 PM
Yep, never mind, the answer is "NO". ( I just realised I have been trough this before)

If we really want to get going with this stuff we might as well add a command (call it “depow”) that does the vb equivalent of “Log(a) / Log(b)"

For example:
Quote
64
4
depow

puts 3 on top of the stack
Title: Need a little help with DB math
Post by: Shasta on April 14, 2009, 07:39:31 PM
What you could do is use an approximation of log (http://en.wikipedia.org/wiki/Logarithm#Series_for_calculating_the_natural_logarithm), wouldn't exactly be nice and clean however  

Also for your first one do you really need a single operator for that?
Code: [Select]
64 1 3 div powThis works just fine.
Title: Need a little help with DB math
Post by: Numsgil on April 14, 2009, 08:56:57 PM
Really?  I guess it was a change Eric made.  Back in the day 1 3 div 3 mult would have been 0 from integer rounding errors.
Title: Need a little help with DB math
Post by: Shasta on April 15, 2009, 02:47:39 AM
Quote from: Numsgil
Really?  I guess it was a change Eric made.  Back in the day 1 3 div 3 mult would have been 0 from integer rounding errors.
Oh... actually no, its returns 1 (which makes sense if there are rounding errors). I was under several assumptions, including that it would work because the math works  sorry
Title: Need a little help with DB math
Post by: Numsgil on April 15, 2009, 09:26:13 AM
I remember Eric talked about it once, so it wouldn't have surprised me.  Mostly I objected to the idea, because floating point is a whole can of worms with how it works.
Title: Need a little help with DB math
Post by: Botsareus on April 15, 2009, 02:55:36 PM
That is why I suggest we skip the floating point bull and do the calculations internally:

“Log(a) / Log(b)" means "depow"
“a ^ (1/b)” means "unpow"

a
b
depow


a
b
unpow

This way the result will be an approximate whole but there will be no need for floating points in the DB code.

And yes my names need improvement: I don't think "unpow" and "depow" sounds professional enough.

P.S.

O yea, and I believe this topic belongs in the suggestions forum now...
Thank You for your time...
Title: Need a little help with DB math
Post by: Numsgil on April 15, 2009, 06:00:35 PM
I think a general pow term actually isn't a great idea.  There's very little need to raise things to powers other than 1/3, 1/2, 2, or 3.  So I think a better solution would be to add cbrt, cube, and square commands.  Or something along those lines.
Title: Need a little help with DB math
Post by: Botsareus on April 16, 2009, 12:11:32 PM
I have already added unpow and depow to my DB source code...

So If my evolved robot uses it I will have to post the vb code I changed. It's two new subs called DNAunpow and DNAdepow. DNA tokenizing and detokenizing was changed. etc.
Title: Need a little help with DB math
Post by: bacillus on April 22, 2009, 02:55:25 AM
Just out of curiosity, what were you planning to use this for?
Title: Need a little help with DB math
Post by: Botsareus on April 22, 2009, 11:05:21 AM
I hope that it will add more flexibility to my evolving robots. I don't plan to write my own robot, I am working on a system to generate a robot good enough for F1 mode...
Title: Need a little help with DB math
Post by: Prsn828 on April 22, 2009, 01:18:56 PM
Quote from: Botsareus
I hope that it will add more flexibility to my evolving robots. I don't plan to write my own robot, I am working on a system to generate a robot good enough for F1 mode...

You know, I think the whole concept of Darwinbots began around that idea.  The thought that you can evolve a better bot, no matter how good the current one may be.  At least in my mind, that is what is so exciting.