Really really fast BASIC handheld
10-18-2019, 04:53 PM
Post: #35
 toml_12953 Senior Member Posts: 1,408 Joined: Dec 2013
RE: Really really fast BASIC handheld
(01-13-2019 10:03 PM)berndpr Wrote:  Hallo!
Here I show the 8-Queen-Problem with addtional feature to show all changes in A and all 92 solutions.

CLS
PRINT "8-Queen-Problem with all solutions"
OPTION DEFINT
N=0
R=8
S=0
X=0
DIM A[9]
@LA
IF X==R GOTO @LE
INC X
A[X]=R: SHOW S,A
@LB
INC S
Y=X
@LC
DEC Y
IF Y==0 GOTO @LA
T=A[X]-A[Y]
IF T==0 GOTO @LD
IF X-Y!=ABS(T) GOTO @LC
@LD
DEC A[x]:SHOW S,A
IF A[X]!=0 GOTO @LB
DEC X
IF X!=0 GOTO @LD
@LE
IF A[1]==0 GOTO @LF
INC N
ZEIG S,A
PRINT
PRINT N;" .Solution=;S ; " Pos:";
FOR I=1 TO 8
PRINT CHR$(64+A[I]);I; IF I!=8 THEN PRINT ","; NEXT BUTOFF GOTO @LD @LF LOCATE 1,15 PRINT "FINISHED" END DEF SHOW S,A LOCATE 1,2 BUTON PRINT S PRINT " A B C D E F G H" FOR I=1 TO 8 J=A[I] PRINT J;" ";I; IF J>0 THEN PRINT " ."*(J-1);" ";CHRS$(&H2640);" ."*(8-J);
ELSE
PRINT " ."*8;
ENDIF
PRINT " ";I
NEXT
END

DEF BUTON
REPEAT
B=BUTTON()
UNTIL B!=0
IF B==#A THEN VSYNC 3 'only to slow down display or output is faster than the eye.
IF B==#B THEN STOP
END

DEF BUTOFF
BUTON
REPEAT
B=BUTTON()
UNTIL B==0 || B==#X

END

Button B quits the program.
The program runs only, if a key is pressed.
If you press the button X the program progress until the button is released. It stops not at the next solution.

Hold Button A to progress slowly and stops at the next solution.
Any other Button progress fast and stops at next solution.
For next solution release button and hold again.

DEF is define a function
END is end program or end function
BUTTON() return the bits of the pressed hardware keys.
#X is the number (bit) of key X
|| is an OR
N is the number of the solution
"ABC"*3 is a string repeat: "ABCABCABC"
CHRS\$(&H2640) is the venus symbol (queen). It's a Unicode value.
If the value in A is a zero, no queen is shown.

This version was developed for Yabasic (PS2 BASIC from the demo cd of the first release, available for PC Windows and Linux too, http://www.yabasic.de/) and is not optimized for speed but use exact the 8-Queen-Benchmark. I have changed it to SmileBASIC (not big changes).

Bernd

P.S.:
I have corrected errors in the code and changed the button control.

In order to be able to accurately compare the benchmark time to other calculators in the test, you'd have to remove the DEFINT if it causes all variables to be integer. The other units use floating point (except the assembler examples, probably).

Tom L
...other than that, Mrs. Lincoln, what did you think of the play?
 « Next Oldest | Next Newest »

 Messages In This Thread Really really fast BASIC handheld - berndpr - 01-09-2019, 04:03 PM RE: Really really fast BASIC handheld - Dan - 01-10-2019, 01:10 AM RE: Really really fast BASIC handheld - berndpr - 01-10-2019, 08:31 AM RE: Really really fast BASIC handheld - Dan - 01-11-2019, 06:40 AM RE: Really really fast BASIC handheld - ijabbott - 01-10-2019, 08:16 AM RE: Really really fast BASIC handheld - berndpr - 01-10-2019, 08:37 AM RE: Really really fast BASIC handheld - ijabbott - 01-10-2019, 08:54 AM RE: Really really fast BASIC handheld - berndpr - 01-11-2019, 06:27 AM RE: Really really fast BASIC handheld - ijabbott - 01-11-2019, 10:34 AM RE: Really really fast BASIC handheld - berndpr - 01-11-2019, 07:11 AM RE: Really really fast BASIC handheld - xerxes - 01-11-2019, 01:34 PM RE: Really really fast BASIC handheld - Maximilian Hohmann - 01-11-2019, 12:05 PM RE: Really really fast BASIC handheld - Dave Britten - 01-11-2019, 04:20 PM RE: Really really fast BASIC handheld - smp - 01-11-2019, 04:21 PM RE: Really really fast BASIC handheld - hp41cx - 01-11-2019, 10:48 PM RE: Really really fast BASIC handheld - Stevetuc - 01-12-2019, 08:03 AM RE: Really really fast BASIC handheld - StephenG1CMZ - 01-12-2019, 10:21 AM RE: Really really fast BASIC handheld - pier4r - 01-12-2019, 02:41 PM RE: Really really fast BASIC handheld - mfleming - 01-12-2019, 04:56 PM RE: Really really fast BASIC handheld - StephenG1CMZ - 01-12-2019, 09:41 PM RE: Really really fast BASIC handheld - mfleming - 01-13-2019, 12:59 AM RE: Really really fast BASIC handheld - berndpr - 01-12-2019, 10:00 PM RE: Really really fast BASIC handheld - xerxes - 01-13-2019, 02:56 PM RE: Really really fast BASIC handheld - xerxes - 01-13-2019, 11:20 PM RE: Really really fast BASIC handheld - berndpr - 01-14-2019, 07:28 PM RE: Really really fast BASIC handheld - Stevetuc - 01-13-2019, 08:37 AM RE: Really really fast BASIC handheld - pier4r - 01-13-2019, 09:55 AM RE: Really really fast BASIC handheld - toml_12953 - 04-18-2020, 04:48 PM RE: Really really fast BASIC handheld - mfleming - 04-19-2020, 01:34 AM RE: Really really fast BASIC handheld - Stevetuc - 05-12-2020, 07:58 AM RE: Really really fast BASIC handheld - Stevetuc - 05-12-2020, 08:40 AM RE: Really really fast BASIC handheld - berndpr - 01-13-2019, 08:08 PM RE: Really really fast BASIC handheld - xerxes - 01-13-2019, 08:30 PM RE: Really really fast BASIC handheld - pier4r - 01-13-2019, 08:40 PM RE: Really really fast BASIC handheld - Luigi Vampa - 01-13-2019, 09:37 PM RE: Really really fast BASIC handheld - berndpr - 01-13-2019, 10:03 PM RE: Really really fast BASIC handheld - toml_12953 - 10-18-2019 04:53 PM RE: Really really fast BASIC handheld - StephenG1CMZ - 10-16-2019, 10:30 PM RE: Really really fast BASIC handheld - Csaba Tizedes - 10-18-2019, 02:08 PM RE: Really really fast BASIC handheld - Csaba Tizedes - 04-18-2020, 11:04 AM RE: Really really fast BASIC handheld - toml_12953 - 04-18-2020, 08:36 PM

User(s) browsing this thread: 1 Guest(s)