Bots and Simulations > DNA Tools

Sanger

(1/7) > >>

Gobo:
Please check it out.

http://ersatz.org/sanger-1.0.zip

Feedback and bug reports are equally welcome. If you notice a bad turn of speech in documentation, please report me as well, since English is not my native language and I can hardly check myself.


--- Code: ---NAME
    sanger.pl - Darwinbots DNA macro language interpreter

SYNOPSIS
        sanger.pl [file]
        sanger.pl -e [code]
        sanger.pl --help

DESCRIPTION
    Sanger is a macro language designed to make conditionless DNA
    construction easier. Sanger is named after Frederick Sanger, inventor
    of DNA sequencing.

    "sanger.pl" is Sanger interpreter which gives classic low-level DNA code
    on output. Sanger code may contain macro definitions and file
    inclusions. Everything else is interpreted as instructions, I. e. macro
    calls and plain DNA code.

MACROS
    Macro definition starts with DEFINE and lasts till a semicolon. Macro
    names are case-insensitive.

        DEFINE NEZ     $1 sgn abs;
        DEFINE NE      NEZ( $1 $2 sub );

    Definition of a macro may contain argument references: $1, $2 and so on.
    When macro is called, argument references are replaced with arguments.
    For instance,

        NE( *.myeye, *.refeye )

    is interpreted as

        *.myeye *.refeye sub sgn abs
    
FILE INCLUSIONS
    File inclusions start with INCLUDE and last till a semicolon, similar to
    macros.

        INCLUDE filename;

STANDARD LIBRARY
    These macros are found within 'stdlib.dna' file going in distribution.

    NOT( boolean )
    AND( boolean, boolean )
    OR( boolean, boolean )
    XOR( boolean, boolean )
        Boolean operators.

    EQZ( integer )
    NEZ( integer )
    GTZ( integer )
    LTZ( integer )
    GEZ( integer )
    LEZ( integer )
        Compare the top value on the stack with zero.

    EQ( integer, integer )
    NE( integer, integer )
    GT( integer, integer )
    LT( integer, integer )
    GE( integer, integer )
    LE( integer, integer )
        Compare two integers on the top of the stack.

    TEST( boolean, integer )
        If the first argument is true, pushes the second argument on the
        stack, otherwise pushes zero.

    IF( boolean, integer, integer )
        If the first argument is true, pushes the second argument on the
        stack, otherwise pushes the third.

EXAMPLES
        Lionfish's genes are taken for demonstration.

            INCLUDE stdlib.dna;

            ' Venom blinding and strvenom killer exploit
            IF( 1 rnd, IF( 1 rnd, .eye5width, .eye5dir ), .strvenom ) .vloc store

            ' Selective shooting
            DEFINE ENEMY NE( *.in1, *.refage );
            IF( GT( *.eye5, 60 ),
                IF( NEZ( *.refeye ),
                    TEST( ENEMY(), -3 ),
                    -6 ),
                TEST( GT( *.nrg, 1000 ), -3 ) ) .shoot store

SEE ALSO
    Frederick Sanger
        <http://en.wikipedia.org/wiki/Frederick_Sanger>

    Lionfish's genes explained
        <http://www.darwinbots.com/Forum/index.php?showtopic=2169>

AUTHOR
    Ivan Fomichev <ifomichev@gmail.com>

COPYRIGHT
        Copyright (C) 2007  Ivan Fomichev

        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
--- End code ---

Numsgil:
Neat, but you might want to consider changing the names for the "standard library" to be clearer.  For instance, EQZ is awefully cryptic if you've never used assembly.  And the macro language is supposed to be higher level than the original DNA.  Maybe something like EqualsZero or similar.

Gobo:

--- Quote from: Numsgil ---Neat, but you might want to consider changing the names for the "standard library" to be clearer.  For instance, EQZ is awefully cryptic if you've never used assembly.  And the macro language is supposed to be higher level than the original DNA.  Maybe something like EqualsZero or similar.
--- End quote ---
I thought about that, but preferred clarity to brevity. Actually these names are based rather on Perl operators than assembly. By the way, high level language may have nothing with clarity, e. g. see APL

Nevertheless thank you for your notice, I'm likely to add verbose names as aliases in the next revision.

Gobo:
I noticed, that IF is not as effective as it might be, when arguments themselves are complex expressions, since $3 is calculated twice. This will be fixed in the next revision.

Originial definition:

--- Code: ---DEFINE IF       $2 $3 sub $1 mult $3 add;
--- End code ---
Revised definition:

--- Code: ---DEFINE IF       $3 dup $2 sub $1 mult sub;
--- End code ---

Peter:
Okay, maybe I am acting like a stupid-head. Well just maybe.  

What can I do with this sanger-program???

Give some explanation, becouse I just don't get the full point.

I Just read the first line again.
It says.
Darwinbots DNA macro language interpreter

Does it means it converts DB dna to a higher languege. If so, I don't understand the languege at all.
But you want to make a program or something that codes what you make in DB-dna and can recode back to higher languege. That could be pretty good. Maybe something for a better understandment of evolved bots or something.(their dna is mostly harder to read)

And just to know, what does EQZ exactly mean??(along with the others)

Navigation

[0] Message Index

[#] Next page

Go to full version