Jump to content
IGNORED

Atari basic


Champions_2002

Recommended Posts

Hi there, with a new year i thought i would try and learn Atari basic, so iam trying to make a game, the problem is i have 11 boys names and 11 girls names, i want 11 randomdly names down one side and 11 randomdly down the other side, but i can not get this to work, does anybody know how to do this please..

Link to comment
Share on other sites

It has been a long time since I have messed with Atari Basic. You would use POSITION x,y then ? "HELLO WORLD" in GR.0 . In GR.1 or 2 (assuming you add 16 to the GR. mode to get rid of the text window on bottom) you would use POSITION x,y then PRINT #6;"HELLO WORLD". As far as string handling goes for the names , Atari Basic was much different than the Microsoft Basics. They were one dimension of varying length. There are many on here much more qualified than I that can do a better job of helping you .

 

There is some good info to be had here and over at Atari Archives

Edited by 777ismyname
Link to comment
Share on other sites

Hi there, with a new year i thought i would try and learn Atari basic, so iam trying to make a game, the problem is i have 11 boys names and 11 girls names, i want 11 randomdly names down one side and 11 randomdly down the other side, but i can not get this to work, does anybody know how to do this please..

 

Hmmm... it's been a while, but you could use data statements (my BASIC is rusty but it should give you some idea):

 

1000 DIM BOY$(20), GIRL$(20), NAME$(20)

1010 GRAPHICS 0

1020 REM MAIN LOOP FOR THE 11 NAMES

1030 FOR LOOP=1 TO 11

1040 REM OBTAIN RANDOM INDEX COUNTER

1040 BI=INT(RND(0)*11)+1

1050 GI=INT(RND(0)*11)+1

1060 REM SET THE DATA READ TO FIRST ONE

1070 RESTORE 1200

1075 REM START READING THE DATA

1080 FOR I=1 TO 22

1090 READ NAME$

1095 REM IF THE INDEX (I) = RANDOM NUMBER THEN MAKE THE STRING MATCH

1100 IF I=BI THEN BOY$=NAME$

1110 IF I=(GI+11) THEN GIRL$=NAME$

1120 NEXT I

1125 REM PRINT THE NAMES

1130 POSITION 0,LOOP: PRINT BOY$

1140 POSITION 20,LOOP: PRINT GIRLS$

1145 REM REPEAT 11 TIMES

1150 NEXT LOOP

1200 DATA BOY1, BOY2, BOY3, BOY4, BOY5, BOY6,BOY7, BOY8,BOY9,BOY10,BOY11

1210 DATA GIRL1, GIRL2, GIRL3, GIRL4, GIRL5, GIRL6, GIRL7, GIRL8,GIRL9, GIRL10,GIRL11

 

what we are doing here is using the data statements to hold the data. The generating random indexes for the statements we are making the random matching of the strings. There probably is a simpler way, but I can't think of it.

Edited by JayoK
Link to comment
Share on other sites

You could just DIMension a very large string that holds all of the names, then scramble them up and print accordingly. This one allows you to set name length, number of groups, etc.

I just whipped it together without trying it, so there might be glitches present.

 

0 GRAPHICS 0
5 REM SET UP VARIABLES
10 GROUPS = 2
20 NAMES = 11
30 MAXLENGTH = 10
40 SIZE = NAMES*GROUPS*MAXLENGTH
50 DIM NAME$(SIZE),TEMP$(MAXLENGTH)

55 REM INITIALIZE STRING
60 NAME$(1) = " " : NAME$(SIZE) = " " : NAME$(2) = NAME$
70 RESTORE 360
80 FOR J = 0 TO GROUPS-1
90 FOR I = (NAMES*J) TO (NAMES*J+NAMES-1)
100 READ TEMP$
110 NAME$(MAXLENGTH*I+1,MAXLENGTH*(I+1)) = TEMP$
120 NEXT I
130 NEXT J

135 REM RANDOMIZE STRING SECTIONS
140 FOR J = 0 TO (GROUPS-1)
150 FOR I = NAMES*J TO (NAMES*(J+1)-1)
160 GOSUB 300
170 NEXT I
180 NEXT J

185 REM PRINT COLUMNS OF NAMES
190 RESTORE 400
200 FOR J = 0 TO (GROUPS-1)
210 READ COLUMN
220 FOR I = 0 TO NAMES-1
230 K = I+J*NAMES
240 POKE 752,1 : REM CLEAR CURSOR
250 POSITION COLUMN,I
260 PRINT NAME$(MAXLENGTH*K+1,MAXLENGTH*(K+1))
270 NEXT I
280 NEXT J
290 POSITION 2,20 : END

295 REM SCRAMBLE NAMES SUBROUTINE
300 RANDOM = INT(RND(0)*NAMES)+(J*NAMES)
310 IF I = RANDOM THEN 300
320 TEMP$ = NAME$(MAXLENGTH*I+1)
330 NAME$(MAXLENGTH*I+1,MAXLENGTH*(I+1)) = NAME$(MAXLENGTH*RANDOM+1,MAXLENGTH*(RANDOM+1))
340 NAME$(MAXLENGTH*RANDOM+1,MAXLENGTH*(RANDOM+1)) = TEMP$
350 RETURN

355 REM GROUP 1 NAMES
360 DATA "BOY1","BOY2","BOY3","BOY4","BOY5"
370 DATA "BOY6","BOY7","BOY8","BOY9","BOY10","BOY11"

375 REM GROUP 2 NAMES
380 DATA "GIRL1","GIRL2","GIRL3","GIRL4","GIRL5"
390 DATA "GIRL6","GIRL7","GIRL8","GIRL9","GIRL10","GIRL11"

395 REM COLUMN POSITIONS
400 DATA 2,20

Edited by Nukey Shay
Link to comment
Share on other sites

Hi there, with a new year i thought i would try and learn Atari basic, so iam trying to make a game, the problem is i have 11 boys names and 11 girls names, i want 11 randomdly names down one side and 11 randomdly down the other side, but i can not get this to work, does anybody know how to do this please..

 

Hmmm... it's been a while, but you could use data statements (my BASIC is rusty but it should give you some idea):

 

1000 DIM BOY$(20), GIRL$(20), NAME$(20)

1010 GRAPHICS 0

1020 REM MAIN LOOP FOR THE 11 NAMES

1030 FOR LOOP=1 TO 11

1040 REM OBTAIN RANDOM INDEX COUNTER

1040 BI=INT(RND(0)*11)+1

1050 GI=INT(RND(0)*11)+1

1060 REM SET THE DATA READ TO FIRST ONE

1070 RESTORE 1200

1075 REM START READING THE DATA

1080 FOR I=1 TO 22

1090 READ NAME$

1095 REM IF THE INDEX (I) = RANDOM NUMBER THEN MAKE THE STRING MATCH

1100 IF I=BI THEN BOY$=NAME$

1110 IF I=(GI+11) THEN GIRL$=NAME$

1120 NEXT I

1125 REM PRINT THE NAMES

1130 POSITION 0,LOOP: PRINT BOY$

1140 POSITION 20,LOOP: PRINT GIRLS$

1145 REM REPEAT 11 TIMES

1150 NEXT LOOP

1200 DATA BOY1, BOY2, BOY3, BOY4, BOY5, BOY6,BOY7, BOY8,BOY9,BOY10,BOY11

1210 DATA GIRL1, GIRL2, GIRL3, GIRL4, GIRL5, GIRL6, GIRL7, GIRL8,GIRL9, GIRL10,GIRL11

 

what we are doing here is using the data statements to hold the data. The generating random indexes for the statements we are making the random matching of the strings. There probably is a simpler way, but I can't think of it.

 

That's great

 

How can i have it completely random, not all boys names on the left and not all the girls names on the right, but randomdly

Link to comment
Share on other sites

How can i have it completely random, not all boys names on the left and not all the girls names on the right, but randomdly

 

Possibly this - I am splitting out to help make sense, you could make this code tighter:

 

1125 REM PRINT THE NAMES

1126 SIDE = INT(RND(0))

1130 POSITION 0,LOOP

1131 IF SIDE=1 THEN PRINT BOY$

