Giter Club home page Giter Club logo

etoma's Introduction

Etoma

Erlang automata playground with websocket-driven visualization

Quick start

This project uses rebar to manage dependencies and compile.

./rebar get-deps
./rebar compile
./rebar generate
rel/etoma/bin/etoma console

Then point your browser at http://localhost:8080/. Note, if you modify any of the javascript files (in apps/etoma_sock/priv), you can copy them to the built release (without having to completely recompile and build) by running rake static.

Create an object with id = 0 at (x,y) = (100, 100) with a circular behavior via the erlang console:

(etoma@127.0.0.1)1> etoma:new(0, 100, 100, etoma_behavior:circular(5, 0.25)).
{ok,<0.1176.0>}

Change the behavior of the object to add noise by first getting the behavior and then composing it with a noise generator:

(etoma@127.0.0.1)2> {ok, C} = etoma:get_behavior(0).
{ok,#Fun<etoma_behavior.1.102839409>}
(etoma@127.0.0.1)3> NoisyCircle = etoma_behavior:compose(C, etoma_behavior:normal_walk(5)).
#Fun<etoma_behavior.5.102839409>
(etoma@127.0.0.1)4> etoma:change_behavior(0, NoisyCircle).
ok

Stop the object by replacing its behavior with a stationary function:

(etoma@127.0.0.1)5> etoma:change_behavior(0, etoma_behavior:stationary()).
ok

Background

The basic websocket framework is taken from the Cowboy websocket example. Animation is via Paper.js.

I built this project to explore using Erlang to program simple dynamic objects, with the idea that each object would be an Erlang process and that "behavior" would be defined by functions and modifyable using ideas from functional programming.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.