Spectra PowerBASIC v2.10f
This commit is contained in:
parent
7a3b3a7c69
commit
8af2e2e1af
32
Spectra PowerBASIC v210f/E.BAS
Normal file
32
Spectra PowerBASIC v210f/E.BAS
Normal file
@ -0,0 +1,32 @@
|
||||
100 DIGITS% = 200
|
||||
110 DIM A%( 200 )
|
||||
120 HIGH% = DIGITS%
|
||||
130 X% = 0
|
||||
140 N% = HIGH% - 1
|
||||
150 IF N% <= 0 GOTO 200
|
||||
160 A%[ N% ] = 1
|
||||
170 N% = N% - 1
|
||||
180 GOTO 150
|
||||
200 A%[ 1 ] = 2
|
||||
210 A%[ 0 ] = 0
|
||||
220 IF HIGH% <= 9 GOTO 400
|
||||
230 HIGH% = HIGH% - 1
|
||||
235 N% = HIGH%
|
||||
240 IF N% = 0 GOTO 300
|
||||
250 A%[ N% ] = X% MOD N%
|
||||
255 rem PRINT "a[n-1]"; A%[ N% - 1 ]
|
||||
260 X% = ( 10 * A%[ N% - 1 ] ) + ( X% \ N% )
|
||||
265 rem PRINT "x: "; X%, "n: "; N%
|
||||
270 N% = N% - 1
|
||||
280 GOTO 240
|
||||
300 IF X% >= 10 GOTO 330
|
||||
310 PRINT USING "#"; X%;
|
||||
320 GOTO 220
|
||||
330 PRINT USING "##"; X%;
|
||||
340 GOTO 220
|
||||
400 PRINT ""
|
||||
410 PRINT "done"
|
||||
420 SYSTEM
|
||||
|
||||
|
||||
|
BIN
Spectra PowerBASIC v210f/PB.EXE
Normal file
BIN
Spectra PowerBASIC v210f/PB.EXE
Normal file
Binary file not shown.
BIN
Spectra PowerBASIC v210f/PBCONFIG.PB
Normal file
BIN
Spectra PowerBASIC v210f/PBCONFIG.PB
Normal file
Binary file not shown.
BIN
Spectra PowerBASIC v210f/PBHELP.PBH
Normal file
BIN
Spectra PowerBASIC v210f/PBHELP.PBH
Normal file
Binary file not shown.
BIN
Spectra PowerBASIC v210f/PBPICK.PBP
Normal file
BIN
Spectra PowerBASIC v210f/PBPICK.PBP
Normal file
Binary file not shown.
20
Spectra PowerBASIC v210f/SIEVE.BAS
Normal file
20
Spectra PowerBASIC v210f/SIEVE.BAS
Normal file
@ -0,0 +1,20 @@
|
||||
1 SIZE% = 8190
|
||||
2 DIM FLAGS%(8191)
|
||||
3 PRINT "10 iterations"
|
||||
4 FOR X% = 1 TO 10
|
||||
5 COUNT% = 0
|
||||
6 FOR I% = 0 TO SIZE%
|
||||
7 FLAGS%(I%) = 1
|
||||
8 NEXT I%
|
||||
9 FOR I% = 0 TO SIZE%
|
||||
10 IF FLAGS%(I%) = 0 THEN 18
|
||||
11 PRIME% = I% + I% + 3
|
||||
12 K% = I% + PRIME%
|
||||
13 IF K% > SIZE% THEN 17
|
||||
14 FLAGS%(K%) = 0
|
||||
15 K% = K% + PRIME%
|
||||
16 GOTO 13
|
||||
17 COUNT% = COUNT% + 1
|
||||
18 NEXT I%
|
||||
19 NEXT X%
|
||||
20 PRINT COUNT%," PRIMES"
|
120
Spectra PowerBASIC v210f/TTT.BAS
Normal file
120
Spectra PowerBASIC v210f/TTT.BAS
Normal file
@ -0,0 +1,120 @@
|
||||
1 REM Tic Tac Toe solving app that learns what WOPR learned: you can't win
|
||||
2 REM Only three starting positions are examined. Others are just reflections of these
|
||||
3 REM b% -- The board
|
||||
4 REM al% -- Alpha, for pruning
|
||||
5 REM be% -- Beta, for pruning
|
||||
6 REM l% -- Top-level loop iteration
|
||||
7 REM wi% -- The winning piece (0 none, 1 X, 2, O )
|
||||
8 REM re% -- Resulting score of 4000/minmax board position. 5 draw, 6 X win, 4 Y win
|
||||
9 REM sx% -- Stack array for "recursion" X can be P, V, A, or B for those variables.
|
||||
10 REM v% -- Value of a board position
|
||||
11 REM st% -- Stack Pointer. Even for alpha/beta pruning Minimize plys, Odd for Maximize
|
||||
12 REM p% -- Current position where a new piece is played
|
||||
14 REM rw% -- Row in the Winner function (2000)
|
||||
15 REM cw% -- Column in the Winner function (2000)
|
||||
18 REM mc% -- Move count total for debugging. Should be a multiple of 6493
|
||||
19 REM Note: Can't use real recursion with GOSUB because stack is limited to roughly 5 deep
|
||||
20 REM BASIC doesn't support goto/gosub using arrays for target line numbers
|
||||
23 li% = val( command$ )
|
||||
24 if 0 = li% then li% = 10
|
||||
30 DIM b%(9)
|
||||
32 DIM sp%(10)
|
||||
34 DIM sv%(10)
|
||||
36 DIM sa%(10)
|
||||
37 DIM sb%(10)
|
||||
38 mc% = 0
|
||||
39 PRINT "start time: "; TIME$
|
||||
40 FOR l% = 1 TO li%
|
||||
41 mc% = 0
|
||||
42 al% = 2
|
||||
43 be% = 9
|
||||
44 b%(0) = 1
|
||||
45 GOSUB 4000
|
||||
58 al% = 2
|
||||
59 be% = 9
|
||||
60 b%(0) = 0
|
||||
61 b%(1) = 1
|
||||
62 GOSUB 4000
|
||||
68 al% = 2
|
||||
69 be% = 9
|
||||
70 b%(1) = 0
|
||||
71 b%(4) = 1
|
||||
72 GOSUB 4000
|
||||
73 b%(4) = 0
|
||||
74 print "mc: "; mc%; " l is "; l%
|
||||
80 NEXT l%
|
||||
82 REM print elap$
|
||||
83 PRINT "end time: "; TIME$
|
||||
84 print "iterations: "; li%
|
||||
85 PRINT "final move count "; mc%
|
||||
88 SYSTEM
|
||||
100 END
|
||||
|
||||
2000 wi% = b%(0)
|
||||
2010 IF 0 = wi% GOTO 2100
|
||||
2020 IF wi% = b%(1) AND wi% = b%(2) THEN RETURN
|
||||
2030 IF wi% = b%(3) AND wi% = b%(6) THEN RETURN
|
||||
2100 wi% = b%(3)
|
||||
2110 IF 0 = wi% GOTO 2200
|
||||
2120 IF wi% = b%(4) AND wi% = b%(5) THEN RETURN
|
||||
2200 wi% = b%(6)
|
||||
2210 IF 0 = wi% GOTO 2300
|
||||
2220 IF wi% = b%(7) AND wi% = b%(8) THEN RETURN
|
||||
2300 wi% = b%(1)
|
||||
2310 IF 0 = wi% GOTO 2400
|
||||
2320 IF wi% = b%(4) AND wi% = b%(7) THEN RETURN
|
||||
2400 wi% = b%(2)
|
||||
2410 IF 0 = wi% GOTO 2500
|
||||
2420 IF wi% = b%(5) AND wi% = b%(8) THEN RETURN
|
||||
2500 wi% = b%(4)
|
||||
2510 IF 0 = wi% THEN RETURN
|
||||
2520 IF wi% = b%(0) AND wi% = b%(8) THEN RETURN
|
||||
2530 IF wi% = b%(2) AND wi% = b%(6) THEN RETURN
|
||||
2540 wi% = 0
|
||||
2550 RETURN
|
||||
|
||||
4000 REM minmax function to find score of a board position
|
||||
4010 REM recursion is simulated with gotos
|
||||
4030 st% = 0
|
||||
4040 v% = 0
|
||||
4060 re% = 0
|
||||
4100 mc% = mc% + 1
|
||||
4104 IF st% < 4 THEN GOTO 4150
|
||||
4105 GOSUB 2000
|
||||
4107 IF 0 = wi% THEN GOTO 4140
|
||||
4110 IF wi% = 1 THEN re% = 6: GOTO 4280
|
||||
4115 re% = 4
|
||||
4116 GOTO 4280
|
||||
4140 IF st% = 8 THEN re% = 5: GOTO 4280
|
||||
4150 IF 1 = (st% MOD 2 ) THEN v% = 2 ELSE v% = 9
|
||||
4160 p% = 0
|
||||
4180 IF 0 <> b%(p%) THEN GOTO 4500
|
||||
4200 IF 1 = ( st% MOD 2) THEN b%(p%) = 1 ELSE b%(p%) = 2
|
||||
4210 sp%(st%) = p%
|
||||
4230 sv%(st%) = v%
|
||||
4245 sa%(st%) = al%
|
||||
4246 sb%(st%) = be%
|
||||
4260 st% = st% + 1
|
||||
4270 GOTO 4100
|
||||
4280 st% = st% - 1
|
||||
4290 p% = sp%(st%)
|
||||
4310 v% = sv%(st%)
|
||||
4325 al% = sa%(st%)
|
||||
4326 be% = sb%(st%)
|
||||
4328 b%(p%) = 0
|
||||
4330 IF 1 = ( st% MOD 2) THEN GOTO 4340
|
||||
4331 IF re% = 4 THEN GOTO 4530
|
||||
4332 IF re% < v% THEN v% = re%
|
||||
4334 IF v% < be% THEN be% = v%
|
||||
4336 IF be% <= al% THEN GOTO 4520
|
||||
4338 GOTO 4500
|
||||
4340 IF re% = 6 THEN GOTO 4530
|
||||
4341 IF re% > v% THEN v% = re%
|
||||
4342 IF v% > al% THEN al% = v%
|
||||
4344 IF al% >= be% THEN GOTO 4520
|
||||
4500 p% = p% + 1
|
||||
4505 IF p% < 9 THEN GOTO 4180
|
||||
4520 re% = v%
|
||||
4530 IF st% = 0 THEN RETURN
|
||||
4540 GOTO 4280
|
||||
|
3
Spectra PowerBASIC v210f/m.bat
Normal file
3
Spectra PowerBASIC v210f/m.bat
Normal file
@ -0,0 +1,3 @@
|
||||
rem PowerBASIC has no command-line build. You have to start the app, load the file, set the main file, and compile.
|
||||
rem Be sure to check the compilation defaults to turn off debug settings go get substantial performance wins
|
||||
|
2
Spectra PowerBASIC v210f/r.bat
Normal file
2
Spectra PowerBASIC v210f/r.bat
Normal file
@ -0,0 +1,2 @@
|
||||
ntvdm -r:. -C:50 pb
|
||||
|
3
Spectra PowerBASIC v210f/runit.bat
Normal file
3
Spectra PowerBASIC v210f/runit.bat
Normal file
@ -0,0 +1,3 @@
|
||||
rem runs a PowerBASIC app, which only write to CGA memory for text output
|
||||
ntvdm -c -p -m %1.EXE
|
||||
|
Loading…
Reference in New Issue
Block a user