Author Topic: Letter Scrambler...  (Read 11777 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Letter Scrambler...
« on: February 07, 2007 »
I haven't used this one for ages. An automatic letter scrambler. I was into anagrams for a while.
It's crude, but it did the job. I've added a count to show the tries it takes to fill all the gaps, as it's random.
It handles up to 26 letters, as I made it originally to handle the alphabet.
Put your word straight into the a$ speech marks.

Code: [Select]
a$=""
open window 640,512
le=len(a$)
label again
ct=0
clear window
pause .25
ac=15
ab=100
aa=230

1 ct=ct+1
a=int(ran(le))+1
text (a*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,1,1)
2 ct=ct+1
b=int(ran(le))+1
if b=a goto 2
text (b*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,2,1)
3 ct=ct+1
c=int(ran(le))+1
if c=b or c=a goto 3
text (c*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,3,1)
if le=3 goto fin
4 ct=ct+1
d=int(ran(le))+1
if d=c or d=b or d=a goto 4
text (d*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,4,1)
if le=4 goto fin

5 ct=ct+1
e=int(ran(le))+1
if e=d or e=c or e=b or e=a goto 5
text (e*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,5,1)
if le=5 goto fin
6 ct=ct+1
f=int(ran(le))+1
if f=e or f=d or f=c or f=b or f=a goto 6
text (f*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,6,1)
if le=6 goto fin
7 ct=ct+1
g=int(ran(le))+1
if g=f or g=e or g=d or g=c or g=b or g=a goto 7
text (g*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,7,1)
if le=7 goto fin
8 ct=ct+1
h=int(ran(le))+1
if h=g or h=f or h=e or h=d or h=c or h=b or h=a goto 8
text (h*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,8,1)
if le=8 goto fin

9 ct=ct+1
i=int(ran(le))+1
if i=h or i=g or i=f or i=e or i=d or i=c or i=b or i=a goto 9
text (i*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,9,1)
if le=9 goto fin
10 ct=ct+1
j=int(ran(le))+1
if j=i or j=h or j=g or j=f or j=e or j=d or j=c or j=b or j=a goto 10
text (j*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,10,1)
if le=10 goto fin
11 ct=ct+1
k=int(ran(le))+1
if k=j or k=i or k=h or k=g or k=f or k=e or k=d or k=c or k=b or k=a goto 11
text (k*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,11,1)
if le=11 goto fin
12 ct=ct+1
l=int(ran(le))+1
if l=k or l=j or l=i or l=h or l=g or l=f or l=e or l=d or l=c or l=b or l=a goto 12
text (l*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,12,1)
if le=12 goto fin

13 ct=ct+1
m=int(ran(le))+1
if m=l or m=k or m=j or m=i or m=h or m=g or m=f or m=e or m=d or m=c or m=b or m=a goto 13
text (m*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,13,1)
if le=13 goto fin
14 ct=ct+1
n=int(ran(le))+1
if n=m or n=l or n=k or n=j or n=i or n=h or n=g or n=f or n=e or n=d or n=c or n=b or n=a goto 14
text (n*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,14,1)
if le=14 goto fin
15 ct=ct+1
o=int(ran(le))+1
if o=n or o=m or o=l or o=k or o=j or o=i or o=h or o=g or o=f or o=e or o=d or o=c or o=b or o=a goto 15
text (o*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,15,1)
if le=15 goto fin
16 ct=ct+1
p=int(ran(le))+1
if p=o or p=n or p=m or p=l or p=k or p=j or p=i or p=h or p=g or p=f or p=e or p=d or p=c or p=b or p=a goto 16
text (p*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,16,1)
if le=16 goto fin

17 ct=ct+1
q=int(ran(le))+1
if q=p or q=o or q=n or q=m or q=l or q=k or q=j or q=i or q=h or q=g or q=f or q=e or q=d or q=c or q=b or q=a goto 17
text (q*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,17,1)
if le=17 goto fin
18 ct=ct+1
r=int(ran(le))+1
if r=q or r=p or r=o or r=n or r=m or r=l or r=k or r=j or r=i or r=h or r=g or r=f or r=e or r=d or r=c or r=b or r=a goto 18
text (r*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,18,1)
if le=18 goto fin
19 ct=ct+1
s=int(ran(le))+1
if s=r or s=q or s=p or s=o or s=n or s=m or s=l or s=k or s=j or s=i or s=h or s=g or s=f or s=e or s=d or s=c or s=b or s=a goto 19
text (s*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,19,1)
if le=19 goto fin
20 ct=ct+1
t=int(ran(le))+1
if t=s or t=r or t=q or t=p or t=o or t=n or t=m or t=l or t=k or t=j or t=i or t=h or t=g or t=f or t=e or t=d or t=c or t=b or t=a goto 20
text (t*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,20,1)
if le=20 goto fin

21 ct=ct+1
u=int(ran(le))+1
if u=t or u=s or u=r or u=q or u=p or u=o or u=n or u=m or u=l or u=k or u=j or u=i or u=h or u=g or u=f or u=e or u=d or u=c or u=b or u=a goto 21
text (u*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,21,1)
if le=21 goto fin
22 ct=ct+1
v=int(ran(le))+1
if v=u or v=t or v=s or v=r or v=q or v=p or v=o or v=n or v=m or v=l or v=k or v=j or v=i or v=h or v=g or v=f or v=e or v=d or v=c or v=b or v=a goto 22
text (v*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,22,1)
if le=22 goto fin
23 ct=ct+1
w=int(ran(le))+1
if w=v or w=u or w=t or w=s or w=r or w=q or w=p or w=o or w=n or w=m or w=l or w=k or w=j or w=i or w=h or w=g or w=f or w=e or w=d or w=c or w=b or w=a goto 23
text (w*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,23,1)
if le=23 goto fin
24 ct=ct+1
x=int(ran(le))+1
if x=w or x=v or x=u or x=t or x=s or x=r or x=q or x=p or x=o or x=n or x=m or x=l or x=k or x=j or x=i or x=h or x=g or x=f or x=e or x=d or x=c or x=b or x=a goto 24
text (x*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,24,1)
if le=24 goto fin

25 ct=ct+1
y=int(ran(le))+1
if y=x or y=w or y=v or y=u or y=t or y=s or y=r or y=q or y=p or y=o or y=n or y=m or y=l or y=k or y=j or y=i or y=h or y=g or y=f or y=e or y=d or y=c or y=b or y=a goto 25
text (y*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,25,1)
if le=25 goto fin
26 ct=ct+1
z=int(ran(le))+1
if z=y or z=x or z=w or z=v or z=u or z=t or z=s or z=r or z=q or z=p or z=o or z=n or z=m or z=l or z=k or z=j or z=i or z=h or z=g or z=f or z=e or z=d or z=c or z=b or z=a goto 26
text (z*ac)+(((26-le)/2)*ac)+ab,aa,mid$(a$,26,1)
label fin
text 240,260,str$(ct)+" loop counts."
inkey$
goto again

Have a Yahappy day.
« Last Edit: February 07, 2007 by Clyde »
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: Letter Scrambler...
« Reply #1 on: February 07, 2007 »
Ok, I tried this, but it doesn't work.
What you should do when posting code is either put them between {code}{/code} **but square brackets**
This will make it look like:
Code: [Select]
THISOr you can attatch the text file by clicking on 'Additional Options...' at the bottom, and attatch the file.
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Re: Letter Scrambler...
« Reply #2 on: February 07, 2007 »
thanks, fixed a couple of glitches. Don't how to use the options, or what happens. Can barely get around windows.

Have a Yahappy day.
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Letter Scrambler...
« Reply #3 on: February 07, 2007 »
its just a matter of typing this without spaces before inserting the program - [ code ]
and this without spaces after the program - [ / code ]

I can't see anything happenin with this code did you not double buffer? The emulator doesnt like it when you dont double buffer I tried switchin buffers just before the clear window command but that did nothing

Challenge Trophies Won:

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Re: Letter Scrambler...
« Reply #4 on: February 07, 2007 »
fill in some letters into the speech marks at the top (a$), ie, your name, and keep hitting a key after that
to scramble the letters. This doesn't need buffering as it doesn't loop.

Have Yahappy day.
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Letter Scrambler...
« Reply #5 on: February 07, 2007 »
I see now you trim the string using mid$() I wouldve inserted spaces into the string and then use token$() so that the charictors become easy to work with, you could probably cut the number of lines down to a quarter of what they are now with that. I havent tried token on the emulator but I will check it out

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Letter Scrambler...
« Reply #6 on: February 07, 2007 »
Yeah token works perfect in the emulator heres a good way to split a string up into chars so that you can work with them easily

Code: [Select]
l$="abcdef"
chars = len(l$)

for c = 1 to chars
  a$ = left$(l$,(c-1)*2+1)
  b$ = right$(l$, chars-c)
  l$ = a$ + " " + b$
next

rem Token needs an array to store the charictors
dim words$(chars)
num = token(l$, words$())

rem Now you have each char stored to an entry in an array
for a = 1 to num
 print words$(a)
next a

Challenge Trophies Won:

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Re: Letter Scrambler...
« Reply #7 on: February 07, 2007 »
Thanks. I dabbled in tokens, but didn't apply it in any practical applications.
I said the code was crude. I was aware that it could be simplified, but didn't know how to at the time.
It's a great feeling when I have been able to simply some of my long-winded stuff.

Have a Yahappy day.

p.s just how does text get into the grey boxes?
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Letter Scrambler...
« Reply #8 on: February 07, 2007 »
Simple dude. All you need to do is put the word code in square brackets [ ] at the beginning of your listing, and at the end, a left slash / & code in more square brackets. In the example below take out the spaces, as i've had to use them to show you the formatting.

For example:

This is some code

would become:
[ code ]
This is some code
[ / code ]

Code: [Select]
This is some code
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Letter Scrambler...
« Reply #9 on: February 07, 2007 »
"just how does text get into the grey boxes?"

^ not for us to know

Challenge Trophies Won: