+OLD CS1 Posted March 15, 2018 Share Posted March 15, 2018 As with Tiles, Laser Strike is another COMPUTE! Magazine type-in program published after the magazine dropped the TI-99/4A, and is another program for which I received permission to sell and distribute my conversion for the TI-99/4A. Laser Strike appears in COMPUTE! Magazine Issue 79, December 1986, Pp. 44-62. Article text here . ""Laser Strike" is a strategy game based on several popular board games (Battleship is probably the most famous). However, unlike the board games, the action in Laser Strike occurs in outer space. Two players secretly deploy their spaceships around the galaxy and then try to locate the opponent's ships by firing laser strikes on the two-dimensional galaxy grid. The first player to find and destroy all the opponent's ships is the winner." This post contains my 1988 versions. The first version has a rather simple A.I., which pokes around the board then follows a very simple search around looking for other parts of a hit ship. The second version has a very sinister A.I. which immediately knows where the rest of a ship is on the grid once it finds one. A computer player is created with a blank player name (just press ENTER when prompted for the player's name.) Over the next few months I will be working on cleaning and modernizing this program as I did with Tiles. A TidBit source, revamped over the ill-advised GCHAR method I use to build the "grids," including a more clandestine placing of computer player ships, and potentially a two-computer player-vs-player system via serial. The listings below contain CTRL characters which do not translate to text. TI BASIC Listing: LASERSTRIK 1 REM ** LASER STRIKE 2 REM * BY BARBARA SCHULAK 3 REM ** TI VERSION BY 4 REM ** ALAN RATELIFF II 5 REM ** AND (C) 1988 BY 6 REM ** ELECTRON INC. 7 REM ** PDD VERSION 1.0 8 RANDOMIZE 9 X(5)=19 10 X(6)=5 11 X(7)=16 12 X(=16 13 CALL CLEAR 14 CALL SCREEN(2) 15 DIM GRID(2,10,10) 16 GOSUB 209 17 FOR I=1 TO 8 18 CALL COLOR(I,16,1) 19 NEXT I 20 PRINT TAB(7);"LASER STRIKE"::: 21 FOR PLA=1 TO 2 22 PRINT "PLAYER ";STR$(PLA);" NAME ->"; 23 INPUT "":PR$(PLA) 24 IF PR$(PLA)<>"" THEN 26 25 PR$(PLA)="COMPUTER" 26 PRINT ::: 27 NEXT PLA 28 CALL CLEAR 29 PRINT " GRID 1 GRID 2":: 30 FOR I=1 TO 10 31 PRINT " €€€€€€€€€€ €€€€€€€€€€" 32 NEXT I 33 PRINT ::: 34 PRINT "MO SH ````` MO SH `````BOMBER hhhh BOMBER hhhh FIGHTER ppp FIGHTER ppp EXPLORERxx EXPLORERxx" 35 PO=5 36 PX=PO 37 PH=16 38 FOR I=1 TO 2 39 FOR J=1 TO 4 40 M$=PR$(I)&"," 41 R=1 42 C=3 43 GOSUB 234 44 M$="DEPLOY YOUR "&S$(J) 45 GOSUB 234 46 CALL GCHAR(PH,PX,CC) 47 IF PR$(I)="COMPUTER" THEN 239 48 CALL HCHAR(PH,PX,129) 49 CALL KEY(0,K,S) 50 IF S=0 THEN 49 51 CALL HCHAR(PH,PX,CC) 52 ON POS("SDEX ",CHR$(K),1)+1 GOTO 48,53,56,59,62,65 53 IF PX=PO THEN 48 54 PX=PX-1 55 GOTO 46 56 IF PX=PO+9 THEN 48 57 PX=PX+1 58 GOTO 46 59 IF PH=7 THEN 48 60 PH=PH-1 61 GOTO 46 62 IF PH=16 THEN 48 63 PH=PH+1 64 GOTO 46 65 IF CC<>128 THEN 46 66 CALL KEY(0,K,S) 67 IF PR$(I)="COMPUTER" THEN 69 68 IF S=0 THEN 66 ELSE 70 69 ON INT(RND*4)+1 GOTO 71,77,83,89 70 ON POS("SDEX",CHR$(K),1)+1 GOTO 66,71,77,83,89 71 FOR M=PX TO PX-LN(J)STEP -1 72 CALL GCHAR(PH,M,HK) 73 IF HK<>128 THEN 46 74 NEXT M 75 CALL HCHAR(PH,M+1,CH(J),LN(J)+1) 76 GOTO 94 77 FOR M=PX TO PX+LN(J) 78 CALL GCHAR(PH,M,HK) 79 IF HK<>128 THEN 46 80 NEXT M 81 CALL HCHAR(PH,PX,CH(J),LN(J)+1) 82 GOTO 94 83 FOR M=PH TO PH-LN(J)STEP -1 84 CALL GCHAR(M,PX,HK) 85 IF HK<>128 THEN 46 86 NEXT M 87 CALL VCHAR(M+1,PX,CH(J),LN(J)+1) 88 GOTO 94 89 FOR M=PH TO PH+LN(J) 90 CALL GCHAR(M,PX,HK) 91 IF HK<>128 THEN 46 92 NEXT M 93 CALL VCHAR(PH,PX,CH(J),LN(J)+1) 94 CALL HCHAR(2,3,32,28) 95 NEXT J 96 FOR VG=7 TO 16 97 FOR HG=0 TO 9 98 CALL GCHAR(VG,HG+PO,HK) 99 ON POS("`hpx€",CHR$(HK),1)GOTO 100,102,104,106,108 100 GRID(I,VG-6,HG+1)=4 101 GOTO 109 102 GRID(I,VG-6,HG+1)=3 103 GOTO 109 104 GRID(I,VG-6,HG+1)=2 105 GOTO 109 106 GRID(I,VG-6,HG+1)=1 107 GOTO 109 108 GRID(I,VG-6,HG+1)=0 109 NEXT HG 110 NEXT VG 111 FOR HH=7 TO 16 112 CALL HCHAR(HH,PO,128,10) 113 NEXT HH 114 PO=19 115 PX=PO 116 PH=16 117 CALL HCHAR(1,3,32,58) 118 NEXT I 119 PA=1 120 M$=PR$(PA)&"," 121 R=1 122 GOSUB 234 123 M$="POSITION AND FIRE LASER" 124 GOSUB 234 125 ON PA GOTO 126,130 126 PO=19 127 PX=19 128 PH=16 129 GOTO 133 130 PO=5 131 PX=5 132 PH=16 133 CALL GCHAR(PH,PX,CC) 134 IF PR$(PA)="COMPUTER" THEN 242 135 CALL HCHAR(PH,PX,129) 136 CALL KEY(0,K,S) 137 IF S=0 THEN 136 138 CALL HCHAR(PH,PX,CC) 139 ON POS("SDEX ",CHR$(K),1)+1 GOTO 135,140,143,146,149,152 140 IF PX=PO THEN 135 141 PX=PX-1 142 GOTO 133 143 IF PX=PO+9 THEN 135 144 PX=PX+1 145 GOTO 133 146 IF PH=7 THEN 135 147 PH=PH-1 148 GOTO 133 149 IF PH=16 THEN 135 150 PH=PH+1 151 GOTO 133 152 IF CC<>128 THEN 133 153 CALL HCHAR(1,3,32,60) 154 PK=PA-1-2*(PA=1) 155 ON GRID(PK,PH-6,(PX-PO)+1)+1 GOTO 176,171,166,161,156 156 M$="MOTHER SHIP HIT ! !" 157 R=2 158 GOSUB 234 159 CALL HCHAR(PH,PX,96) 160 GOTO 185 161 M$="BOMBER HIT ! !" 162 R=2 163 GOSUB 234 164 CALL HCHAR(PH,PX,104) 165 GOTO 185 166 M$="FIGHTER HIT ! !" 167 R=2 168 GOSUB 234 169 CALL HCHAR(PH,PX,112) 170 GOTO 185 171 M$="EXPLORER HIT ! !" 172 R=2 173 GOSUB 234 174 CALL HCHAR(PH,PX,120) 175 GOTO 185 176 M$="MISS ! !" 177 R=2 178 PA=PK 179 GOSUB 234 180 CALL HCHAR(PH,PX,130) 181 FOR LK=2555 TO 100 STEP -100 182 CALL SOUND(-100,LK,0) 183 NEXT LK 184 GOTO 120 185 FOR LK=0 TO 30 STEP 2 186 CALL SOUND(250,-7,LK) 187 NEXT LK 188 CALL HCHAR(2,3,32,28) 189 BU(PK)=BU(PK)+1 190 PA=PK 191 GRID(PK,PH-6,(PX-PO)+1)=-1 192 IF BU(PK)<14 THEN 120 193 M$=PR$(PA-1-2*(PA=1))&" HAS" 194 R=1 195 GOSUB 234 196 M$="SAVED THE GALAXY ! !" 197 GOSUB 234 198 M$="PLAY AGAIN (Y/N)?" 199 R=4 200 GOSUB 234 201 CALL KEY(0,K,S) 202 IF S=0 THEN 201 203 IF CHR$(K)="N" THEN 207 204 BU(1)=0 205 BU(2)=0 206 GOTO 28 207 CALL CLEAR 208 END 209 READ C$ 210 FOR I=96 TO 120 STEP 8 211 CALL CHAR(I,C$) 212 NEXT I 213 READ C$,C2$,C3$ 214 CALL CHAR(128,C$) 215 CALL CHAR(129,C2$) 216 CALL CHAR(130,C3$) 217 FOR I=9 TO 13 218 READ C 219 CALL COLOR(I,C,16) 220 NEXT I 221 FOR J=1 TO 2 222 MS(J)=5 223 BR(J)=4 224 FR(J)=3 225 EX(J)=2 226 NEXT J 227 FOR I=1 TO 4 228 READ S$(I) 229 NEXT I 230 READ LN(1),LN(2),LN(3),LN(4),CH(1),CH(2),CH(3),CH(4) 231 RETURN 232 DATA 007E7E7E7E7E7E,007E7E7E7E7E7E,007E7E66667E7E,00666600006666,7,11,5,4,2, MOTHER SHIP,BOMBER,FIGHTER,EXPLORER,4,3,2,1,96 233 DATA 104,112,120 234 FOR AA=0 TO LEN(M$)-1 235 CALL HCHAR(R,C+AA,ASC(SEG$(M$,AA+1,1))) 236 NEXT AA 237 R=R+1 238 RETURN 239 PX=INT(RND*10)+PO 240 PH=16-INT(RND*10) 241 GOTO 65 242 PX=INT(10*RND)+PO 243 PK=PA-1-2*(PA=1) 244 PH=16-INT(RND*10) 245 IF GRID(PK,X(6+PA)-6,(X(4+PA)-PO)+1)>-1 THEN 253 246 PH=X(6+PA) 247 PX=X(4+PA) 248 LC=LC+1 249 IF LC<6 THEN 253 250 PX=INT(RND*10)+PO 251 PH=16-INT(RND*10) 252 LC=0 253 IF GRID(PK,PH-6,(PX-PO)+1)>0 THEN 280 254 IF PH+1>16 THEN 256 255 X(1)=GRID(PK,PH-5,(PX-PO)+1) 256 IF PH-1<7 THEN 258 257 X(2)=GRID(PK,PH-7,(PX-PO)+1) 258 IF PX+1>PO+9 THEN 260 259 X(3)=GRID(PK,PH-6,(PX-PO)+2) 260 IF PX-1<PO THEN 262 261 X(4)=GRID(PK,PH-6,PX-PO) 262 IF ((X(1)<1)*(X(2)<1)*(X(3)<1)*(X(4)<1))THEN 280 263 IF X(1)>0 THEN 268 264 IF X(2)>0 THEN 271 265 IF X(3)>0 THEN 274 266 IF X(4)>0 THEN 277 267 ON INT(RND*4)+1 GOTO 268,271,274,277 268 IF X(1)=0 THEN 267 269 PH=PH+1 270 GOTO 287 271 IF X(2)=0 THEN 267 272 PH=PH-1 273 GOTO 287 274 IF X(3)=0 THEN 267 275 PX=PX+1 276 GOTO 287 277 IF X(4)=0 THEN 267 278 PX=PX-1 279 GOTO 287 280 FOR XE=1 TO 4 281 X(XE)=0 282 NEXT XE 283 CALL GCHAR(PH,PX,CC) 284 X(4+PA)=PX 285 X(6+PA)=PH 286 GOTO 152 287 IF GRID(PK,PH-6,(PX-PO)+1)=-1 THEN 253 ELSE 280 288 AP=AP+8 289 GOSUB 288 TI BASIC Listing: LASERSTRK+ (sinister A.I.) 1 REM ** LASER STRIKE 2 REM * BY BARBARA SCHULAK 3 REM ** TI VERSION BY 4 REM ** ALAN RATELIFF II 5 REM ** AND (C) 1988 BY 6 REM ** ELECTRON INC. 7 REM ** PDD VERSION 1.1 8 RANDOMIZE 9 CALL CLEAR 10 CALL SCREEN(2) 11 DIM GRID(2,10,10) 12 GOSUB 258 13 FOR I=1 TO 8 14 CALL COLOR(I,16,1) 15 NEXT I 16 PRINT TAB(7);"LASER STRIKE"::: 17 FOR PLA=1 TO 2 18 PRINT "PLAYER ";STR$(PLA);" NAME ->"; 19 INPUT "":PR$(PLA) 20 IF PR$(PLA)<>"" THEN 22 21 PR$(PLA)="COMPUTER" 22 PRINT ::: 23 NEXT PLA 24 CALL CLEAR 25 PRINT " GRID 1 GRID 2":: 26 FOR I=1 TO 10 27 PRINT " €€€€€€€€€€ €€€€€€€€€€" 28 NEXT I 29 PRINT ::: 30 PRINT "MO SH ````` MO SH `````BOMBER hhhh BOMBER hhhh FIGHTER ppp FIGHTER ppp EXPLORERxx EXPLORERxx" 31 PO=5 32 PX=PO 33 PH=16 34 FOR I=1 TO 2 35 FOR J=1 TO 4 36 M$=PR$(I)&"," 37 R=1 38 C=3 39 GOSUB 283 40 M$="DEPLOY YOUR "&S$(J) 41 GOSUB 283 42 CALL GCHAR(PH,PX,CC) 43 IF PR$(I)="COMPUTER" THEN 288 44 CALL HCHAR(PH,PX,129) 45 CALL KEY(0,K,S) 46 IF S=0 THEN 45 47 CALL HCHAR(PH,PX,CC) 48 ON POS("SDEX ",CHR$(K),1)+1 GOTO 44,49,52,55,58,61 49 IF PX=PO THEN 44 50 PX=PX-1 51 GOTO 42 52 IF PX=PO+9 THEN 44 53 PX=PX+1 54 GOTO 42 55 IF PH=7 THEN 44 56 PH=PH-1 57 GOTO 42 58 IF PH=16 THEN 44 59 PH=PH+1 60 GOTO 42 61 IF CC<>128 THEN 42 62 CALL KEY(0,K,S) 63 IF PR$(I)="COMPUTER" THEN 65 64 IF S=0 THEN 62 ELSE 66 65 ON INT(RND*4)+1 GOTO 67,73,79,85 66 ON POS("SDEX",CHR$(K),1)+1 GOTO 62,67,73,79,85 67 FOR M=PX TO PX-LN(J)STEP -1 68 CALL GCHAR(PH,M,HK) 69 IF HK<>128 THEN 42 70 NEXT M 71 CALL HCHAR(PH,M+1,CH(J),LN(J)+1) 72 GOTO 90 73 FOR M=PX TO PX+LN(J) 74 CALL GCHAR(PH,M,HK) 75 IF HK<>128 THEN 42 76 NEXT M 77 CALL HCHAR(PH,PX,CH(J),LN(J)+1) 78 GOTO 90 79 FOR M=PH TO PH-LN(J)STEP -1 80 CALL GCHAR(M,PX,HK) 81 IF HK<>128 THEN 42 82 NEXT M 83 CALL VCHAR(M+1,PX,CH(J),LN(J)+1) 84 GOTO 90 85 FOR M=PH TO PH+LN(J) 86 CALL GCHAR(M,PX,HK) 87 IF HK<>128 THEN 42 88 NEXT M 89 CALL VCHAR(PH,PX,CH(J),LN(J)+1) 90 CALL HCHAR(2,3,32,28) 91 NEXT J 92 FOR VG=7 TO 16 93 FOR HG=0 TO 9 94 CALL GCHAR(VG,HG+PO,HK) 95 ON POS("`hpx€",CHR$(HK),1)GOTO 96,98,100,102,104 96 GRID(I,VG-6,HG+1)=4 97 GOTO 105 98 GRID(I,VG-6,HG+1)=3 99 GOTO 105 100 GRID(I,VG-6,HG+1)=2 101 GOTO 105 102 GRID(I,VG-6,HG+1)=1 103 GOTO 105 104 GRID(I,VG-6,HG+1)=0 105 NEXT HG 106 NEXT VG 107 FOR HH=7 TO 16 108 CALL HCHAR(HH,PO,128,10) 109 NEXT HH 110 PO=19 111 PX=PO 112 PH=16 113 CALL HCHAR(1,3,32,58) 114 NEXT I 115 PA=1 116 M$=PR$(PA)&"," 117 R=1 118 GOSUB 283 119 M$="POSITION AND FIRE LASER" 120 GOSUB 283 121 ON PA GOTO 122,126 122 PO=19 123 PX=19 124 PH=16 125 GOTO 129 126 PO=5 127 PX=5 128 PH=16 129 CALL GCHAR(PH,PX,CC) 130 IF PR$(PA)="COMPUTER" THEN 291 131 CALL HCHAR(PH,PX,129) 132 CALL KEY(0,K,S) 133 IF S=0 THEN 132 134 CALL HCHAR(PH,PX,CC) 135 ON POS("SDEX ",CHR$(K),1)+1 GOTO 131,136,139,142,145,148 136 IF PX=PO THEN 131 137 PX=PX-1 138 GOTO 129 139 IF PX=PO+9 THEN 131 140 PX=PX+1 141 GOTO 129 142 IF PH=7 THEN 131 143 PH=PH-1 144 GOTO 129 145 IF PH=16 THEN 131 146 PH=PH+1 147 GOTO 129 148 IF CC<>128 THEN 129 149 CALL HCHAR(1,3,32,60) 150 PK=PA-1-2*(PA=1) 151 ON GRID(PK,PH-6,(PX-PO)+1)+1 GOTO 216,200,184,168,152 152 M$="MOTHER SHIP HIT ! !" 153 IF MS(PK)-1>0 THEN 155 154 M$="MOTHER SHIP DESTROYED ! !" 155 R=2 156 ON PK GOTO 157,159 157 CALL HCHAR(20,11,32,5) 158 GOTO 160 159 CALL HCHAR(20,26,32,5) 160 GOSUB 283 161 MS(PK)=MS(PK)-1 162 CALL HCHAR(PH,PX,96) 163 ON PK GOTO 164,166 164 CALL HCHAR(20,11,96,MS(1)) 165 GOTO 167 166 CALL HCHAR(20,26,96,MS(2)) 167 GOTO 225 168 M$="BOMBER HIT ! !" 169 BR(PK)=BR(PK)-1 170 IF BR(PK)>0 THEN 172 171 M$="BOMBER DESTROYED ! !" 172 R=2 173 ON PK GOTO 174,176 174 CALL HCHAR(21,11,32,5) 175 GOTO 177 176 CALL HCHAR(21,26,32,5) 177 GOSUB 283 178 CALL HCHAR(PH,PX,104) 179 ON PK GOTO 180,182 180 CALL HCHAR(21,11,104,BR(1)) 181 GOTO 183 182 CALL HCHAR(21,26,104,BR(2)) 183 GOTO 225 184 M$="FIGHTER HIT ! !" 185 FR(PK)=FR(PK)-1 186 IF FR(PK)>0 THEN 188 187 M$="FIGHTER DESTROYED ! !" 188 R=2 189 ON PK GOTO 190,192 190 CALL HCHAR(22,11,32,5) 191 GOTO 193 192 CALL HCHAR(22,26,32,5) 193 GOSUB 283 194 CALL HCHAR(PH,PX,112) 195 ON PK GOTO 196,198 196 CALL HCHAR(22,11,112,FR(1)) 197 GOTO 199 198 CALL HCHAR(22,26,112,FR(2)) 199 GOTO 225 200 M$="EXPLORER HIT ! !" 201 EX(PK)=EX(PK)-1 202 IF EX(PK)>0 THEN 204 203 M$="EXPLORER DESTROYED ! !" 204 R=2 205 ON PK GOTO 206,208 206 CALL HCHAR(23,11,32,5) 207 GOTO 209 208 CALL HCHAR(23,26,32,5) 209 GOSUB 283 210 CALL HCHAR(PH,PX,120) 211 ON PK GOTO 212,214 212 CALL HCHAR(23,11,120,EX(1)) 213 GOTO 215 214 CALL HCHAR(23,26,120,EX(2)) 215 GOTO 225 216 M$="MISS ! !" 217 R=2 218 PA=PK 219 GOSUB 283 220 CALL HCHAR(PH,PX,130) 221 FOR LK=2555 TO 100 STEP -100 222 CALL SOUND(-100,LK,0) 223 NEXT LK 224 GOTO 116 225 FOR LK=0 TO 30 STEP 2 226 CALL SOUND(250,-7,LK) 227 NEXT LK 228 CALL HCHAR(2,3,32,28) 229 BU(PK)=BU(PK)+1 230 PA=PK 231 GRID(PK,PH-6,(PX-PO)+1)=-1 232 IF BU(PK)<14 THEN 116 233 M$=PR$(PA-1-2*(PA=1))&" HAS" 234 R=1 235 GOSUB 283 236 M$="SAVED THE GALAXY ! !" 237 GOSUB 283 238 M$="PLAY AGAIN (Y/N)?" 239 R=4 240 GOSUB 283 241 CALL KEY(0,K,S) 242 KC=KC+1 243 IF (PR$(1)="COMPUTER")*(PR$(2)=PR$(1))*(KC>1250)THEN 246 244 IF S=0 THEN 241 245 IF CHR$(K)="N" THEN 256 246 BU(1)=0 247 KC=0 248 BU(2)=0 249 FOR JJ=1 TO 2 250 MS(JJ)=5 251 BR(JJ)=4 252 FR(JJ)=3 253 EX(JJ)=2 254 NEXT JJ 255 GOTO 24 256 CALL CLEAR 257 END 258 READ C$ 259 FOR I=96 TO 120 STEP 8 260 CALL CHAR(I,C$) 261 NEXT I 262 READ C$,C2$,C3$ 263 CALL CHAR(128,C$) 264 CALL CHAR(129,C2$) 265 CALL CHAR(130,C3$) 266 FOR I=9 TO 13 267 READ C 268 CALL COLOR(I,C,16) 269 NEXT I 270 FOR J=1 TO 2 271 MS(J)=5 272 BR(J)=4 273 FR(J)=3 274 EX(J)=2 275 NEXT J 276 FOR I=1 TO 4 277 READ S$(I) 278 NEXT I 279 READ LN(1),LN(2),LN(3),LN(4),CH(1),CH(2),CH(3),CH(4) 280 RETURN 281 DATA 007E7E7E7E7E7E,007E7E7E7E7E7E,007E7E66667E7E,00666600006666,7,11,5,4,2, MOTHER SHIP,BOMBER,FIGHTER,EXPLORER,4,3,2,1,96 282 DATA 104,112,120 283 FOR AA=0 TO LEN(M$)-1 284 CALL HCHAR(R,C+AA,ASC(SEG$(M$,AA+1,1))) 285 NEXT AA 286 R=R+1 287 RETURN 288 PX=INT(RND*10)+PO 289 PH=16-INT(RND*10) 290 GOTO 61 291 REM ** COMPUTER'S TURN 292 PK=PA-1-2*(PA=1) 293 FOR HG=7 TO 16 294 FOR VG=PO TO PO+9 295 IF GRID(PK,HG-6,(VG-PO)+1)=-1 THEN 299 296 NEXT VG 297 NEXT HG 298 GOTO 323 299 IF VG+1>PO+9 THEN 301 300 X(1)=GRID(PK,HG-6,(VG-PO)+2) 301 IF VG-1<PO THEN 303 302 X(2)=GRID(PK,HG-6,VG-PO) 303 IF HG+1>16 THEN 305 304 X(3)=GRID(PK,HG-5,(VG-PO)+1) 305 IF HG-1<7 THEN 307 306 X(4)=GRID(PK,HG-7,(VG-PO)+1) 307 IF (X(1)<1)*(X(2)<1)*(X(3)<1)*(X(4)<1)THEN 296 308 PX=VG 309 PH=HG 310 ON INT(RND*4)+1 GOTO 311,314,317,320 311 IF X(1)<1 THEN 310 312 PX=PX+1 313 GOTO 325 314 IF X(2)<1 THEN 310 315 PX=PX-1 316 GOTO 325 317 IF X(3)<1 THEN 310 318 PH=PH+1 319 GOTO 325 320 IF X(4)<1 THEN 310 321 PH=PH-1 322 GOTO 325 323 PH=16-INT(RND*10) 324 PX=INT(RND*10)+PO 325 FOR XE=1 TO 4 326 X(XE)=0 327 NEXT XE 328 CALL GCHAR(PH,PX,CC) 329 GOTO 148 330 AP=AP+8 331 GOSUB 330 LASERSTRIKE.zip 6 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted March 16, 2018 Author Share Posted March 16, 2018 I just noticed the last two lines of each program is a simple memory sizer for TI BASIC. An old trick I picked up from a newsletter which came from some magazine. If you RUN 288 or RUN 330 the variable AP will increase by 8 until the stack fills up with entries from the following GOSUB. Then PRINT AP and you will get the number of available bytes: 2248 for the first version, 1440 for the second. 5 Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 16, 2018 Share Posted March 16, 2018 Cool trick! Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted March 16, 2018 Author Share Posted March 16, 2018 For comparison: Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted March 28, 2018 Author Share Posted March 28, 2018 Here is a Tidbit snippet showing the ridiculous ways I tend to get complex trying to avoid redundant or repeating sections, IF-THENs, and branches. This shit is what drives me nuts writing programs and why I could not do this professionally as I obsess and agonize over a short section for hours or days. FOR Y=R+(5-I)*(J=4) TO R-(5-I)*(J=3) // Check horizontal spacing IF (Y<1)+(Y>10)+G(P,ABS(Y),C) THEN DeployError // ABS() fixes negative subscript during OR operation NEXT Y FOR X=C+(5-I)*(J=1) TO C-(5-I)*(J=2) // Check vertical spacing IF (X<1)+(X>10)+G(P,R,ABS(X)) THEN DeployError // ABS() fixes negative subscript during OR operation NEXT X CALL VCHAR(8+R+(5-I)*(J=4),C-10+14*P,104+8*I,(I-6)*(J>2)) CALL HCHAR(8+R,C+(5-I)*(J=1)-10+14*P,104+8*I,(I-6)*(J<3)) The most painful discovery and wrench in my progress was that FOR-NEXT-STEP does not accept "0" as a STEP. Makes perfect sense but I was thinking a zero STEP would just cause the loop to be skipped. There are other sections which are vexing me but I am breaking them up. I have added a couple of "features" which have made things a little more complex, but I have also removed some things which have made program, like that above, less complex. One removed feature of my conversion is the ability to lay a ship in any direction from the marker, whereas the original game only let you lay it RIGHT or DOWN, both positive directions. That HCHAR and VCHAR will put out nothing if the repeat value is zero meant I could try to plot in both directions without using an IF-THEN statement and the execution penalty was negligible for this section. Ultimately a wiser decision was made and this trick, while really cool, is no longer used. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted March 28, 2018 Author Share Posted March 28, 2018 Here is something REALLY weird I ran into tonight testing the "AI" for deploying computer ships in Classic99. This section of program: DeployComputerShip: RANDOMIZE R=INT(RND*10)+1 C=INT(RND*10)+1 ON INT(RND*2)+1 GOSUB DeployXCheck,DeployYCheck IF G(P,R,C)<>I THEN DeployComputerShip ELSE DeployNextShip without the RANDOMIZE statement produces the EXACT SAME results for both computer players -- that is, both player's ships are laid in exactly the same positions -- every time the program is run. There is a RANDOMIZE statement earlier in the program in the execution path so I do not expect this behavior. I have no idea if this behaves the same way on metal. What gives? Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted April 3, 2018 Author Share Posted April 3, 2018 All parts of game setup and play are completed including the introduction marquee. All that remains is the AI and I will be done, much to relief of those around me as my time and thoughts are consumed with this project. I have had a revelation while reworking this program: I am tired of TI BASIC. When I originally wrote these programs all I had was a console and a tape drive. Thus such configuration was my target audience should these ever be published. It was also a challenge to do some of the stuff these more advanced BASICs of other computers could do. Now, however, Extended BASIC makes the limitations of BASIC just plain aggravating, and that is notwithstanding assembly language. I have four more programs which need to be redone, all of them originally written in TI BASIC and one of which took advantage of capabilities offered by MiniMemory in BASIC with an alternate version which also leveraged some assembly routines. I have not yet decided if I will rework them all in TI BASIC or Extended BASIC. The idea originally was to make them as "type-in friendly" as possible. I would still like to meet that if only for nostalgia, otherwise right now TI BASIC is not fun to me; it is frustrating and I am getting to the point where I never want to fire up BASIC, again. If you want to see how it looks right now without the AI -- any computer player will fall through to human player -- see below. I believe it works exactly as desired as a two-player game in its current form. It can be pasted into Classic99. EXSD for Player 1, IMJK for Player 2, SPACE for both, joysticks work, too. Ships will be deployed onto your opponent's grid. That is, Player 1 deploys onto GRID 2, and vice-versa. When deploying the "plus" mark indicates to select a direction, right or down. 1 REM ** LASER STRIKE 2 REM * BY BARBARA SCHULAK 3 REM ** (C) 1988 COMPUTE! 4 REM ** PUBLICATIONS INC. 5 REM ** TI CONVERSIONS 6 REM ** (C) 1988,2018 7 REM ** ALAN RATELIFF,II 8 REM ** BASIC/EXT BASIC 9 REM ** PDD VERSION 2.5 10 CALL CLEAR 11 PRINT "ORIGINAL VERSION OF":"""LASER STRIKE"" USED WITH PERMISSION OF": : 12 PRINT "COMPUTE! PUBLICATIONS, INC. PO BOX 5406":"GREENSBORO NC 27403": : 13 PRINT "COPYRIGHT 1988 COMPUTE!":"PUBLICATIONS, INC.":"ALL RIGHTS RESERVED": : 14 PRINT "TEXAS INSTRUMENTS CONVERSIONCOPYRIGHT 1988, 2018 BY":"ALAN W. RATELIFF, II": 15 DIM G(2,10,10),P$(2),K$(1) 16 FOR I=1 TO 1250 17 NEXT I 18 GOTO 91 19 J=0 20 CALL KEY(ABS(P),K,S) 21 IF S THEN 22 ELSE 25 22 J=POS(K$(0),CHR$(K),1) 23 IF J=0 THEN 27 24 RETURN 25 CALL JOYST(ABS(P),X,Y) 26 IF X+Y THEN 32 27 CALL KEY(3,K,S) 28 IF S THEN 29 ELSE 31 29 J=4+POS(K$(1),CHR$(K),1) 30 J=J*-(J>4) 31 RETURN 32 IF SGN(X)*SGN(Y)THEN 30 33 J=ABS(((SGN(X)+3)/2)*SGN(X))+(ABS(((SGN(Y)+3)/2)*SGN(Y))-2*(Y<>0)) 34 RETURN 35 Y=POS(M$,":",1) 36 X=Y-(LEN(M$)*(Y=0))+(Y>0) 37 CALL HCHAR(R,C+2,32,28-C) 38 FOR M=1 TO X 39 CALL HCHAR(R,C+M+1,ASC(SEG$(M$,M,1))) 40 NEXT M 41 R=R+1 42 IF Y=0 THEN 45 43 M$=SEG$(M$,Y+1,84) 44 GOTO 35 45 RETURN 46 CALL COLOR(9-(P<0),2,17-ABS(P)) 47 CALL COLOR(10+(P<0),2,14+ABS(P)) 48 RETURN 49 Z=P-3*(P<0) 50 FOR I=0 TO 9 51 CALL HCHAR(9+I,14*Z-9,88+8*Z,10) 52 NEXT I 53 RETURN 54 R=G(ABS(P),0,5) 55 C=G(ABS(P),0,6) 56 RETURN 57 G(ABS(P),0,5)=R 58 G(ABS(P),0,6)=C 59 RETURN 60 Z=G(P-3*(P<0),R,C) 61 M=104-ABS(Z)*8*((Z<0)+(P<0))-8*(2-(P-3*(P<0)))*((Z>0)*(P>0)-(Z=0)) 62 CALL HCHAR(8+R,14*P-10-42*(P<0)+C,M+1) 63 GOSUB 19 64 IF J=0 THEN 63 65 IF J>4 THEN 70 66 CALL HCHAR(8+R,14*P-10-42*(P<0)+C,M-2*(Z=5)) 67 R=R+((J=3)*(R<10))-((J=4)*(R>1)) 68 C=C+((J=2)*(C<10))-((J=1)*(C>1)) 69 GOTO 60 70 RETURN 71 IF R+(5-I)>10 THEN 80 72 FOR Y=R TO R+(5-I) 73 IF G(P+3,Y,C) THEN 80 74 NEXT Y 75 FOR Y=R TO R+(5-I) 76 G(P+3,Y,C)=I 77 NEXT Y 78 IF G(-P,0,0) THEN 80 79 CALL VCHAR(8+R,C+32+14*P,104+8*I,6-I) 80 RETURN 81 IF C+(5-I)>10 THEN 80 82 FOR X=C TO C+(5-I) 83 IF G(P+3,R,X) THEN 80 84 NEXT X 85 FOR X=C TO C+(5-I) 86 G(P+3,R,X)=I 87 NEXT X 88 IF G(-P,0,0) THEN 80 89 CALL HCHAR(8+R,C+32+14*P,104+8*I,6-I) 90 RETURN 91 CALL SCREEN(2) 92 CALL CLEAR 93 CALL VCHAR(1,31,31,96) 94 CALL COLOR(1,2,2) 95 FOR I=2 TO 8 96 CALL COLOR(I,1,2) 97 NEXT I 98 M$="LASER STRIKE " 99 FOR I=1 TO 13 100 CALL SOUND(-200,-5,2*(13-I)) 101 CALL SCREEN(3+I) 102 CALL HCHAR(12,10+I,ASC(SEG$(M$,I,1))) 103 NEXT I 104 FOR I=1 TO 8 105 CALL COLOR(I,16,2) 106 NEXT I 107 CALL SCREEN(2) 108 K$(0)=CHR$(2)&CHR$(3)&CHR$(0)&CHR$(5)&CHR$(18) 109 K$(1)=" " 110 S$="MOTHERSHIP BOMBER FIGHTER EXPLORER " 111 FOR I=96 TO 136 STEP 8 112 CALL CHAR(I+0,"007E7E7E7E7E7E") 113 CALL CHAR(I+1,"007E7E66667E7E") 114 CALL CHAR(I+2,"00666600006666") 115 NEXT I 116 FOR I=0 TO 8 STEP 8 117 RESTORE 130 118 FOR J=0 TO 3 119 READ M$ 120 CALL CHAR(99+J+I,M$) 121 NEXT J 122 READ M$ 123 CALL CHAR(103+I,SEG$(M$,I*2+1,16)) 124 NEXT I 125 RANDOMIZE 126 FOR I=9 TO 14 127 READ J 128 CALL COLOR(I,J,16) 129 NEXT I 130 DATA FFC3BFBFA3BBBBC7,FF87BBBB87AFB7BB,FFC7EFEFEFEFEFC7,FF87DBDBDBDBDB87 131 DATA FFEFCFEFEFEFEFC7FFC7BBFBF7EFDF83 132 DATA 2,2,7,11,5,4 133 FOR P=1 TO 2 134 PRINT "PLAYER";P;"NAME? "; 135 CALL KEY(3,K,S) 136 INPUT "":P$(P) 137 G(P,0,0)=-(P$(P)="") 138 P$(P)=SEG$("COMPUTER"&P$(P),9-8*G(P,0,0),10-2*(G(P,0,0))) 139 PRINT 140 NEXT P 141 CALL CLEAR 142 FOR C=1 TO 16 STEP 15 143 M$="MTHRSHIP: BOMBER: FIGHTER:EXPLORER" 144 R=21 145 GOSUB 35 146 NEXT C 147 FOR I=0 TO 4 148 J=I-(I=4) 149 CALL HCHAR(7,7+J,99+I) 150 CALL HCHAR(7,21+J,107+I) 151 NEXT I 152 FOR I=1 TO 4 153 CALL HCHAR(I,3,32,28) 154 G(1,0,I)=6-I 155 G(2,0,I)=6-I 156 CALL HCHAR(20+I,11,104+I*8,6-I) 157 CALL HCHAR(20+I,26,104+I*8,6-I) 158 NEXT I 159 FOR P=1 TO 2 160 FOR I=1 TO 10 161 FOR J=1 TO 10 162 G(P,I,J)=0 163 NEXT J 164 NEXT I 165 G(P,0,5)=1 166 G(P,0,6)=1 167 GOSUB 49 168 NEXT P 169 FOR P=-1 TO -2 STEP -1 170 GOSUB 46 171 M$=P$(-P)&",:DEPLOY YOUR" 172 R=1 173 C=1 174 GOSUB 35 175 FOR I=1 TO 4 176 IF G(-P,0,0)=0 THEN 187 177 IF I>1 THEN 182 178 M$="SHIPS" 179 R=2 180 C=13 181 GOSUB 35 182 RANDOMIZE 183 R=INT(RND*10)+1 184 C=INT(RND*10)+1 185 ON INT(RND*2)+1 GOSUB 81,71 186 IF G(P+3,R,C)<>I THEN 182 ELSE 204 187 M$=SEG$(S$,1+(I-1)*11,11) 188 M$=SEG$(M$,1,POS(M$," ",1)-1) 189 R=2 190 C=13 191 GOSUB 35 192 GOSUB 54 193 GOSUB 60 194 IF G(P+3,R,C)=0 THEN 197 195 CALL SOUND(150,220,2) 196 GOTO 193 197 CALL HCHAR(8+R,32+14*P+C,M+2) 198 GOSUB 19 199 IF J=0 THEN 198 200 IF J=5 THEN 193 201 IF (J<2)+(J>3) THEN 198 202 ON J-1 GOSUB 81,71 203 IF G(P+3,R,C)=0 THEN 195 204 GOSUB 57 205 NEXT I 206 CALL HCHAR(1,1,32,56) 207 GOSUB 49 208 G(-P,0,5)=1 209 G(-P,0,6)=1 210 NEXT P 211 FOR I=1 TO 4 212 CALL HCHAR(20+I,11,32,5) 213 CALL HCHAR(20+I,26,32,5) 214 NEXT I 215 CALL VCHAR(1,31,31,96) 216 CALL SOUND(150,1350,2) 217 FOR P=1 TO 2 218 GOSUB 46 219 M$=P$(P)&",:POSITION AND FIRE LASER::" 220 R=1 221 C=1 222 GOSUB 35 223 IF G(P,0,0) THEN 224 ELSE 224 224 GOSUB 54 225 GOSUB 60 226 Z=G(P,R,C) 227 IF (Z=5)+(Z<0) THEN 225 228 FOR I=2 TO 28 STEP 4 229 CALL SOUND(50,525,I) 230 NEXT I 231 GOSUB 57 232 ON SGN(Z)+1 GOTO 233,237 233 G(P,R,C)=5 234 CALL HCHAR(8+R,14*P-10+C,90+P* 235 M$=":::MISS!" 236 GOTO 256 237 CALL SCREEN(12) 238 CALL SCREEN(10) 239 CALL HCHAR(8+R,14*P-10+C,104+Z* 240 CALL SCREEN(2) 241 G(P,R,C)=-Z 242 G(P,0,Z)=G(P,0,Z)-1 243 CALL HCHAR(20+Z,P*15-4,104+Z*8,6-Z-G(P,0,Z)) 244 FOR I=2 TO 26 STEP 4 245 CALL SOUND(500,200,30,220,30,300,30,-8,I) 246 NEXT I 247 IF G(P,0,Z)>0 THEN 254 248 FOR I=14 TO 2 STEP -6 249 CALL SOUND(-100,-5,I) 250 NEXT I 251 FOR I=0 TO 30 STEP 2 252 CALL SOUND(-100,-5,I) 253 NEXT I 254 M$=SEG$(S$,Z*11-10,11) 255 M$=":::"&SEG$(M$,1,POS(M$," ",1))&SEG$("DESTROYED!HIT!",11+10*(G(P,0,Z)=0),10) 256 R=1 257 C=1 258 GOSUB 35 259 IF G(P,0,1)+G(P,0,2)+G(P,0,3)+G(P,0,4)=0 THEN 262 260 NEXT P 261 GOTO 217 262 M$=P$(P)&":HAS FREED THE GALAXY!::PLAY AGAIN (Y/N)?" 263 R=1 264 C=1 265 GOSUB 35 266 CALL KEY(3,K,S) 267 IF K=89 THEN 152 268 IF K<>78 THEN 266 269 CALL CLEAR 270 END Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 3, 2018 Share Posted April 3, 2018 Awesome stuff there, broseph... I am very much enjoying observing this process. But don't give up on console BASIC so easily... There is untapped potential there, and you've obviously got the knack for it (especially now with TIdBiT in the toolbelt) Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted April 3, 2018 Author Share Posted April 3, 2018 I definitely agree that my frustration level would be over 9000 right now were it not for Tidbit. Here are some screen shots from play, me versus myself as the computer player 3 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted April 5, 2018 Author Share Posted April 5, 2018 Working up an AI for this, I found some really neat articles on algorithms for playing Battle Ship. I have been working up a flow chart (ick!) to build my own AI and resisting the urge to just copy the one used in the original game. Once I release the final version I will include some of the articles I found, whether I implement any of them or not it still makes for interesting reading. Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted April 5, 2018 Share Posted April 5, 2018 Quick and dirty algorithm: 1- Random shots until hit recorded. Set hit flag. 2- systematic test of the 4 cardinal directions for additional hits unless bounded by edge or previous shots. 3- Follow cardinal direction where hit recorded. If sunk, then clear hit flag and go to 1. If hit go to 3. If no hit then reverse cardinal direction starting with initial hit and go back to 3. This obviously can be refined further by pre-scanning the grid and creating a list of all possible locations where a particular target could be residing, sorted by ship size. Not terribly helpful until about 50% of the grid has been shot at. It's slow but will make the AI extremely deadly... Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted April 5, 2018 Author Share Posted April 5, 2018 Essentially my flow chart goes like this: Check for any ships with hits and parts remaining Check spacing in all four directions If only one part has been hit: Is there a miss adjacent? Does the ship fit in one direction versus another? Try the best possible direction, or pick one if more than one. If multiple parts have been hit: Is it horizontal or vertical? Check spacing in both directions Fire at best possible spot. Otherwise, look at four quadrants Choose quadrant with most empty space (percentage-wise) less hit ship parts Choose random spot in selected quadrant check spacing: is it within space of longest remaining ship? Fire at best possible or random spot if no best spot, giving space for shortest remaining ship. I want the AI to be a moderately capable opponent. I am considering using the other player's "score" to determine how analytical the AI becomes. In my original iterations the AI could lose its place on a ship after determining its location by poking around randomly. The second version automatically knows where the rest of a ship is when it first finds it (cheats in that regard, but the initial find is also random.) Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted April 6, 2018 Author Share Posted April 6, 2018 AI aside, hearkening back to the use of complex formulas, the question becomes is performance more greatly impacted by using a formula like C+32+14*P or an array like C+GX(P). For something that small (number added to number times variable) it may not make a difference, but what about C+14*P-10-42*(P<0) where you are expecting values P={-2,-1,1,2}, but you still have to reference the array by taking a variable and adding a number. Thus, GX(P+3) to return GX({1,2,4,5}). I would assume the act of "variable plus number times variable minus number minus variable compared to number times number," noting the parenthesis has to be interpreted for precedence order, would take longer than "array lookup of element variable plus number." Just more to obsess. I have memory available to set up some arrays for the longer formulas so that is not a concern. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted April 6, 2018 Author Share Posted April 6, 2018 Another thing I learned while working on Tiles is not everything runs the same in emulation and on the metal. I played this a little tonight on a real console and am very pleased with the results, in particular the sounds. BASIC is very difficult to get just the right sounds. Partly because when the 9919 gets a new noise command it restarts the noise generator. 1 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted May 14, 2018 Author Share Posted May 14, 2018 Here is an irritating thing I have found with IF/THEN/ELSE that I cannot figure out. I like to cut down on the logic in IF/THEN/ELSE statements by using variables as the expression. For instance, IF G(P,0,0)THEN 2270 ELSE 2540 Even though in this statement G(P,0,0) is always 1 when executed, sometimes the ELSE clause is effected and execution is transferred to line 2540. Stranger still is I do not see this behavior in my other programs. I really have no idea WTF is going on but it is changing game flow and forcing me to use comparisons rather than zero and non-zero variables. Really aggravating and so far I have not seen it happen in Extended BASIC, only console BASIC. EDIT: yeah, I had no idea... Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted May 14, 2018 Author Share Posted May 14, 2018 Sunnuva...!!! Now, even with the comparison G(P,0,0)=0 execution is still going to the wrong place. So far as I can tell there is no other way for program flow to get there. *sigh* EDIT: As well, I have found that my random numbers are the same each run, even with a RANDOMIZE statement earlier in the program. Almost as if it has a specific scope. This is in Classic99 but I do not expect different behavior on a real console. I will test tomorrow -- I am too tired to continue mucking about. 1 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted May 14, 2018 Author Share Posted May 14, 2018 Okay, thanks to the good ol' TRACE statement I was able to figure out that under some circumstances the check routine following is bouncing back to a line which it should not be. That is, well after the decision but invisible to me because the program offers no other feedback. Sunnuva... HOWEVER, in order to not get a predictable repeat of random numbers I have to put a RANDOMIZE statement before each use of RND. THIS is genuinely legit and frustratingly confusing. Quote Link to comment Share on other sites More sharing options...
+Ksarul Posted May 14, 2018 Share Posted May 14, 2018 RANDOMIZE resets the random seed number--one time. The seed will then follow a predictable sequence until RANDOMIZE is used again to reset the seed. There is also a considerable time hit for using RANDOMIZE, but it is worth it to ensure that your pseudo-random numbers are as close to truly random as you can make them. I explored this particular issue in detail when I was writing a character generation program for the 1st Edition of Advanced Dungeons and Dragons back around 1988. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted May 14, 2018 Author Share Posted May 14, 2018 Right, but the seed should be different for each program run with just a single RANDOMIZE statement, correct? The game has lines like these: 200 R=INT(RND*10)+1 201 C=INT(RND*10)+1 If I only use the single RANDOMIZE earlier in the program then the values selected are demonstrably the same: ships get deployed in the same places every run and positions fired upon are the same. Quite annoying. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted May 14, 2018 Author Share Posted May 14, 2018 Maybe the issue is one of timing? For kicks and grins I put a short test program together and ran it a few times. Notice the first and third runs produce the same series of numbers. Based upon the behavior described above, I suspect if I had continued this I would have received more identical sets. 10 RANDOMIZE20 PRINT INT(RND*10)+1;30 GOTO 20 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted May 14, 2018 Share Posted May 14, 2018 A few things to remember with TI Basic regarding pseudo-random number generation: At program start, the random number seed at >83C0 always starts with the same number (>3567 in Classic99). RANDOMIZE uses the VDP interrupt timer value (1 byte, ticking 0 – 255) at >8379 to replace only the LSB of the seed at >83C0. At least in Classic99, the VDP timer only ticks (1 tick = 1/60 second) the LSN (Least Significant Nybble) of 4 bits (0 – 15) while in command mode. Your comment about timing is, indeed, relevant. At program start (RUN), the VDP timer jumps into the 0 – 255 timer cycle with a value of 0 – 15. With RANDOMIZE as the first statement, there is a high likelihood that the seed will start with the same number. If the VDP timer were zeroed at program start, it would be a virtual certainty. One thing you might try is to run RND without a limit before RANDOMIZE to force a change in both bytes of the seed. RND calls the GPL RAND function at least 7 times, with each call to RAND swapping the bytes of the seed before beginning its calculations. This makes RND a good bit slower than RANDOMIZE, by the way [Edit: 0.0125 s vs. 0.0015 s]: 10 A = RND 20 RANDOMIZE 30 PRINT INT(RND*10)+1; 40 GOTO 30 Edit: Actually, RANDOMIZE should be run before RND to avoid starting with another constant. So, perhaps, the following: 10 RANDOMIZE 20 A = RND 30 RANDOMIZE 40 PRINT INT(RND*10)+1; 50 GOTO 40 ...lee Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted May 14, 2018 Author Share Posted May 14, 2018 Thanks for the insight. Except for the un-bounded RND, I am doing close to the same at this point. In the game I have a RANDOMIZE in the loops immediate before using RND, which follows after other RNDs. So far the results are satisfying, but I have no technical details on what it is doing in the background. I will try with the un-bounded RND and see if that makes a difference. Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted May 14, 2018 Share Posted May 14, 2018 Thanks for the insight. Except for the un-bounded RND, I am doing close to the same at this point. In the game I have a RANDOMIZE in the loops immediate before using RND, which follows after other RNDs. So far the results are satisfying, but I have no technical details on what it is doing in the background. I will try with the un-bounded RND and see if that makes a difference. I only suggested the unbounded RND because it eliminates the multiplication and truncation steps. It has no effect on the seed. ...lee Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted August 27, 2020 Author Share Posted August 27, 2020 Since I have been on restricted activity, I decided to spend some time finishing this up. This is the fruit of my labor. While the computer logic is a little more simple than I wanted it to be, I did spice it up a little and have a couple of additional ideas if I can fit them into memory and program flow without too much trouble. To play the computer, enter a blank name for the player. The computer can play itself. Entered human player names will be truncated to 10 characters (while the technical reason for this has been eliminated, the restriction will remain.) Player one uses ESDX, player two uses IJKM, or the appropriate joysticks for each player. SPACE is fire, irrespective of player. During ship deployment, fire selects the spot and ships may be deployed right or down. Fire a second time deselects the deployment spot. The computer logic randomly pokes about the board using spacing based upon the size of the smallest remaining ship. Upon choosing a solution, it then checks to see if the smallest remaining ship will fit into the surrounding space. Once a ship is found, it looks at all surrounding directions and chooses based upon fit, so it will not waste a shot in a blocked direction. As well, if it happens to find another ship along the way, it remains focused on the larger ship until it is destroyed. This is the first candidate for release, in TIFILES format. I plan to spend some time over the next couple of weeks refining the code and preparing it into a package, as well as developing an Extended BASIC version. Unlike Tiles, I plan neither a compiled nor cartridge version as I am sticking to the original intent as a magazine type-in style program. LS-082720.zip 3 Quote Link to comment Share on other sites More sharing options...
oddemann Posted August 27, 2020 Share Posted August 27, 2020 Nice! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.