EkBass commited on
Commit
cb0d0f7
·
verified ·
1 Parent(s): 221f1c7

Update BazzBasic-AI-guide.txt

Browse files
Files changed (1) hide show
  1. BazzBasic-AI-guide.txt +204 -72
BazzBasic-AI-guide.txt CHANGED
@@ -1,31 +1,29 @@
1
  # METADATA:
2
-
3
- Name: BazzBasic
4
-
5
- Description: BazzBasic BASIC interpreter language reference. Use when writing, debugging, or explaining BazzBasic code (.bas files). Triggers on BazzBasic syntax, BASIC programming with $ and # suffixes, SDL2 graphics in BASIC, or references to BazzBasic interpreter features
6
-
7
- About: BazzBasic is built around one simple idea: starting programming should feel nice and even fun. Ease of learning, comfort of exploration and small but important moments of success. Just like the classic BASICs of decades past, but with a fresh and modern feel.
8
-
9
- Purpose: This guide has been provided with the idea that it would be easy and efficient for a modern AI to use this guide and through this either guide a new programmer to the secrets of BazzBasic or, if necessary, generate code himself.
10
-
11
- Version: This guide is written for BazzBasic version 1.1d and is updated 26.03.2026 Finnish time.
12
-
13
  # END METADATA
14
 
15
  ---
16
 
17
- # BazzBasic Language Reference
18
- **Version:** 1.1b (March 2026) | **Author:** Kristian Virtanen (EkBass) | **Platform:** Windows x64
 
 
 
 
 
 
19
  **GitHub:** https://github.com/EkBass/BazzBasic
20
  **Manual:** https://ekbass.github.io/BazzBasic/manual/#/
21
- **Examples:** https://github.com/EkBass/BazzBasic/tree/main/Examples
22
  **Rosetta Code:** https://rosettacode.org/wiki/Category:BazzBasic
23
-
24
 
25
  ---
26
 
27
  ## ⚠️ Critical Rules — Read First
28
-
29
  | Rule | Detail |
30
  |------|--------|
31
  | Variables end with `$` | `name$`, `score$`, `x$` |
@@ -43,37 +41,26 @@ Version: This guide is written for BazzBasic version 1.1d and is updated 26.03.2
43
 
44
  ---
45
 
 
 
46
 
47
- ## ABOUT
48
- BazzBasic is built around one simple idea: starting programming should feel nice and even fun.
49
-
50
- Ease of learning, comfort of exploration and small but important moments of success.
51
-
52
- Just like the classic BASICs of decades past, but with a fresh and modern feel.
53
-
54
- ## STORY
55
- Although over the years, as my own skills have grown, I have moved on to more versatile and modern languages, BASIC has always been something that has been fun to try out many different things with.
56
-
57
- Sometimes it's great to just make a simple adventure game again, a lottery machine, a quiz, or even just those balls bouncing on the screen.
58
 
59
- BazzBasic was created with this in mind.
60
 
61
- I wanted to create a language that makes it easy for you to give free rein to your curiosity and program something.
62
-
63
- And when you finish your first little game, you may crave something bigger and better.
64
-
65
- Maybe one day you will move on to another programming language, but then BazzBasic will have succeeded in doing what it was intended for.
66
-
67
- To arouse your curiosity.
68
 
69
  ## Variables & Constants
70
 
71
  ```basic
72
- LET a$ ' Declare without value
73
- LET name$ = "Alice" ' String variable
74
- LET score$ = 0 ' Numeric variable
75
- LET x$, y$, z$ = 10 ' Multiple declaration
76
- LET PI# = 3.14159 ' Constant (immutable)
 
 
 
77
  LET TITLE# = "My Game" ' String constant
78
  ```
79
 
@@ -85,7 +72,7 @@ LET TITLE# = "My Game" ' String constant
85
  ### Built-in Constants
86
  - **Boolean:** `TRUE`, `FALSE`
87
  - **Math:** `PI`, `HPI` (π/2 = 90°), `QPI` (π/4 = 45°), `TAU` (2π = 360°), `EULER` (e)
