Bots and Simulations > DNA Tools
Sanger
Peter:
--- Quote from: Numsgil ---
--- Quote from: Peter ---
And just to know, what does EQZ exactly mean??(along with the others)
--- End quote ---
You need to actually read posts before declaring that they don't make sense.
--- End quote ---
When did I declare they don't make sense?
What made you think I didn't red any posts?
--- Quote ---EQZ( integer )
NEZ( integer )
GTZ( integer )
LTZ( integer )
GEZ( integer )
LEZ( integer )
Compare the top value on the stack with zero.
--- End quote ---
I see compare the top value on the stack with zero. Everyone?, I don't think they all do desame so what do they do.
--- Quote from: Gobo ---
--- Quote from: Numsgil ---I don't think he ever released it, but he'd probably share if you could reach him.
--- End quote ---
I think I dropped him a personal message, but it didn't show up in "Sent Items". Is it ok?
--- End quote ---
Yes, it is.
Gobo:
--- Quote from: Peter ---
--- Quote --- EQZ( integer )
NEZ( integer )
GTZ( integer )
LTZ( integer )
GEZ( integer )
LEZ( integer )
Compare the top value on the stack with zero.
--- End quote ---
I see compare the top value on the stack with zero. Everyone?, I don't think they all do desame so what do they do.
--- End quote ---
EQZ - equal to zero
NEZ - not equal to zero
GTZ - greater than zero
LTZ - less than zero
GEZ - greater or equal to zero
LEZ - less or equal to zero
If you glanced in 'stdlib.dna', you could easily figure that by yourself.
Gobo:
--- Quote from: Numsgil ---You might want to give this a look. About the 4th or 5th post down Trafalgar shows the code he used for Guardian for his interpreter.
--- End quote ---
I looked into it more thoroughly. Trafalgar's interpreter has a prettier syntax, but it seems it lacks at least two prominent features Sanger has.
First, there are no macros with arguments. So Trafalgar's interpreter's language seems to me less extensible, than Sanger.
Second, there is no branching with "else" case (compare to IF macro in Sanger). As the result, I expect DNA code produced with Trafalgar's interpreter's language be much more verbose than Sanger's, since the same conditions repeat in compiled code excessively.
Gobo:
--- Quote from: Numsgil ---By contrast, something like assembly is designed only to be easy for the computer to interpret. Programming ease is not the priority at all. The current DNA language is comparable to assembly, so I'm thinking you should aim for something like ruby. Something totally natural for a coder to work in.
--- End quote ---
I have trifled Parse::Eyapp and I think I can manage a prettier syntax. Sample code for the same Lionfish's genes follows.
--- Code: ---include "stdlib.dna";
.vloc = rnd(1) ? .strvenom : rnd(1) ? .eye5width : .eye5dir;
function isEnemy() { *.in1 != *.refage }
if ( *.eye5 > 60 ) {
if ( *.refeye != 0 ) {
if ( isEnemy() ) .shoot = -3;
}
else .shoot = -6;
}
else if ( *.nrg > 1000 ) .shoot = -3;
--- End code ---
I suppose to embed plain DNA with backticks and have named arguments for "functions". The following example is contrived, since notEquals is built-in "!=", and notEqualsZero is thought to be used within as an optimization of "a != 0".
--- Code: ---function notEqualsZero(a) { a, `abs sgn`; }
function notEquals(a, b) { notEqualsZero( a - b ); }
--- End code ---
Please make your notices before I begin developing, because it is much easier to change code before it has been written
Gobo:
I have written pre-alpha Sanger with new syntax. This is not yet documented, though is quite intuitive.
You can download it from http://ersatz.org/sanger-1.999.tar.gz or try it online at http://ersatz.org/sanger.html. By default the form contains the source of Animal Minimalis in Sanger.
Just few notices.
* There is a ternary conditional assignment operator: EXPR1 ?? EXPR2 = EXPR3. It means: assign EXPR3 to EXPR1 if EXPR2 is true. EXPR2 may contain a special word this (but just once), which refers to EXPR3. E. g.
--- Code: ---.aimsx ?? this = ( *.eye9 && -40 ) + ( *.eye8 && -30 ) + ( *.eye7 && -20 ) +
( *.eye6 && -10 ) + ( *.eye4 && 10 ) + ( *.eye3 && 20 ) +
( *.eye2 && 30 ) + ( *.eye1 && 40 );
.eye5width ?? ( this != *.eye5width ) = ( rnd(4) == 0 ? 900 : 0 );
--- End code ---
* You can define macros with -> operator. For now, they cannot be inside genes. They may have arguments, separated with comma.
--- Code: ---friendly() -> *.refeye == *.myeye;
chance( n ) -> rnd( n ) == 0;
--- End code ---
* Custom variables are defined with similar syntax.
--- Code: ---kinfactor -> 971;
--- End code ---
* For now, there is only syntax for conditionless genes.
--- Code: ---always {
...
}
--- End code ---
* You may have expressions on the left side, too.
--- Code: ---*.eye5 > 50 && !friendly() && .shoot = -1;
--- End code ---
* Logical operators || and && have the same return value as in Perl. It means that
5 || 3 == 5
0 || 2 == 2
3 && 5 == 5
0 && 2 == 0
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version