Bits and Pieces

David Harry, West Midlands

 

Issue 6

Nov/Dec 83

Next Article >>

<< Prev Article

 

 

Here are a few bits and pieces which I hope you will find useful or interesting.

BRIEF IS BEAUTIFUL - If you learned your Basic from the book that came with your Atari and all the listings you have typed in from magazines have been printed by the error-free method of LOADing the program into the computer and LISTing it straight out to the printer, then you are probably still using PRINT, LIST, INPUT, etc., in your own programming. Most of the Basic Keywords have abbreviations which can save you time and effort when writing your own programs or typing in listings. Type in the following demo exactly as shown, don't change a single space or character, and then RUN it.

10GR.23:C.1:PL.3,1:DR.150,70:F.X=1T099: SO.1,X,14,8:N.X:GR.0:POS.15,7:?"INPUT A";:I.A:?:?A:GOS.20:L.:T.30:G.999:.! 20S0.1,0,0,0:RET. 30? :? "BYE! 

See what has happened? Your three lines have changed into five lines of program with only half the typing. Some points may not be immediately obvious. GR.23 is the same as GRAPHICS 7+16 and ? is the abbreviation for PRINT. In line 30 the Editor fills in the final quotation mark.

Line 10 shows a 50% saving in space, useful sometimes if you are trying to squeeze a lot of code into one FOR ... NEXT loop or trying to PLOT and DRAWTO several points on one line. There is a snag with abbreviations. If the LISTed line exceeds three physical lines on the screen, you can't edit the line and if you want to change it, you will have to type it all again. Try changing line 10 when you have LISTed it.

Abbreviations can be overdone but they are well worth learning. All the abbreviations are shown in Appendix A of your manual.

FOUR IN A ROW - Four in A Row from Issue 2 is an excellent program, but when you wish to replay your opponent, you have to enter both names in all over again. The following changes will make this unnecessary

Renumber line 30 as 306 and line 50 as 307, then delete lines 30, 50 and 80. Change line 1540 to IF NAME$="Y" THEN 7000 and add the following:

7000 CT=0:? "WHO PLAYS FIRST?":? " 1) ";NAME 1$;"?":? " 2) ";NAME2$;"?":? " 3) NEW PLAYERS?","ENTER 1/2/3"; 

7010 TRAP 7000:INPUT GO:ON GO GOTO 300 ,300,7020 7020 RUN

If you want the computer to play a stronger game then also change line 4400 to

4400 COLNO=INT(RND(1)*3)+INT(RND(1)*4) +1

This biases its moves towards the more tactically valuable central columns.

TINY TIP - If you are writing a game for two players and wish to transfer the turn from one player to another, you could use

10 IF PLAYER=1 THEN PLAYER=2:GOTO 30

20 PLAYER=1  

30 REM PLAYER NOW CHANGED

To save time and memory try using the following instead

18 PLAYER=3-PLAYER 

20 REM PLAYER NOW CHANGED

This will work on all games which have two players.

Has anyone else got any little Hints and Tips?

David Harry

top