Author Topic: Need a little help with DB math  (Read 4962 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Need a little help with DB math
« 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

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Need a little help with DB math
« Reply #1 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
« Last Edit: April 14, 2009, 04:12:29 PM by Botsareus »

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Need a little help with DB math
« Reply #2 on: April 14, 2009, 07:39:31 PM »
What you could do is use an approximation of log, 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.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Need a little help with DB math
« Reply #3 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.

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Need a little help with DB math
« Reply #4 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

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Need a little help with DB math
« Reply #5 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.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Need a little help with DB math
« Reply #6 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...
« Last Edit: April 15, 2009, 03:35:09 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Need a little help with DB math
« Reply #7 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.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Need a little help with DB math
« Reply #8 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.

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
Need a little help with DB math
« Reply #9 on: April 22, 2009, 02:55:25 AM »
Just out of curiosity, what were you planning to use this for?
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Need a little help with DB math
« Reply #10 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...

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Need a little help with DB math
« Reply #11 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.
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!