Files
gw-basic-2026/tests/programs/number_guess.bas
Eremey Valetov 1f4c460f4f Phase 5: CI, terminal I/O, Sixel graphics, classic programs
Add GitHub Actions CI with automated build and test. Implement real
terminal I/O with raw mode (enable_raw/disable_raw, proper INKEY$
polling via VMIN=0/VTIME=0, INPUT$ function). Add Sixel graphics
engine with virtual framebuffer (SCREEN 1: 320x200, SCREEN 2:
640x200), Bresenham line drawing, midpoint circle, flood fill PAINT,
DRAW mini-language parser, and Sixel encoder with RLE. Replace all
graphics stubs with real implementations (PSET, LINE, CIRCLE, DRAW,
PAINT, COLOR, SCREEN, POINT). Fix AND/OR/XOR operator precedence
to be lower than relational operators. Add 13 classic test programs
(39 total). Bump version to 0.5.0.
2026-02-10 16:46:34 -05:00

14 lines
494 B
QBasic

10 REM Number guessing game (self-playing with fixed seed)
20 RANDOMIZE 99
30 SECRET% = INT(RND(1) * 100) + 1
40 REM Play using binary search
50 LO% = 1 : HI% = 100
60 TRIES% = 0
70 WHILE LO% <= HI%
80 GUESS% = INT((LO% + HI%) / 2)
90 TRIES% = TRIES% + 1
100 IF GUESS% = SECRET% THEN PRINT "Found"; SECRET%; "in"; TRIES%; "tries" : GOTO 150
110 IF GUESS% < SECRET% THEN LO% = GUESS% + 1 ELSE HI% = GUESS% - 1
120 WEND
150 IF TRIES% <= 7 THEN PRINT "Number guess OK" ELSE PRINT "Too many tries"