Update BazzBasic-AI-guide.txt
Browse files- BazzBasic-AI-guide.txt +54 -9
BazzBasic-AI-guide.txt
CHANGED
|
@@ -2,14 +2,14 @@
|
|
| 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.
|
| 6 |
**URL:** This guide is stored and updated at https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
|
| 7 |
# END METADATA
|
| 8 |
|
| 9 |
---
|
| 10 |
|
| 11 |
## BazzBasic details
|
| 12 |
-
**Version:** 1.
|
| 13 |
**Author:** Kristian Virtanen (EkBass)
|
| 14 |
**Platform:** Windows x64
|
| 15 |
**License:** MIT
|
|
@@ -45,7 +45,8 @@
|
|
| 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)
|
|
@@ -76,6 +77,16 @@ LET score$ = 0 ' Numeric variable
|
|
| 76 |
LET x$, y$, z$ = 10 ' Multiple declaration
|
| 77 |
' x$ & y$ has value of 0 while z$ has 10
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
' constants
|
| 80 |
LET TITLE# = "My Game" ' String constant
|
| 81 |
LET_VER# = 1.2 ' Numeric constant
|
|
@@ -88,7 +99,7 @@ LET_VER# = 1.2 ' Numeric constant
|
|
| 88 |
|
| 89 |
### Built-in Constants
|
| 90 |
- **Boolean:** `TRUE`, `FALSE`
|
| 91 |
-
- **Math:** `PI`, `HPI` (π/2 = 90°), `QPI` (π/4 = 45°), `TAU` (2π = 360°), `EULER` (e)
|
| 92 |
- **System:** `PRG_ROOT#` (program base directory path), `BBVER#` (interpreter version as text, e.g. `"1.1"`)
|
| 93 |
- **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.
|
| 94 |
|
|
@@ -106,7 +117,8 @@ matrix$(0, 1) = "A2" ' Multi-dimensional
|
|
| 106 |
|
| 107 |
| Function/Command | Description |
|
| 108 |
|-----------------|-------------|
|
| 109 |
-
| `LEN(arr$())` |
|
|
|
|
| 110 |
| `HASKEY(arr$(key))` | 1 if exists, 0 if not |
|
| 111 |
| `DELKEY arr$(key)` | Remove one element |
|
| 112 |
| `DELARRAY arr$` | Remove entire array (can re-DIM after) |
|
|
@@ -224,8 +236,9 @@ FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
|
|
| 224 |
|----------|-------------|
|
| 225 |
| `ASC(s$)` | ASCII code of first char |
|
| 226 |
| `CHR(n)` | Character from ASCII code |
|
| 227 |
-
| `INSTR(s$, search$)` | Position (1-based), 0=not found |
|
| 228 |
-
| `INSTR(
|
|
|
|
| 229 |
| `INVERT(s$)` | Reverse string |
|
| 230 |
| `LCASE(s$)` / `UCASE(s$)` | Lower / upper case |
|
| 231 |
| `LEFT(s$, n)` / `RIGHT(s$, n)` | First/last n chars |
|
|
@@ -271,7 +284,7 @@ FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
|
|
| 271 |
| `SGN(n)` | Sign: -1, 0, or 1 |
|
| 272 |
| `SQR(n)` | Square root |
|
| 273 |
|
| 274 |
-
**Math constants:** `PI`, `HPI` (PI/2), `QPI` (PI/4), `TAU` (PI*2), `EULER`
|
| 275 |
|
| 276 |
---
|
| 277 |
|
|
@@ -343,6 +356,25 @@ REMOVESHAPE RECT# ' Free memory (always clean up)
|
|
| 343 |
|
| 344 |
---
|
| 345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
## Sound
|
| 347 |
|
| 348 |
```basic
|
|
@@ -464,6 +496,19 @@ Use for raycasting, sprite rotation, particle systems, any high-freq trig.
|
|
| 464 |
|
| 465 |
---
|
| 466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
## Libraries & INCLUDE
|
| 468 |
|
| 469 |
```basic
|
|
@@ -571,7 +616,7 @@ RETURN
|
|
| 571 |
|
| 572 |
LET px$ = SCREEN_W# / 2 ' Pivot point X — where the pendulum is attached (screen center top)
|
| 573 |
LET py$ = 10 ' Pivot point Y — a bit down from top edge
|
| 574 |
-
LET theta$ = HPI
|
| 575 |
LET bx$ ' Bob X position on screen (calculated each frame)
|
| 576 |
LET by$ ' Bob Y position on screen (calculated each frame)
|
| 577 |
|
|
|
|
| 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.3 and is updated 11.04.26 (ddmmyy)
|
| 6 |
**URL:** This guide is stored and updated at https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
|
| 7 |
# END METADATA
|
| 8 |
|
| 9 |
---
|
| 10 |
|
| 11 |
## BazzBasic details
|
| 12 |
+
**Version:** 1.3
|
| 13 |
**Author:** Kristian Virtanen (EkBass)
|
| 14 |
**Platform:** Windows x64
|
| 15 |
**License:** MIT
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
### Common AI Mistakes
|
| 48 |
+
- forgetting LET
|
| 49 |
+
- Mis-using LET/ROWCOUNT with arrays
|
| 50 |
- using LET inside subs (wastes computing time, prefer [inits] section)
|
| 51 |
- calling function before definition
|
| 52 |
- not using return value from FN (if not other chance, use temp$ to get it)
|
|
|
|
| 77 |
LET x$, y$, z$ = 10 ' Multiple declaration
|
| 78 |
' x$ & y$ has value of 0 while z$ has 10
|
| 79 |
|
| 80 |
+
**Compound assignment operators** (variables only — **not** allowed with `#` constants):
|
| 81 |
+
|
| 82 |
+
```basic
|
| 83 |
+
x$ += 5 ' add
|
| 84 |
+
x$ -= 3 ' subtract
|
| 85 |
+
x$ *= 2 ' multiply
|
| 86 |
+
x$ /= 4 ' divide
|
| 87 |
+
s$ += " World" ' string concatenation
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
' constants
|
| 91 |
LET TITLE# = "My Game" ' String constant
|
| 92 |
LET_VER# = 1.2 ' Numeric constant
|
|
|
|
| 99 |
|
| 100 |
### Built-in Constants
|
| 101 |
- **Boolean:** `TRUE`, `FALSE`
|
| 102 |
+
- **Math:** `PI#`, `HPI#` (π/2 = 90°), `QPI#` (π/4 = 45°), `TAU#` (2π = 360°), `EULER#` (e)
|
| 103 |
- **System:** `PRG_ROOT#` (program base directory path), `BBVER#` (interpreter version as text, e.g. `"1.1"`)
|
| 104 |
- **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.
|
| 105 |
|
|
|
|
| 117 |
|
| 118 |
| Function/Command | Description |
|
| 119 |
|-----------------|-------------|
|
| 120 |
+
| `LEN(arr$())` | Total element count (note empty parens) |
|
| 121 |
+
| `ROWCOUNT(arr$())` | Count of first-dimension rows — use this for FOR loops over multi-dim arrays |
|
| 122 |
| `HASKEY(arr$(key))` | 1 if exists, 0 if not |
|
| 123 |
| `DELKEY arr$(key)` | Remove one element |
|
| 124 |
| `DELARRAY arr$` | Remove entire array (can re-DIM after) |
|
|
|
|
| 236 |
|----------|-------------|
|
| 237 |
| `ASC(s$)` | ASCII code of first char |
|
| 238 |
| `CHR(n)` | Character from ASCII code |
|
| 239 |
+
| `INSTR(s$, search$)` | Position (1-based), 0=not found; case-sensitive by default |
|
| 240 |
+
| `INSTR(s$, search$, mode)` | mode: 0=case-insensitive, 1=case-sensitive |
|
| 241 |
+
| `INSTR(start, s$, search$)` | Search from position (case-sensitive) |
|
| 242 |
| `INVERT(s$)` | Reverse string |
|
| 243 |
| `LCASE(s$)` / `UCASE(s$)` | Lower / upper case |
|
| 244 |
| `LEFT(s$, n)` / `RIGHT(s$, n)` | First/last n chars |
|
|
|
|
| 284 |
| `SGN(n)` | Sign: -1, 0, or 1 |
|
| 285 |
| `SQR(n)` | Square root |
|
| 286 |
|
| 287 |
+
**Math constants:** `PI#`, `HPI#` (PI/2), `QPI#` (PI/4), `TAU#` (PI*2), `EULER#`
|
| 288 |
|
| 289 |
---
|
| 290 |
|
|
|
|
| 356 |
|
| 357 |
---
|
| 358 |
|
| 359 |
+
### Text Rendering (SDL2_ttf.dll required)
|
| 360 |
+
#### DRAWSTRING & LOADFONT
|
| 361 |
+
|
| 362 |
+
```basic
|
| 363 |
+
' Default font (Arial)
|
| 364 |
+
DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
|
| 365 |
+
|
| 366 |
+
' Load alternative font — becomes the new default
|
| 367 |
+
LOADFONT "comic.ttf", 24
|
| 368 |
+
DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
|
| 369 |
+
|
| 370 |
+
' Reset to Arial
|
| 371 |
+
LOADFONT
|
| 372 |
+
```
|
| 373 |
+
|
| 374 |
+
`DRAWSTRING x, y` positions the top-left of the text. Requires `SDL2_ttf.dll` in the same directory as the interpreter. Prefer this over PRINT, which makes graphic screen easily blinking.
|
| 375 |
+
|
| 376 |
+
---
|
| 377 |
+
|
| 378 |
## Sound
|
| 379 |
|
| 380 |
```basic
|
|
|
|
| 496 |
|
| 497 |
---
|
| 498 |
|
| 499 |
+
## Command-Line Arguments
|
| 500 |
+
|
| 501 |
+
```basic
|
| 502 |
+
' bazzbasic.exe myprog.bas arg1 arg2
|
| 503 |
+
PRINT ARGCOUNT ' number of args (2 in this example)
|
| 504 |
+
PRINT ARGS(0) ' first arg → "arg1"
|
| 505 |
+
PRINT ARGS(1) ' second arg → "arg2"
|
| 506 |
+
```
|
| 507 |
+
|
| 508 |
+
`ARGCOUNT` and `ARGS(n)` are 0-based; ARGS does not include the interpreter or script name.
|
| 509 |
+
|
| 510 |
+
---
|
| 511 |
+
|
| 512 |
## Libraries & INCLUDE
|
| 513 |
|
| 514 |
```basic
|
|
|
|
| 616 |
|
| 617 |
LET px$ = SCREEN_W# / 2 ' Pivot point X — where the pendulum is attached (screen center top)
|
| 618 |
LET py$ = 10 ' Pivot point Y — a bit down from top edge
|
| 619 |
+
LET theta$ = HPI# ' Current angle in radians (HPI# = 90° = starts horizontal)
|
| 620 |
LET bx$ ' Bob X position on screen (calculated each frame)
|
| 621 |
LET by$ ' Bob Y position on screen (calculated each frame)
|
| 622 |
|