forums

TNT Basic Forums > Programming Q&A
Help with arrays...
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-26-2009 22:45

Posted by:
HarryCaray

Location:
Orlando, Fl

Find more posts by HarryCaray

I have an array containing 108 values and I'm trying to find a way to transfer those values into another array randomly, kind of like shuffling cards. Any idea of how to approach this?

04-26-2009 22:55

Posted by:
HarryCaray

Location:
Orlando, Fl

Find more posts by HarryCaray

I always feel like a fool when you figure out your own problem 5 minutes after you post.

04-29-2009 04:49

Posted by:
HarryCaray

Location:
Orlando, Fl

Find more posts by HarryCaray

Ok, turns out I do need help with this.

for a = 1 to 108
repeat
b = Random (1,108)
until deck <> 0
sdeck[a]=deck
deck=0
next a

This does what I want, but I'm thinking it gets stuck in the repeat loop, so the program doesn't continue after this. I've tried using breaks but I can't figure out how to incorporate it. Any ideas?

04-29-2009 17:34

Posted by:
JHVipond

Location:
South Dakota

Find more posts by JHVipond

Fast shuffle

Take a look at this code from COMPUTE! magazine, the June 1983 issue. It's written in Atari BASIC, but it can be used in TNT Basic with very few changes:

Atari Fast Shuffle

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.