Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
merthsoft wrote:
Alright, so now we've got a C# implementation, a TI-BASIC implementation, and a Python (3.1?) implementation. Let's get more! Someone make the z80 implementation!

KermMartian wrote:
I would find it trivial to write the shell script to wrap that program and find the seeds on Linux, but how are you doing it on Windows? Did you modify the program to iterate over possible seeds instead of doing batch scripting for the sake of simplicity?
Python. And it's running on Linux now so I could run it in a screen session.


We could have a contest to see who finds the “hello world” seed first... or if you wanted to go really overkill, set up a BOINC thing to find it. Laughing
This should work, didn't really test it... z80 ASM, store everything in prgmMERTHCDE (as in, the input) and then run the program. Can't be archived because I was too lazy to make sure that part worked.

Edit: Updated and moved code to two posts below this one.
Ruby one:


Code:
arg_string = ARGV.join
arg_string.each_char {|character|
    case character
    when 'm';puts 'merth'
    when 'e';puts "\n"
    when 'r';puts ' '
    when 't';puts Array.new(i = rand(13)) {
                  |chrct| chrct = (('a'..'z').to_a.at(rand(25)).to_s)
                  }.join.chomp
    when 'h'
        while character != 'h';next;end;next;end }


Working on a Procedural Brainf*** one.

Edit by Merth: Stars my friend, start.
Here is the updated version of my z80 code for this. Uncomment the "#define KERM" to use the Merthing @ Kerm extension.
Code:
; Program Name:
; Author:
; Version:
; Date:
; Written for Doors CS 7.0 and higher (http://dcs.cemetech.net)
#define store(xx,yyyy) ld a,xx \ ld (yyyy),a
#define storelarge(value,location) ld hl,value \ ld (location),hl
#define clrscr() ld hl,gbuf \ ld de,gbuf+1 \ ld bc,767 \ ld (hl),0 \ ldir
#define comparehl(xxxx) ld de,xxxx \ or a \ sbc hl,de \ add hl,de
#define comparehlde() or a \ sbc hl,de \ add hl,de
#define getKey(group,bitty) ld a,group \ out (1),a \ nop \ nop \ in a,(1) \ bit bitty,a
#define sprite(sprite,x,y,height) ld ix,sprite \ ld a,(y) \ ld l,a \ ld a,(x) \ ld b,height \ call iPutSprite
#define AddBullet(x,y) ld a,(y) \ld e,a \ ld a,(x) \ call AddBullet
#define copybackwards(start,size) ld hl,start \ ld bc,size \ push hl \ pop de \ inc de \ ldir
#define setmem(start,size,value) ld hl,start \ ld de,start+1 \ ld bc,size-1 \ ld (hl),value \ ldir
#define random(low,high) ld b,high-low+1 \ call iRandom \ add a,low
#define random(high) ld b,high \ call iRandom
#define randombool() ld a,r \ and %00000001
#define randomjump(jr1, jr2) ld a,r \ and %0000001 \ jr z,jr1 \ jr jr2
#define randomjump(jr1) ld a,r \ and %00000001 \ jr z,jr1
#define copy(from,to,size) ld hl,from \ ld de,to \ ld bc,size \ ldir

;#define KERM
#define ARRAY_SIZE 5
#ifdef KERM
   #define ARRAY_SIZE 6
#endif
#define hflagison() ld a,(hflag) \ or a \ ret nz

.nolist
#include "dcs7brass.inc"
.list
   .org progstart
   .db $BB,$6D
Init:
   xor d
   ret
   jr Start
   
   .dw 0000         ;or .dw $0000 if you don't have a description '
   .db $07,$00         ;always this string
   .dw 0000         ;or .dw $0000 if you don't have an icon'
   .dw 0000            ;usually .dw $0000 if you don't have or know what an ALE is'
Start:                             ;main routines
   store(0,accum)
   store(0,hflag)
   ld hl,varname
   rst 20h
   bcall 42F1h       ;ChkFindSym
   jr c,Archived      ;carry flag is set if the VAT entry is not found
   ex de,hl           ;put data pointer into hl
   xor a
   cp  b              ;see if b is 0, and the program is in the ram
   jr z,unarchived      ;if so, jump to unarchived
Archived:
Error:
   bcall _ClrLCDFull
   ld hl,sErrorMessage
   bcall _PutS
   bcall _Getkey
   ret
Unarchived:
   inc hl
   inc hl
Merthterpreter:
   ld a,(hl)
   push hl
      push bc
         ld b,ARRAY_SIZE
         ld hl,ArrayToTestAgainst
CheckForCharacterLoop:
         cp (hl)
         jr z,CheckForCharacter_Found
CheckForCharacterNevermind:
         inc hl
         inc hl
         inc hl
CheckForCharacterContinue:
         djnz CheckForCharacterLoop
         jr CheckForCharacterFinished
CheckForCharacter_Found:
         inc hl
         push hl
            ld ($+3+1),hl
            ld hl,(0000) ; SMC
            ld ($+3+1),hl
            call 0000 ; SMC
            pop hl
         inc hl
         inc hl
         jr CheckForCharacterContinue
CheckForCharacterFinished:
         pop bc
      pop hl
   inc hl
   dec bc
   ld a,b
   or c
   ret z
   jr Merthterpreter
MertheseM:
   hflagison()
#ifdef KERM
   randomjump(MertheseM2)
#endif
   ld hl,sMerth
   bcall _PutS
   ret
#ifdef KERM
MertheseM2:
   ld h,0
   ld a,(accum)
   ld l,a
   bcall _DispHL
   ret
#endif
MertheseE:
   hflagison()
#ifdef KERM
   randomjump(MertheseE2)
#endif
   ld a,'\n'
   bcall _PutC
   ret
#ifdef KERM
MertheseE2:
   ld hl,accum
   inc (hl)
   ret
#endif
MertheseR:
   hflagison()
#ifdef KERM
   randomjump(MertheseR2)
#endif
   ld a,' '
   bcall _PutC
   ret
#ifdef KERM
MertheseR2:
   xor a
   ld (accum),a
   ret
#endif
MertheseT:
   hflagison()
   random(14) ; Because ASM doesn't have 13.4, sorry :('
   ld b,a
MertheseTLoop:
   push bc
      random('a','z')
      bcall _PutC
      pop bc
   djnz MertheseTLoop
   ret
MertheseH:
   ld a,(hflag)
   xor 1
   ld (hflag),a
   ret
#ifdef KERM
MertheseK:
   hflagison()
   ld a,(accum)
   bcall _PutC
   ret
#endif
data:
ArrayToTestAgainst:
   .db 'M', MertheseM
   .db 'E', MertheseE
   .db 'R', MertheseR
   .db 'T', MertheseT
   .db 'H', MertheseH
#ifdef KERM
   .db 'K', MertheseK
#endif
hflag:
   .db 0
sMerth:
   .db "merth",0
sErrorMessage:
   .db "Please unarchive"
   .db "prgmMERTHCDE",0
VarName:
   .db $05,"MERTHCDE",0
accum:
   .db 0
UserRPL version. Takes input as a string on the stack and returns the resulting string on the stack.

May not be the most optimized in the world; I'm not as experienced with UserRPL as I am with languages like Python and TI-BASIC. It's possible there could be some bugs, though it seems to work fine.


Code:

« 1. → code codepos
  « ""
    WHILE codepos code SIZE ≤
    REPEAT code codepos DUP SUB
      CASE DUP "m" ==
        THEN "merth"
        END DUP "e" ==
        THEN "
"
        END DUP "r" ==
        THEN " "
        END DUP "t" ==
        THEN "" 1. RAND 13.4 *
          FOR i "abcdefghijklmnopqrstuvwxyz" RAND 26. * DUP SUB +
          NEXT
        END DUP "h" ==
        THEN code SIZE → s
          « code codepos 1. + s SUB "h" POS DUP 0. ≠ SWAP s IFTE codepos + 'codepos' STO
          » ""
        END ""
      END NIP + 'codepos' 1. STO+
    END
  »
»
This is wonderful. You guys have made my day Smile
Axe version:

Code:

.MERTHESE
"MERTH"->Str1
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Str2
For(X,0,length(Str1))
If {Str1+X}='M'
Disp "merth"
End
If {Str1+X}='E'
Disp i
.That's the complex i
End
If {Str1+X}='R'
Disp " "
End
If {Str1+X}='T'
rand^14->K
For(M,0,K
rand^26->G
Copy(Str2+G,L1,1
0->{L1+1}
Disp L1
End
End
If {Str1+X}='H'
X+1->A
length(Str1)->G
Repeat (A=G) or ({Str1+A}='H')
A+1->A
End
If {Str1+A}='H'
A->X
End
End
End
Repeat getKey
End
Return

Modify Str1 to change the code to interpret.



EDIT: Bash implementation:

I haven't really tested this yet, but it should work:

Code:
#!/bin/bash

code=$1
codelength=${#code}
allchars="abcdefghijklmnopqrstuvwxyz"
i=0
while [[ "$i" -le "$codelength" ]]
do
   current=${code:$i:1}
   
   case $current in
    m)
        echo -n "merth";;
       
    e)
        echo "";;
    r)
        echo -n " ";;
    t)
        length=$RANDOM%14
       
        for (( l=1; l<=$length; l++))
        do
        character=1+$RANDOM%26
        echo -n ${allchars:$character:1}
        done
        ;;
    h)
        for (( l=$i+1; l<=$codelength; l++))
            do
           
            case ${code:$l:1} in
            h)
                i=$l
                break
                ;;
            esac     
               
           
         done
         ;;
    esac
    i=$i+1
