Title: | 1970s BASIC Interpreter |
---|---|
Description: | Executes BASIC programs from the 1970s, for historical and educational purposes. This enables famous examples of early machine learning, artificial intelligence, natural language processing, cellular automata, and so on, to be run in their original form. |
Authors: | Mike Lee |
Maintainer: | Mike Lee <[email protected]> |
License: | GPL-3 |
Version: | 1.0.2 |
Built: | 2024-10-31 20:50:48 UTC |
Source: | CRAN |
Runs 1970s BASIC programs.
Interprets and executes a subset of early (1975) Altair/Microsoft BASIC, plus some generalisations and extensions. Enables various programs of historical interest to be run in their primal form. A selection of public-domain examples are included.
Mike Lee
require(brassica) ## Not run: # Load and run the 'Wumpus' program. RUN("WUMPUS") ## End(Not run)
require(brassica) ## Not run: # Load and run the 'Wumpus' program. RUN("WUMPUS") ## End(Not run)
Lists whichever BASIC program is loaded.
LIST()
LIST()
Returns a character vector, containing the complete listing of whichever BASIC program is in memory at the time.
# List the current BASIC program. LIST()
# List the current BASIC program. LIST()
Converts a BASIC program to lower case, except for any string literals.
LowerCode(p)
LowerCode(p)
p |
A BASIC program listing, as a character vector. |
Returns the converted listing, as a character vector.
# Convert a program to lower case. LowerCode(c('10 LET X=X+1', '20 PRINT "Hello, World!"'))
# Convert a program to lower case. LowerCode(c('10 LET X=X+1', '20 PRINT "Hello, World!"'))
Returns a data frame of any BASIC program lines that contain one or
more unexecuted statements.
Used with repeated calls of RUN()
, this provides a test of code syntax
and accessibility.
NotRun(pretty = TRUE)
NotRun(pretty = TRUE)
pretty |
A single logical value.
If |
Returns a data frame of any lines, from the currently-loaded BASIC program, containing one or more unexecuted statements. Lines are listed with both their BASIC line numbers and the corresponding file line numbers of the source script. A persistent appearance here may, but does not necessarily, signify a problem with the line.
BASIC ON
and IF-THEN-ELSE
statements contain multiple
alternative clauses.
Each such statement, as a whole, is marked as having been executed once any one
of its clauses has been run without error.
Hence, the absence of such a statement from the NotRun()
frame does not
guarantee that all of its clauses are error-free.
# Peruse which lines have not yet been run. NotRun()
# Peruse which lines have not yet been run. NotRun()
Loads and runs BASIC programs.
RUN(program = NULL, ttx = 0, tty = 0, up = FALSE)
RUN(program = NULL, ttx = 0, tty = 0, up = FALSE)
program |
A character string, containing the name or file path of a BASIC program. Omitting this re-runs the currently-loaded program. |
ttx |
Aesthetic teletype option. A delay, of not more than 200 milliseconds, to be applied after printing each character. In practice, the actual delay will be this time plus however long it takes to flush the console, plus interpreter overheads. Depending on the model, a real teletype could manage around ten characters per second. Making this negative imposes no delay, but flushes the console after each completed line (not after each character). |
tty |
Aesthetic teletype option. A delay, of not more than 2000 milliseconds, to be applied after each line of printing. Making this negative imposes no delay, but still flushes the console after each completed line. |
up |
Aesthetic teletype option.
Making this |
List of bundled example programs (from the references):
Animal | by Arthur Luehrmann | (decision trees) |
Camel | by the Heath Users Group | (random walk) |
Chase | by Mac Oglesby | (robots) |
Eliza | by Jeff Shrager | (language processing) |
Even Wins | by Eric Peters | (machine learning) |
Flip | by John S. James | (machine learning) |
Four in a Row | by James L. Murphy | (artificial intelligence) |
Guess-It | by Gerard Kierman | (bluffing) |
Hammurabi | by David H. Ahl | (resource management) |
Hexapawn | by R. A. Kaapke | (machine learning) |
Inkblot | by Scott Costello | (projection) |
Life | by Clark Baker | (cellular automata) |
Maze | by Richard Schaal | (depth-first search) |
Not One | by Robert Puopolo | (expectation values) |
Sea Battle | by Vincent Erickson | (monsters) |
Super Star Trek | by Richard Leedon | (vector space) |
Wumpus | by Gregory Yob | (graph topology) |
All of these are in the public domain.
Returns an invisible NULL
, after printing to standard output.
Many BASIC programs ask for user input after printing a custom prompt.
When ttx
is greater than zero, some R sessions may incorrectly position
the cursor at the beginning of the line, or on the next.
Neither occurrence is fatal.
Known to be affected: Windows R terminal (‘R’ and ‘Rterm’, but the
‘Rgui’ console is fine), Mac R console (but the Bash terminal is fine),
RStudio.
Additionally, double buffering, or the like, may interfere with the effect at
higher speeds (Mac R console, again).
David H. Ahl & Steve North, BASIC Computer Games (1978)
David H. Ahl & Steve North, More BASIC Computer Games (1979)
## Not run: # Load and run 'Wumpus'. RUN("wumpus") # Load and run 'Chase', flushing the # console after every line of output. RUN("chase", -1) # Load and run 'Camel', with full # retro-style teletypewriter effects. RUN("camel", 20, 300, TRUE) # Load and run your program. RUN("myprogram.bas") # Re-run the last program # (without re-loading it). RUN() ## End(Not run)
## Not run: # Load and run 'Wumpus'. RUN("wumpus") # Load and run 'Chase', flushing the # console after every line of output. RUN("chase", -1) # Load and run 'Camel', with full # retro-style teletypewriter effects. RUN("camel", 20, 300, TRUE) # Load and run your program. RUN("myprogram.bas") # Re-run the last program # (without re-loading it). RUN() ## End(Not run)
Converts a BASIC program to upper case, except for any string literals.
UpperCode(p)
UpperCode(p)
p |
A BASIC program listing, as a character vector. |
Returns the converted listing, as a character vector.
# Convert a program to upper case. UpperCode(c('10 let x=x+1', '20 print "Hello, World!"'))
# Convert a program to upper case. UpperCode(c('10 let x=x+1', '20 print "Hello, World!"'))