88
- - **System:** `ROOT#` (program base directory path)
89
  - **Keyboard:** `KEY_ESC#`, `KEY_ENTER#`, `KEY_SPACE#`, `KEY_UP#`, `KEY_DOWN#`, `KEY_LEFT#`, `KEY_RIGHT#`, `KEY_F1#`…`KEY_F12#`, `KEY_A#`…`KEY_Z#`, `KEY_0#`…`KEY_9#`, `KEY_LSHIFT#`, `KEY_LCTRL#`, etc.
90
 
91
  ---
@@ -106,6 +93,7 @@ matrix$(0, 1) = "A2" ' Multi-dimensional
106
  | `HASKEY(arr$(key))` | 1 if exists, 0 if not |
107
  | `DELKEY arr$(key)` | Remove one element |
108
  | `DELARRAY arr$` | Remove entire array (can re-DIM after) |
 
109
 
110
  **Always check with `HASKEY` before reading uninitialized elements.**
111
 
@@ -165,6 +153,8 @@ END ' Terminate program
165
  | `LINE INPUT "prompt", var$` | Read entire line with spaces |
166
  | `CLS` | Clear screen |
167
  | `LOCATE row, col` | Move cursor (1-based) |
 
 
168
  | `COLOR fg, bg` | Text colors (0–15 palette) |
169
  | `SHELL("cmd")` | Run shell command, returns output |
170
  | `SHELL("cmd", ms)` | With timeout in ms (default 5000) |
@@ -257,7 +247,8 @@ FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
257
  | `MAX(a, b)` / `MIN(a, b)` | Larger / smaller of two |
258
  | `MOD(a, b)` | Remainder |
259
  | `POW(base, exp)` | Power |
260
- | `RND(n)` | Random integer 0 to n-1 |
 
261
  | `ROUND(n)` | Standard rounding |
262
  | `SGN(n)` | Sign: -1, 0, or 1 |
263
  | `SQR(n)` | Square root |
@@ -312,9 +303,11 @@ CLS ' Clear screen (slow — prefer LINE BF)
312
  ### Shapes & Images
313
  ```basic
314
  ' Create shape
315
- LET id$ = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE"
316
- LET img$ = LOADIMAGE("player.png") ' PNG (alpha) or BMP
317
- LET img$ = LOADIMAGE("https://example.com/a.png") ' Download + load
 
 
318
 
319
  ' Sprite sheet — sprites indexed 1-based
320
  DIM sprites$
@@ -322,12 +315,12 @@ LOADSHEET sprites$, 128, 128, "sheet.png" ' tileW, tileH, file
322
  MOVESHAPE sprites$(1), x, y ' sprites$(1) = first sprite
323
 
324
  ' Transform
325
- MOVESHAPE id$, x, y ' Position by center point
326
- ROTATESHAPE id$, angle ' Degrees (absolute)
327
- SCALESHAPE id$, scale ' 1.0 = original size
328
- DRAWSHAPE id$ ' Render to buffer
329
- SHOWSHAPE id$ / HIDESHAPE id$ ' Toggle visibility
330
- REMOVESHAPE id$ ' Free memory (always clean up)
331
  ```
332
 
333
  ---
@@ -335,12 +328,14 @@ REMOVESHAPE id$ ' Free memory (always clean up)
335
  ## Sound
336
 
337
  ```basic
338
- LET snd$ = LOADSOUND("jump.wav") ' Load (WAV recommended)
339
- SOUNDONCE(snd$) ' Play once, non-blocking
340
- SOUNDONCEWAIT(snd$) ' Play once, wait for finish
341
- SOUNDREPEAT(snd$) ' Loop continuously
342
- SOUNDSTOP(snd$) ' Stop specific sound
343
- SOUNDSTOPALL ' Stop all sounds
 
 
344
  ```
345
 
346
  Load all sounds at startup. Call `SOUNDSTOPALL` before `END`.
@@ -366,7 +361,7 @@ LET env$ = FileRead(".env")
366
  LET API_KEY# = env$("OPENAI_API_KEY")
