Files
gw-basic-2026/tests/programs/monte_carlo.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
345 B
QBasic

10 REM Monte Carlo pi estimation
20 RANDOMIZE 42
30 INSIDE% = 0
40 N% = 10000
50 FOR I = 1 TO N%
60 X = RND(1) * 2 - 1
70 Y = RND(1) * 2 - 1
80 IF X*X + Y*Y <= 1 THEN INSIDE% = INSIDE% + 1
90 NEXT I
100 PE = 4 * INSIDE% / N%
110 PRINT USING "Pi estimate: #.####"; PE
120 PRINT USING "Actual pi: #.####"; 3.14159265#
130 PRINT "Monte Carlo OK"