Inkling language basics
Current version
All Inkling files must start with an inkling statement that specifies the
current language version:
inkling "2.0"
Language elements
Inkling code defines what (and how) you want to teach your AI. An expression in Inkling code is any syntactic entity that can be evaluated to determine its value including:
- Comments: user-defined code annotations.
- Identifiers: user-defined names for objects and types.
- Keywords: lowercase ASCII strings that are reserved words in Inkling.
- Literals: explicit array, string, struct, or numeric values not represented by an identifier.
- Operators: built-in symbols for arithmetic transformation, value assignment, value comparison, and logical evaluation.
Comments
Inkling supports Unix shell-style (Perl style) comments. For example:
# Distances (meters)
const RadiusOfPlate = 0.1125
In-line comments are only supported at the end of a code line. For example:
# Velocities
const MaxVelocity = 1.0 # meters / second
const MaxInitialVelocity = 0.05 # meters / second
Identifiers
Identifiers are user-defined names for objects or types. Valid Inkling identifiers:
- start with an alphabetical character or underscore
- contain printable Unicode characters that are not reserved characters in Inkling.
For example:
const Velocity = 5.0
var _max_percent: number = 100
const Rotate90Degrees = true
Inkling provides the following escape characters for identifiers that must use unsupported characters:
- backticks (
`) can be used to escape whitespace. - backslash (
\) can be used to escape backticks and backslashes.
For example:
const `1 Microsoft Way` = true
var `Service Name`: string = "Bonsai"
const `Don't \` do this` = "This is a legal, but very bad identifier"
Tip
Capitalize identifiers or start them with underscores to future-proof your Inkling code against possible collisions with future keywords.
Debugging and runtime errors
The Inkling compiler will detect and report most errors in the Bonsai coding panel and disable training until all errors are resolved. But, there are rare circumstances where runtime errors may occur (for example, division by zero).
Runtime errors that occur during training are logged and reported in the Bonsai UI. Depending on the nature of the runtime error, the training episode may be terminated. If a significant number of episodes are terminated in a short period of time, training is terminated.
Edit Inkling files with Visual Studio Code
If you edit Inkling in text files with Visual Studio Code, you can install the Inkling extension from Visual Studio Marketplace. The Inkling extension provides syntax coloring, IntelliSense, errors, and warnings.
Tip
By default, IntelliSense suggests completions based on words that occur in your document even if those words are not valid Inkling syntax. You can disable this in Visual Studio Code under File > Preferences > Text Editor > Suggestions > Word Based Suggestions.
Uncheck the Word Based Suggestions preference to improve the IntelliSense choices for editing Inkling files.