367
  ```
368
 
369
- **Paths:** Use `/` or `\\` — never single `\` (it's an escape char). Relative paths are from `ROOT#`.
370
  **FileWrite with array** saves in key=value format (round-trips with FileRead).
371
 
372
  ---
@@ -441,27 +436,26 @@ Library functions can read main-program constants (`#`). `.bb` files are version
441
  ## Program Structure
442
 
443
  ```basic
444
- ' ---- 1. CONSTANTS (or INCLUDE "constants.bas") ----
445
- LET SCREEN_W# = 640
446
- LET SCREEN_H# = 480
447
- LET MAX_SPEED# = 5
448
-
449
- ' ---- 2. FUNCTIONS (or INCLUDE "functions.bas") ----
450
  DEF FN Clamp$(v$, lo$, hi$)
451
  IF v$ < lo$ THEN RETURN lo$
452
  IF v$ > hi$ THEN RETURN hi$
453
  RETURN v$
454
  END DEF
455
 
456
- ' ---- 3. INIT (declare ALL variables here, not inside loops) ----
457
  ' Performance: variables declared outside loops avoid repeated existence checks.
458
  [inits]
459
- SCREEN 0, SCREEN_W#, SCREEN_H#, "My Game"
 
 
460
  LET x$ = 320
461
  LET y$ = 240
462
  LET running$ = TRUE
463
 
464
- ' ---- 4. MAIN LOOP ----
 
 
465
  [main]
466
  WHILE running$
467
  IF INKEY = KEY_ESC# THEN running$ = FALSE
@@ -470,9 +464,9 @@ END DEF
470
  SLEEP 16
471
  WEND
472
  SOUNDSTOPALL
473
- END
474
 
475
- ' ---- 5. SUBROUTINES (or INCLUDE "subs.bas") ----
476
  [sub:update]
477
  IF KEYDOWN(KEY_LEFT#) THEN x$ = x$ - MAX_SPEED#
478
  IF KEYDOWN(KEY_RIGHT#) THEN x$ = x$ + MAX_SPEED#
@@ -489,8 +483,8 @@ RETURN
489
  **Key conventions:**
490
  - Variables: `camelCase$` | Constants: `UPPER_SNAKE_CASE#` | Functions: `PascalCase$`
491
  - Labels: `[gameLoop]` for jump targets, `[sub:name]` for subroutines
492
- - Image/sound IDs that never change use constants: `LET MY_IMG# = LOADIMAGE("x.png")`
493
- - Group many image/sound IDs use arrays: `DIM sprites$` / `sprites$("player") = LOADIMAGE(...)`
494
 
495
  ---
496
 
@@ -501,4 +495,142 @@ RETURN
501
  - Store `RGB()` results in constants/variables — don't call RGB in hot loops
502
  - Declare all variables in `[inits]`, not inside loops or subroutines
503
  - Use `FastTrig` for any loop calling trig hundreds of times per frame
504
- - `SLEEP 16` in game loop → ~60 FPS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # METADATA:
2
+ **Name:** BazzBasic-AI-guide.txt
3
+ **Description:** BazzBasic BASIC interpreter language reference for AI. Use BazzBasic to write, debug, or teach code.
4
+ **File extensions:*** ".bas"*, *".bb"*
5
+ **Version:** This guide is written for BazzBasic version 1.2 and is updated 01.04.26 (ddmmyy)
 
 
 
 
 
 
 
6
  # END METADATA
7
 
8
  ---
9
 
10
+ ## BazzBasic details
11
+ **Version:** 1.2
12
+ **Author:** Kristian Virtanen (EkBass)
13
+ **Platform:** Windows x64
14
+ **License:** MIT
15
+
16
+ ## BazzBasic www-references
17
+ **Homepage:** https://ekbass.github.io/BazzBasic/
18
  **GitHub:** https://github.com/EkBass/BazzBasic
19
  **Manual:** https://ekbass.github.io/BazzBasic/manual/#/
20
+ **Common examples:** https://github.com/EkBass/BazzBasic/tree/main/Examples
21
  **Rosetta Code:** https://rosettacode.org/wiki/Category:BazzBasic
