Inkling Tips & Tricks

We’ve written a full language reference in our documentation, and that’s the source of truth. If you’re looking for a few quick pointers to get started, read on for a short introduction to Inkling. We’ll take a close look at the Cartpole sample gym.

Connecting concepts

When creating Inkling code, concepts have inputs and outputs. These are defined using the “follows”, “predicts”, and “feeds” keywords.

  • “schema” defines the variables expected, and their values. For CartPole, we call them GameState and Action. We’ve declared one for the simulator’s state, one for the action space, and there’s a third for “CartPoleConfig” which we’ll ignore. The schema is a tuple of key:type pairs.
  • The “simulator” block will populate our schema with the actual controls from the sim.
  • follows” describes the input for this concept; this can be either the name of another concept, or the special function input(<input>). Consume incoming simulator state with “follows input(<input_name>)”. When consuming the output of another concept, use “follows <concept>” instead, omitting the “input” keyword
  • predicts” describes the output of the concept, which should either fit a pre-defined schema, or a schema that is defined within this function. Examples: “predicts(Action)” or “predicts int8{0, 1} command”.
  • At least one concept should have a “feeds” statement, to declare either the next concept in the chain, or the keyword “output” to indicate that the result will be directed back to your simulator.

Read our documentation for more information about:

Common Semantic Pitfalls

The Inkling language and compiler is quite robust, but there are some semantic pitfalls that users can run into. Here’s a short list:

  • Be sure to define a schema for variables. Define the correct variable type in a schema.
  • Be sure to end code blocks with the keyword “end”.
  • Use “#” for comments, not “//” or other indicators.

Conventions for Ordering Code

Even though the Inkling compiler will consume all of your code and evaluate it a a block, it’s helpful to

  • Set schema at the beginning. Avoid anonymous schema if possible.
  • Simulators get coded next. Define the sim’s inputs and outputs here.
  • Finally, write your curriculum. If you’re using multiple curricula, start with the input and end with the output.

General notes

We love writing Inkling, and we hope you do to! The guidelines listed above will help you write the best, clearest, and most reliable code out there.

Come visit us in the forums, or file a support request at support if you’d like more information. Follow me at @bitbucketeer and Bonsai at @bonsaiai