done
echo ""
C implementation. Run it like
Code:
./merthese merth is the coolest person I have ever seen.  Ever.

Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>

#define randbool() rand() % 2

int main(int argc, char** argv) {
  int i,
    hflag = 0,
    j;
  srand(time(NULL));
  char accum = '\0';
  for( i = 0; i < argc; i++ ) {
    char* cur = argv[i];
    for( j = 0; j < strlen( cur ) - 1; j++ ) {
      if ( cur[j] == 'h' )
   hflag = !hflag;
      if ( !hflag ) {
   switch ( cur[j] ) {
   case 'm':
     if ( randbool() )
       printf("merth");
     else
       printf("%d", accum);
     break;
   case 'e':
     if ( randbool() )
       printf("\n");
     else
       accum++;
     break;
   case 'r':
     if ( randbool() )
       printf(" ");
     else
       accum = '\0';
     break;
   case 't':
     {
       int times = rand() % ((int)13.4);
       for ( ; times >= 0 ; times-- )
         printf("%c",(char)((rand() % 26) + 'a'));
     }
     break;
   case 'k':
     printf("%c", accum);
     break;
   }
      }
    }
  }
}
Souvik, not be annoying, but may I optimize that axe program? Laughing


Code:
length(L1)
While -- ->A
   {L1+A}->B
   !If B-'M'
      Disp "Merth"
   Else!if B-'E'
      Disp i
   Else!if B-'R'
      Disp " "
   Else!if B-'T'
      rand^14
      While -- ->C
         Disp rand^26+'A'
         C
      End
   Else!if B-'H'
      While ({L1+A}->B)-'H'
         A--
      End
      A--
   End
A
End


Almost done the Pbrain one Smile
How goes the seeding?
Here's some mildly interesting seeds for the Python version on my system (running the Merthese program ‘trt’) I came across so far:


Code:

2801883: merth rw
113210346:  nikky
119936660:  dizzy
119965555: hi slacy
126193299: casiojhelloz
127258204: world
623016594: lukihellos


Haven't found “hello world” yet but still looking (though I suspect this is a bit like trying to factor the Nspire keys or something). This is actually kind of fun, though—better than a million monkeys on a million typewriters. Very Happy
Stacked BF Merthese interpreter.  It'll keep inputting characters until you input a space bar stroke.  The procedural parts are entirely optional as non-pbrain or Toadskin interpreters will ignore them, but can be recalled later on if you want by assigning the current cell to one of the 5 mertherators (Merthese operators), inverting bitwise, and doing a : .  I wrote this in about 2 hours of concentrated agony, keeping a tally list nearby of all the pushes and pops and values of 8 bit cells, so I'm about to go crazy.  Everything here is written by me, including the random number generating and rough modulus algorithms.