1132 IF SIDE=0 THNE PRINT GIRL$

1140 POSITION 20,LOOP

1141 IF SIDE=1 THEN PRINT GIRL$

1142 IF SIDE=0 THEN PRINT BOY$

.

.

.

Link to comment
Share on other sites

How can i have it completely random, not all boys names on the left and not all the girls names on the right, but randomdly

 

Possibly this - I am splitting out to help make sense, you could make this code tighter:

 

1125 REM PRINT THE NAMES

1126 SIDE = INT(RND(0))

1130 POSITION 0,LOOP

1131 IF SIDE=1 THEN PRINT BOY$

1132 IF SIDE=0 THNE PRINT GIRL$

1140 POSITION 20,LOOP

1141 IF SIDE=1 THEN PRINT GIRL$

1142 IF SIDE=0 THEN PRINT BOY$

.

.

.

 

thanks

 

Another problem that has accured is the same name appears twice, i do i get round this

Link to comment
Share on other sites

Looks like the random instructions don't account for names already picked in the loop. Might be easier using the long string approach I posted (NAMES = 22 : GROUPS = 1 at the top...but you want the printing routine to be split, so reset those variables to be NAMES = 11 : GROUPS = 2 before printing).

Link to comment
Share on other sites

Looks like the random instructions don't account for names already picked in the loop. Might be easier using the long string approach I posted (NAMES = 22 : GROUPS = 1 at the top...but you want the printing routine to be split, so reset those variables to be NAMES = 11 : GROUPS = 2 before printing).

 

Yeah the program I listed doesn't give consideration for names already done. As Nukey said you can use his example above with strings if you want this. Another option is no to randomise the reading of the names, but instead randomise the position on the screen. The use LOCATE to determine if it was already filled:

 

For example:

 

1000 FOR I=1 TO 22

1010 READ NAME$

1020 Y=INT(RND(0)*11)+1

1030 SIDE = INT(RND(0))

1040 IF SIDE=0 THEN X=0

1050 IF SIDE=1 THEN X=20

1060 LOCATE X,Y,A

1070 IF A<>" " THEN GOTO 1020

1080 POSITION X,Y

1090 PRINT NAME$

1100 NEXT I

 

Ok, so here's some inefficient code for you. Basically, this reads only one name at a time, but then attempts to find a random "free" position on the screen to put it. The problem here is that it could take ages to actually get the screen filled (as we wait for random to return the remaining values).

 

As possibly better option would be to fill an index table first with just numbers and then plot them, but I can only think of using this via POKE and PEEK (spent too long way at 6502 to think of another way)

Link to comment
Share on other sites

Another problem that has accured is the same name appears twice, i do i get round this

Try this:

10 GRAPHICS 0:DIM NAMES$(37):REM 37 is the sum of the names' lengths
20 NAMES$="CalebAaronGabrielJoshuaSamuelGuybrush"
30 NAMESNUM=5:SHOWNUM=4:REM NAMESNUM is the number of all names - 1; SHOWNUM is the number of names to display
40 DIM BEGINS(NAMESNUM),ENDS(NAMESNUM)
50 FOR I=0 TO NAMESNUM:READ BEGIN,END:BEGINS(I)=BEGIN:LET ENDS(I)=END:NEXT I
60 REM Pairs of numbers which mark the begin and end of each name in NAMES$
70 DATA 1,5,6,10,11,17,18,23,24,29,30,37
80 DIM VALUES(NAMESNUM)
90 FOR I=0 TO NAMESNUM:VALUES(I)=RND(0):NEXT I:REM Assign random value to each name
100 FOR I=1 TO SHOWNUM:MINVAL=VALUES(0):MINIDX=0
110 FOR J=1 TO NAMESNUM:REM Find name with the lowest value
120 IF VALUES(J)<MINVAL THEN MINVAL=VALUES(J):MINIDX=J
130 NEXT J:REM Name with the lowest value has index number MINIDX
140 POSITION 0,I:? NAMES$(BEGINS(MINIDX),ENDS(MINIDX))
150 VALUES(MINIDX)=1:REM Avoid the name being chosen again
160 NEXT I
170 REM Do the same for the girls

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...