22
+ **Rosetta-Code examples:** https://github.com/EkBass/BazzBasic/tree/main/Examples/rosetta-code
23
 
24
  ---
25
 
26
  ## ⚠️ Critical Rules — Read First
 
27
  | Rule | Detail |
28
  |------|--------|
29
  | Variables end with `$` | `name$`, `score$`, `x$` |
 
41
 
42
  ---
43
 
44
+ ## For context from the author:
45
+ **About:** BazzBasic is built around one simple idea: starting programming should feel nice and even fun. Ease of learning, comfort of exploration and small but important moments of success. Just like the classic BASICs of decades past, but with a fresh and modern feel.
46
 
47
+ **Story:** Although over the years, as my own skills have grown, I have moved on to more versatile and modern languages, BASIC has always been something that has been fun to try out many different things with. Sometimes it's great to just make a simple adventure game again, a lottery machine, a quiz, or even just those balls bouncing on the screen. BazzBasic was created with this in mind. I wanted to create a language that makes it easy for you to give free rein to your curiosity and program something. And when you finish your first little game, you may crave something bigger and better.
 
 
 
 
 
 
 
 
 
 
48
 
49
+ *Maybe one day you will move on to another programming language, but then BazzBasic will have succeeded in doing what it was intended for: To arouse your curiosity.*
50
 
51
+ - Kristian Virtanen (EkBass), author of BazzBasic
 
 
 
 
 
 
52
 
53
  ## Variables & Constants
54
 
55
  ```basic
56
+ ' variables
57
+ LET a$ ' Declare without value
58
+ LET name$ = "Alice" ' String variable
59
+ LET score$ = 0 ' Numeric variable
60
+ LET x$, y$, z$ = 10 ' Multiple declaration
61
+ ' x$ & y$ has value of 0 while z$ has 10
62
+
63
+ ' constants
64
  LET TITLE# = "My Game" ' String constant
65
  ```
66
 
 
72
  ### Built-in Constants
73
  - **Boolean:** `TRUE`, `FALSE`
74
  - **Math:** `PI`, `HPI` (π/2 = 90°), `QPI` (π/4 = 45°), `TAU` (2π = 360°), `EULER` (e)
75
+ - **System:** `PRG_ROOT#` (program base directory path), `BBVER#` (interpreter version as text, e.g. `"1.1"`)
76
  - **Keyboard:** `KEY_ESC#`, `KEY_ENTER#`, `KEY_SPACE#`, `KEY_UP#`, `KEY_DOWN#`, `KEY_LEFT#`, `KEY_RIGHT#`, `KEY_F1#`…`KEY_F12#`, `KEY_A#`…`KEY_Z#`, `KEY_0#`…`KEY_9#`, `KEY_LSHIFT#`, `KEY_LCTRL#`, etc.
77
 
78
  ---
 
93
  | `HASKEY(arr$(key))` | 1 if exists, 0 if not |
94
  | `DELKEY arr$(key)` | Remove one element |
95
  | `DELARRAY arr$` | Remove entire array (can re-DIM after) |
96
+ | `JOIN dest$, src1$, src2$` | Merge two arrays into dest$; src2$ keys overwrite src1$ on conflict |
97
 
98
  **Always check with `HASKEY` before reading uninitialized elements.**
99
 
 
153
  | `LINE INPUT "prompt", var$` | Read entire line with spaces |
154
  | `CLS` | Clear screen |
155
  | `LOCATE row, col` | Move cursor (1-based) |
156
+ | `CURPOS("row")` | Returns current cursor row |
157
+ | `CURPOS("col")` | Returns current cursor column |
158
  | `COLOR fg, bg` | Text colors (0–15 palette) |
159
  | `SHELL("cmd")` | Run shell command, returns output |
160
  | `SHELL("cmd", ms)` | With timeout in ms (default 5000) |
 
247
  | `MAX(a, b)` / `MIN(a, b)` | Larger / smaller of two |
248
  | `MOD(a, b)` | Remainder |
249
  | `POW(base, exp)` | Power |
