Darwinbots Forum

Code center => Suggestions => Topic started by: Botsareus on April 16, 2009, 01:16:55 PM

Title: My new math commands
Post by: Botsareus on April 16, 2009, 01:16:55 PM
How many people will update there source code with my new commands discussed here (http://www.darwinbots.com/Forum/index.php?showtopic=3120&view=getnewpost)
if I evolve a robot who beats the best robot on the F1 league and uses this commands.
Title: My new math commands
Post by: Botsareus on April 16, 2009, 05:03:39 PM
'By the way, here it is: (Please make sure the right code goes into the right .bas file)



'----------changes to DNAExecution(DNA.bas)


Private Sub ExecuteAdvancedCommand(n As Integer) 'replace existing
  Select Case n
    Case 1 'findang
      findang
    Case 2 'finddist
      finddist
    Case 3 'ceil
      DNAceil
    Case 4 'floor
      DNAfloor
    Case 5 ' sqr
      DNASqr
    Case 6 ' power
      DNApow
    Case 7 ' pyth
      DNApyth
    Case 8 ' unpow
      DNAunpow
    Case 9 ' depow
      DNAdepow
  End Select
End Sub


Private Sub DNAunpow() 'add new
On Error GoTo b:
    Dim a As Double
    Dim b As Double
    Dim c As Double
    b = PopIntStack
    a = PopIntStack
    c = a ^ (1 / b)
    PushIntStack c
Exit Sub
b:
    PushIntStack 0
End Sub


Private Sub DNAdepow() 'add new
    Dim a As Double
    Dim b As Double
    Dim c As Double
    b = Abs(PopIntStack)
    a = Abs(PopIntStack)
    If b > 1 And a > 0 Then c = Log(a) / Log(b) Else c = 0
    PushIntStack c
End Sub


'----------changes to DNATokenizing(DNATokenizing.bas)


Private Function AdvancedCommandDetok(n As Integer) As String 'replace existing
  AdvancedCommandDetok = ""
  Select Case n
    Case 1
      AdvancedCommandDetok = "angle"
    Case 2
      AdvancedCommandDetok = "dist"
    Case 3
      AdvancedCommandDetok = "ceil"
    Case 4
      AdvancedCommandDetok = "floor"
    Case 5
      AdvancedCommandDetok = "sqr"
    Case 6
      AdvancedCommandDetok = "pow"
    Case 7
      AdvancedCommandDetok = "pyth"
    Case 8
      AdvancedCommandDetok = "unpow"
    Case 9
      AdvancedCommandDetok = "depow"
  End Select
End Function


Private Function AdvancedCommandTok(s As String) As block 'replace existing
  AdvancedCommandTok.value = 0
  AdvancedCommandTok.tipo = 3
  Select Case s
    Case "angle"
      AdvancedCommandTok.value = 1
    Case "dist"
      AdvancedCommandTok.value = 2
    Case "ceil"
      AdvancedCommandTok.value = 3
    Case "floor"
      AdvancedCommandTok.value = 4
    Case "sqr"
      AdvancedCommandTok.value = 5
    Case "pow"
      AdvancedCommandTok.value = 6
    Case "pyth"
      AdvancedCommandTok.value = 7
    Case "unpow"
      AdvancedCommandTok.value = 8
    Case "depow"
      AdvancedCommandTok.value = 9
  End Select
End Function

'If you are having problems inserting the code or get any kind of error please let me know.
Title: My new math commands
Post by: Prsn828 on April 20, 2009, 12:11:55 PM
The problem here is, some people just cannot update their version (Me) because VB6 is incompatible with Vista (And therefore only the .exe's can be run).

On the other hand, if you make new exe's, I would gladly use them
Title: My new math commands
Post by: Botsareus on April 20, 2009, 01:02:34 PM
Ok, I will get the latest available DB source code and update it with my commands and compile it. I will post the .zip here.

I also planning to add DNAsin and DNAcos, to the code.
Title: My new math commands
Post by: Prsn828 on April 20, 2009, 02:16:00 PM
Quote from: Botsareus
Ok, I will get the latest available DB source code and update it with my commands and compile it. I will post the .zip here.

I also planning to add DNAsin and DNAcos, to the code.

You know, you may be saving DB2 from complete abandonment by doing this.

I tried to convert the code to the recent version of VB, but of course, it was completely hopeless.  103 errors are visible at all times, and several thousand are usually forgotten by the compiler by the time it reports the first 103 errors, so after hours and hours of conversions I was destroyed by Microsoft's total failure at backwards compatibility.
Title: My new math commands
Post by: Botsareus on April 20, 2009, 05:14:18 PM
Well if I get .net studio (which I don't have yet). And get my hands on the DB3 source code. I might (hopefully) figure out how to add my commands to that as well.
Title: My new math commands
Post by: Prsn828 on April 20, 2009, 05:47:24 PM
DB3 is open-source, unless I'm going crazy, and there are instructions on the wiki as to exactly what you need to do to get it, and Microsoft Visual C# 2008 Express Edition (also free) up and running (or at least as close to running as it gets right now).

I had never even seen a single line of C# before I joined Nums in the project, so if you want to try to help out, it is not only OK, but would actually be very appreciated.

If you do decide you want to get it up and running, Nums and I can both assist you in the setup, so just PM us if you need help (I check the forum quite often, so I will likely reply within an hour at the most, unless I'm asleep).  It is no trouble at all if you need to be brought up to speed.

If, while getting set up, you notice something confusing on the wiki, feel free to fix it.


Title: My new math commands
Post by: Numsgil on April 20, 2009, 11:40:22 PM
You know, I don't think I ever picked an open source license for DB3.  I kept meaning to but I always forgot.  I'll try to spend some time and pick one out.
Title: My new math commands
Post by: Prsn828 on April 21, 2009, 10:18:11 AM
Quote from: Numsgil
You know, I don't think I ever picked an open source license for DB3.  I kept meaning to but I always forgot.  I'll try to spend some time and pick one out.
  BAD NUMS!!!

How could you forget such a thing!?!?

Just kidding; sort of....

But yeah, you should get on that buddy, it is kinda important :/
Title: My new math commands
Post by: Numsgil on April 21, 2009, 03:22:31 PM
I picked the MIT license (basically about as close to releasing into public domain as you can get).