Code:
[-]^^+[,>^>*>**+^^<<-------- -------- -------- --------][-]+[<<*-^>]*^[---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- - (^++++++++.--------.+++++++++++++.++.------------.*) --- (^[-].*) ----- (^[-]++++++++++.*) ------ (^>>>>>>>>^>>>^<<<<<<<<<<<<<[-]++++++++++++++^>>>>>>>>>>>>>
[<<<<<<<<<<<<<*>>>>>>>>>>>>>[-<<<<<<<<<<<<<->>>>>>>>>>>>>]<<<<<<<<<<<<<^>*>>>>>>>>>>>>[-]]<<<*<<<<<<<<<<<^>>>
*[(<<<<<<[-]++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ +++++++ ^ <<^>* <<<<<<<<<<<<<[-]++++++++++++++++++++++++++^>>>>>>>>>>>>>
[<<<<<<<<<<<<<*>>>>>>>>>>>>>[-<<<<<<<<<<<<<->>>>>>>>>>>>>]<<<<<<<<<<<<<^>*>>>>>>>>>>>>[-]] >[-<+>].)]***) -- (^<*>*^<^[>---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----]>**) >][-]



While I don't have access to prove it until the morning, I think that even with a few typos or such it should be pretty close to functional.  I'll test it tomorrow and make any needed adjustments.

Edit: just noticed it does the operators in correspondence to 'ehmrt' right now, not 'merth'. I'll fix it in the morning since copy-pasting on the iPad really, really sucks.
Ashbad wrote:
Stacked BF Merthese interpreter.  It'll keep inputting characters until you input a space bar stroke.  The procedural parts are entirely optional as non-pbrain or Toadskin interpreters will ignore them, but can be recalled later on if you want by assigning the current cell to one of the 5 mertherators (Merthese operators), inverting bitwise, and doing a : .  I wrote this in about 2 hours of concentrated agony, keeping a tally list nearby of all the pushes and pops and values of 8 bit cells, so I'm about to go crazy.  Everything here is written by me, including the random number generating and rough modulus algorithms.


Code:
[-]^^+[,>^>*>**+^^<<-------- -------- -------- --------][-]+[<<*-^>]*^[---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- - (^++++++++.--------.+++++++++++++.++.------------.*) --- (^[-].*) ----- (^[-]++++++++++.*) ------ (^>>>>>>>>^>>>^<<<<<<<<<<<<<[-]++++++++++++++^>>>>>>>>>>>>>
[<<<<<<<<<<<<<*>>>>>>>>>>>>>[-<<<<<<<<<<<<<->>>>>>>>>>>>>]<<<<<<<<<<<<<^>*>>>>>>>>>>>>[-]]<<<*<<<<<<<<<<<^>>>
*[(<<<<<<[-]++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ +++++++ ^ <<^>* <<<<<<<<<<<<<[-]++++++++++++++++++++++++++^>>>>>>>>>>>>>
[<<<<<<<<<<<<<*>>>>>>>>>>>>>[-<<<<<<<<<<<<<->>>>>>>>>>>>>]<<<<<<<<<<<<<^>*>>>>>>>>>>>>[-]] >[-<+>].)]***) -- (^<*>*^<^[>---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----]>**) >][-]



While I don't have access to prove it until the morning, I think that even with a few typos or such it should be pretty close to functional.  I'll test it tomorrow and make any needed adjustments.

Edit: just noticed it does the operators in correspondence to 'ehmrt' right now, not 'merth'. I'll fix it in the morning since copy-pasting on the iPad really, really sucks.

Writing BF on the iPad sounds like an even worse idea than writing BF at all..... O_o




Travis: those are pretty cool =D
Nice, two hours seems like an impressively short time for something like that. The BF program looks much shorter and more concise than I expected, too.
Travis wrote:
Nice, two hours seems like an impressively short time for something like that. The BF program looks much shorter and more concise than I expected, too.


Well, I tried to go for size optimizations over speed ones. Plus, since I'm using Toadskin (procedures and stacks support added to BF) it took away a lot of size as well. However, I plan to do a 'real' BF program tomorrow (AKA keep constant awareness of a stack location defined by me, and update a SP constantly in memory x.x)
Well, if I can ask, what language should I write this in?
What languages do you know?
Good: Axe, Basic
Okay: C++
Poor: z80
IDK: All not listed
Do a C++ one with classes (since my C one doesn't have classes for obvious reasons).
Well, I would have to code on paper then transfer to computer due to restricted computer time.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 7
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement