Update BazzBasic-AI-guide.txt
Browse files- BazzBasic-AI-guide.txt +19 -3
BazzBasic-AI-guide.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 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
|
| 6 |
**URL:** This guide is stored and updated at https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
|
| 7 |
# END METADATA
|
| 8 |
|
|
@@ -27,11 +27,14 @@
|
|
| 27 |
## ⚠️ Critical Rules — Read First
|
| 28 |
| Rule | Detail |
|
| 29 |
|------|--------|
|
|
|
|
| 30 |
| Variables end with `$` | `name$`, `score$`, `x$` |
|
|
|
|
| 31 |
| Constants end with `#` | `MAX#`, `PI#`, `TITLE#` |
|
| 32 |
| Arrays declared with `DIM`, end with `$` | `DIM items$` |
|
| 33 |
| First use of variable requires `LET` | `LET x$ = 0` — after that `x$ = x$ + 1` |
|
| 34 |
| FOR and INPUT auto-declare, no LET needed | `FOR i$ = 1 TO 10` |
|
|
|
|
| 35 |
| Functions defined **before** they are called | Put at top or INCLUDE |
|
| 36 |
| Function name ends with `$`, called with `FN` | `FN MyFunc$(a$, b$)` |
|
| 37 |
| Function return value **must** be used | `PRINT FN f$()` or `LET v$ = FN f$()` |
|
|
@@ -40,6 +43,18 @@
|
|
| 40 |
| `+` operator does both add and concatenate | `"Hi" + " " + name$` |
|
| 41 |
| Division always returns float | `10 / 3` → `3.333...` |
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
---
|
| 44 |
|
| 45 |
## For context from the author:
|
|
@@ -63,6 +78,7 @@ LET x$, y$, z$ = 10 ' Multiple declaration
|
|
| 63 |
|
| 64 |
' constants
|
| 65 |
LET TITLE# = "My Game" ' String constant
|
|
|
|
| 66 |
```
|
| 67 |
|
| 68 |
**Scope:** All main-code variables share one scope (even inside IF blocks).
|
|
@@ -112,7 +128,7 @@ ELSE
|
|
| 112 |
PRINT "F"
|
| 113 |
END IF ' ENDIF also works
|
| 114 |
|
| 115 |
-
' One-line IF
|
| 116 |
IF lives$ = 0 THEN GOTO [game_over]
|
| 117 |
IF key$ = KEY_ESC# THEN GOTO [menu] ELSE GOTO [play]
|
| 118 |
|
|
@@ -500,7 +516,7 @@ RETURN
|
|
| 500 |
|
| 501 |
---
|
| 502 |
|
| 503 |
-
## Rosetta-Code
|
| 504 |
|
| 505 |
### Animate a pendulum
|
| 506 |
|
|
|
|
| 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 07.04.26 (ddmmyy)
|
| 6 |
**URL:** This guide is stored and updated at https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
|
| 7 |
# END METADATA
|
| 8 |
|
|
|
|
| 27 |
## ⚠️ Critical Rules — Read First
|
| 28 |
| Rule | Detail |
|
| 29 |
|------|--------|
|
| 30 |
+
| Every variable must be introduced with LET exactly once before any use | LET <var> |
|
| 31 |
| Variables end with `$` | `name$`, `score$`, `x$` |
|
| 32 |
+
| Variables must describe purpose | no x$, tmp$, a$ unless loop index |
|
| 33 |
| Constants end with `#` | `MAX#`, `PI#`, `TITLE#` |
|
| 34 |
| Arrays declared with `DIM`, end with `$` | `DIM items$` |
|
| 35 |
| First use of variable requires `LET` | `LET x$ = 0` — after that `x$ = x$ + 1` |
|
| 36 |
| FOR and INPUT auto-declare, no LET needed | `FOR i$ = 1 TO 10` |
|
| 37 |
+
| Avoid GOTO | Supported only for historical reasons |
|
| 38 |
| Functions defined **before** they are called | Put at top or INCLUDE |
|
| 39 |
| Function name ends with `$`, called with `FN` | `FN MyFunc$(a$, b$)` |
|
| 40 |
| Function return value **must** be used | `PRINT FN f$()` or `LET v$ = FN f$()` |
|
|
|
|
| 43 |
| `+` operator does both add and concatenate | `"Hi" + " " + name$` |
|
| 44 |
| Division always returns float | `10 / 3` → `3.333...` |
|
| 45 |
|
| 46 |
+
|
| 47 |
+
### Common AI Mistakes
|
| 48 |
+
- forgetting LET
|
| 49 |
+
- using LET inside subs (wastes computing time, prefer [inits] section)
|
| 50 |
+
- calling function before definition
|
| 51 |
+
- not using return value from FN (if not other chance, use temp$ to get it)
|
| 52 |
+
- passing arrays to functions
|
| 53 |
+
- mixing $ and #
|
| 54 |
+
- using LET on subs or loops
|
| 55 |
+
- forgots to use SCREENLOCK/SCREENUNLOCK
|
| 56 |
+
- Does not read: ## Performance Tips
|
| 57 |
+
|
| 58 |
---
|
| 59 |
|
| 60 |
## For context from the author:
|
|
|
|
| 78 |
|
| 79 |
' constants
|
| 80 |
LET TITLE# = "My Game" ' String constant
|
| 81 |
+
LET_VER# = 1.2 ' Numeric constant
|
| 82 |
```
|
| 83 |
|
| 84 |
**Scope:** All main-code variables share one scope (even inside IF blocks).
|
|
|
|
| 128 |
PRINT "F"
|
| 129 |
END IF ' ENDIF also works
|
| 130 |
|
| 131 |
+
' One-line IF
|
| 132 |
IF lives$ = 0 THEN GOTO [game_over]
|
| 133 |
IF key$ = KEY_ESC# THEN GOTO [menu] ELSE GOTO [play]
|
| 134 |
|
|
|
|
| 516 |
|
| 517 |
---
|
| 518 |
|
| 519 |
+
## Rosetta-Code examples
|
| 520 |
|
| 521 |
### Animate a pendulum
|
| 522 |
|