250
+ | `RND(0)` | Random float 0.0 to <1.0 |
251
+ | `RND(n)` | Random integer 0 to n-1 (n ≥ 1) |
252
  | `ROUND(n)` | Standard rounding |
253
  | `SGN(n)` | Sign: -1, 0, or 1 |
254
  | `SQR(n)` | Square root |
 
303
  ### Shapes & Images
304
  ```basic
305
  ' Create shape
306
+ ' LOADSHAPE and LOADIMAGE return a stable integer handle — never reassigned.
307
+ ' SDL2 owns the resource; your code only ever holds this one reference. Use constants.
308
+ LET RECT# = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE"
309
+ LET IMG_PLAYER# = LOADIMAGE("player.png") ' PNG (alpha) or BMP
310
+ LET IMG_REMOTE# = LOADIMAGE("https://example.com/a.png") ' Download + load
311
 
312
  ' Sprite sheet — sprites indexed 1-based
313
  DIM sprites$
 
315
  MOVESHAPE sprites$(1), x, y ' sprites$(1) = first sprite
316
 
317
  ' Transform
318
+ MOVESHAPE RECT#, x, y ' Position by center point
319
+ ROTATESHAPE RECT#, angle ' Degrees (absolute)
320
+ SCALESHAPE RECT#, scale ' 1.0 = original size
321
+ DRAWSHAPE RECT# ' Render to buffer
322
+ SHOWSHAPE RECT# / HIDESHAPE RECT# ' Toggle visibility
323
+ REMOVESHAPE RECT# ' Free memory (always clean up)
324
  ```
325
 
326
  ---
 
328
  ## Sound
329
 
330
  ```basic
331
+ ' LOADSOUND returns a stable integer handle — SDL2 manages the resource.
332
+ ' The handle never changes; store it in a constant to protect it from accidental reassignment.
333
+ LET SND_JUMP# = LOADSOUND("jump.wav") ' Load (WAV/MP3 recommended)
334
+ SOUNDONCE(SND_JUMP#) ' Play once, non-blocking
335
+ SOUNDONCEWAIT(SND_JUMP#) ' Play once, wait for finish
336
+ SOUNDREPEAT(SND_JUMP#) ' Loop continuously
337
+ SOUNDSTOP(SND_JUMP#) ' Stop specific sound
338
+ SOUNDSTOPALL ' Stop all sounds
339
  ```
340
 
341
  Load all sounds at startup. Call `SOUNDSTOPALL` before `END`.
 
361
  LET API_KEY# = env$("OPENAI_API_KEY")
362
  ```
363
 
364
+ **Paths:** Use `/` or `\\` — never single `\` (it's an escape char). Relative paths are from `PRG_ROOT#`.
365
  **FileWrite with array** saves in key=value format (round-trips with FileRead).
366
 
367
  ---
 
436
  ## Program Structure
437
 
438
  ```basic
439
+ ' ---- 1. FUNCTIONS (or INCLUDE "functions.bas") ----
 
 
 
 
 
440
  DEF FN Clamp$(v$, lo$, hi$)
441
  IF v$ < lo$ THEN RETURN lo$
442
  IF v$ > hi$ THEN RETURN hi$
443
  RETURN v$
444
  END DEF
445
 
446
+ ' ---- 2. INIT (declare ALL variables/constants here, not inside loops) ----
447
  ' Performance: variables declared outside loops avoid repeated existence checks.
448
  [inits]
449
+ LET SCREEN_W# = 640
450
+ LET SCREEN_H# = 480
451
+ LET MAX_SPEED# = 5
452
  LET x$ = 320
453
  LET y$ = 240
454
  LET running$ = TRUE
455
 
456
+ SCREEN 0, SCREEN_W#, SCREEN_H#, "My Game"
457
+
458
+ ' ---- 3. MAIN LOOP ----
459
  [main]
460
  WHILE running$
461
  IF INKEY = KEY_ESC# THEN running$ = FALSE
 
464
  SLEEP 16
465
  WEND
466
  SOUNDSTOPALL
467
+ END ' always before code enters to subroutines
468
 
469
+ ' ---- 4. SUBROUTINES (or INCLUDE "subs.bas") ----
470
  [sub:update]
471
  IF KEYDOWN(KEY_LEFT#) THEN x$ = x$ - MAX_SPEED#
472
  IF KEYDOWN(KEY_RIGHT#) THEN x$ = x$ + MAX_SPEED#
 
483
  **Key conventions:**
484
  - Variables: `camelCase$` | Constants: `UPPER_SNAKE_CASE#` | Functions: `PascalCase$`
