Featured image of post SAM Space – Educational App

SAM Space – Educational App

This was a really interesting project to work on as it merges the virtual and physical worlds. These magical Bluetooth blocks get paired with your device and connected in various ways that can execute logic. It was mainly used in schools as an introduction to programming.

Simple Example

  • Button Block
  • Light Block

When you press on the button and the light will turn green.

Role

My role was mainly building the SAM Space App. But I also had to work on a variety of prototypes that explore the capabilities of this technology.

Prototypes

LED Matrix – Animations

I made a little animation app that would allow you to make animations in 9x9+. It would send the frames over by Bluetooth and you could watch your animations loop on the physical LED matrix.

Snappable Bricks

SAM Space App has been limited in its ability to do anything more complex, basic things that are possible with programming. I’ve implemented a rough implementation of snappable bricks with Abstract Syntax Tree. It has proven to be a start in the right direction.

Core Code Example

Some example code in C#.

// Base interface for all expressions.
public interface IExpression
{
  Value Evaluate(Dictionary<string, Value> env);
  string Tokenize(Dictionary<string, Value> env);
}

// If statement (IF Test THEN Consequence ELSE Alternative).
public class Conditional : IExpression
{
  public readonly IExpression Test;
  public readonly IExpression Conseq;
  public readonly IExpression Alt;

  public Conditional(IExpression test, IExpression conseq, IExpression alt)
  {
    Test = test;
    Conseq = conseq;
    Alt = alt;
  }

  public Value Evaluate(Dictionary<string, Value> env)
  {
    var test = Test.Evaluate(env) as Bool;
    return test.Value
        ? Conseq.Evaluate(env)
        : Alt.Evaluate(env);
  }

  public string Tokenize(Dictionary<string, Value> env)
  {
    return string.Format(
      "if ({0}) {{\n    {1}\n}} else {{\n    {2}\n}}\n",
      Test.Tokenize(env),
      Conseq.Tokenize(env),
      Alt.Tokenize(env)
    );
  }
}

Test Code Example

// A Fibonacci example with ASTs.
void Fibonacci()
{
    var env = new Dictionary<string, Value>()
    {
        { "x", new Number(0) }
    };

    var x = new Variable("x");

    var fib = new Function("fib", new Conditional(
    new BinaryOperation(x, new Number(1), "<="),
    new Number(1),
    new BinaryOperation(new Call(new Variable("fib"), new BinaryOperation(x, new Number(1), "-")),
                        new Call(new Variable("fib"), new BinaryOperation(x, new Number(2), "-")), "+")), "x");

    IExpression exp = new Call(fib, new Number(10));
    Value result = exp.Evaluate(env);

    Debug.Log(result);
}

You would not need to write code like this yourself. There is a visual layer that constructs it on the fly as you drag and snap bricks together.

Augmented Reality

We tried adding an AR layer on top of the physical blocks. This, in theory, would allow you to control an object in the physical world that would look different on screen. It failed due to AR being unstable at the time.

Video

Last updated on Feb 02, 2021 11:03 UTC
Built with Hugo
Theme Stack designed by Jimmy