485
  - Labels: `[gameLoop]` for jump targets, `[sub:name]` for subroutines
486
+ - Image/sound/shape IDs are stable integer handles **always** store as constants: `LET MY_IMG# = LOADIMAGE("x.png")` — never use `$` variables for these
487
+ - Group many IDs -> use arrays: `DIM sprites$` / `sprites$("player") = LOADIMAGE(...)` — but prefer named constants when count is small
488
 
489
  ---
490
 
 
495
  - Store `RGB()` results in constants/variables — don't call RGB in hot loops
496
  - Declare all variables in `[inits]`, not inside loops or subroutines
497
  - Use `FastTrig` for any loop calling trig hundreds of times per frame
498
+ - `SLEEP 16` in game loop → ~60 FPS
499
+
500
+ ---
501
+
502
+ ## Rosetta-Code example
503
+
504
+ ### Animate a pendulum
505
+
506
+ ```basic
507
+ ' https://rosettacode.org/wiki/Animate_a_pendulum
508
+ ' BazzBasic conversion from Freebasic code
509
+ ' https://ekbass.github.io/BazzBasic/
510
+
511
+ ' This is done for educational purposes -> commented everything
512
+ ' Public Domain
513
+
514
+
515
+ [inits]
516
+ LET SCREEN_W# = 640 ' Screen width in pixels
517
+ LET SCREEN_H# = 480 ' Screen height in pixels
518
+ LET DAMPING# = 0.9995 ' Energy loss per frame (1.0 = no loss, 0.0 = instant stop)
519
+
520
+ LET g$ = 9.81 ' Gravity constant (m/s²) — drives the swing force
521
+ LET l$ = 1 ' Pendulum length (affects swing speed — longer = slower)
522
+ LET speed$ = 0 ' Current angular velocity (how fast the angle is changing)
523
+ LET accel$ ' Angular acceleration this frame (force pushing toward center)
524
+
525
+ LET px$ = SCREEN_W# / 2 ' Pivot point X — where the pendulum is attached (screen center top)
526
+ LET py$ = 10 ' Pivot point Y — a bit down from top edge
527
+ LET theta$ = HPI ' Current angle in radians (HPI = 90° = starts horizontal)
528
+ LET bx$ ' Bob X position on screen (calculated each frame)
529
+ LET by$ ' Bob Y position on screen (calculated each frame)
530
+
531
+
532
+ [main]
533
+ SCREEN SCREEN_W#, SCREEN_H#
534
+ WHILE INKEY <> KEY_ESC#
535
+ ' Project angle to screen coordinates
536
+ bx$ = px$ + l$ * (SCREEN_W# / 2) * SIN(theta$) ' horizontal offset from pivot
537
+ by$ = py$ - l$ * (SCREEN_W# / 2) * COS(theta$) ' vertical offset from pivot (Y flipped)
538
+
539
+ SCREENLOCK ON
540
+ LINE (0, 0) - (SCREEN_W#, SCREEN_H#), 15, BF ' clear screen
541
+ LINE (px$, py$) - (bx$, by$), 0 ' draw rod
542
+ CIRCLE (bx$, by$), 50, 7, 1 ' draw bob
543
+ SCREENLOCK OFF
544
+
545
+ accel$ = g$ * SIN(theta$) / l$ / 100 ' gravity pulls bob toward center (SIN of angle = sideways force)
546
+ speed$ = (speed$ * DAMPING#) + accel$ / 100 ' update speed with damping applied
547
+ theta$ = theta$ + speed$ ' advance the angle by current speed
548
+ SLEEP 16
549
+ WEND
550
+ END
551
+ ```
552
+
553
+ ### RGB attributes generator
554
+ ```basic
555
+ ' ============================================
556
+ ' https://rosettacode.org/wiki/RPG_attributes_generator
557
+ ' BazzBasic: https://github.com/EkBass/BazzBasic
558
+ ' ============================================
559
+ ' Attributes: Strength, Dexterity, Constitution,
560
+ ' Intelligence, Wisdom, Charisma
561
+ '
562
+ ' Rules:
563
+ ' - Total of all attributes must be >= 75
564
+ ' - At least two attributes must be >= 15
565
+
566
+ LET MIN_TOTAL# = 75
567
+ LET MIN_TWO# = 15
568
+
569
+ ' Roll 4d6, drop the lowest die, return sum of top 3
570
+ DEF FN RollStat$()
571
+ LET r1$ = RND(6) + 1
572
+ LET r2$ = RND(6) + 1
573
+ LET r3$ = RND(6) + 1
574
+ LET r4$ = RND(6) + 1
575
+ RETURN r1$ + r2$ + r3$ + r4$ - MIN(MIN(r1$, r2$), MIN(r3$, r4$))
576
+ END DEF
577
+
578
+ [inits]
579
+ DIM attributes$
580
+ attributes$("str") = 0
581
+ attributes$("dex") = 0
582
+ attributes$("con") = 0
583
+ attributes$("int") = 0
584
+ attributes$("wis") = 0
585
+ attributes$("cha") = 0
586
+ LET stat$ = 0
587
+ LET total$ = 0
588
+ LET highCount$ = 0
589
+ LET passed$ = FALSE
590
+
591
+ [main]
592
+ WHILE passed$ = FALSE
593
+ stat$ = FN RollStat$() : attributes$("str") = stat$
594
+ stat$ = FN RollStat$() : attributes$("dex") = stat$
595
+ stat$ = FN RollStat$() : attributes$("con") = stat$
596
+ stat$ = FN RollStat$() : attributes$("int") = stat$
597
+ stat$ = FN RollStat$() : attributes$("wis") = stat$
598
+ stat$ = FN RollStat$() : attributes$("cha") = stat$
599
+
600
+ total$ = attributes$("str") + attributes$("dex") + attributes$("con") + attributes$("int") + attributes$("wis") + attributes$("cha")
601
+
602
+ highCount$ = 0
603
+ IF attributes$("str") >= MIN_TWO# THEN highCount$ = highCount$ + 1
604
+ IF attributes$("dex") >= MIN_TWO# THEN highCount$ = highCount$ + 1
605
+ IF attributes$("con") >= MIN_TWO# THEN highCount$ = highCount$ + 1
606
+ IF attributes$("int") >= MIN_TWO# THEN highCount$ = highCount$ + 1
607
+ IF attributes$("wis") >= MIN_TWO# THEN highCount$ = highCount$ + 1
608
+ IF attributes$("cha") >= MIN_TWO# THEN highCount$ = highCount$ + 1
609
+
610
+ IF total$ >= MIN_TOTAL# AND highCount$ >= 2 THEN passed$ = TRUE
611
+ WEND
612
+
613
+ PRINT "Attribute Score"
614
+ PRINT "------------------"
615
+ PRINT "Strength " + STR(attributes$("str"))
616
+ PRINT "Dexterity " + STR(attributes$("dex"))
617
+ PRINT "Constitution " + STR(attributes$("con"))
618
+ PRINT "Intelligence " + STR(attributes$("int"))
619
+ PRINT "Wisdom " + STR(attributes$("wis"))
620
+ PRINT "Charisma " + STR(attributes$("cha"))
621
+ PRINT "------------------"
622
+ PRINT "Total " + STR(total$)
623
+ END
624
+
625
+ ' Expected output (example - varies each run):
626
+ ' Attribute Score
627
+ ' ------------------
628
+ ' Strength 13
629
+ ' Dexterity 15
630
+ ' Constitution 12
631
+ ' Intelligence 11
632
+ ' Wisdom 15
633
+ ' Charisma 10
634
+ ' ------------------
635
+ ' Total 76
636
+ ```