write a program only by a simple click
JavaScript Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
data
src
typings
web_modules/recurrentjs
.gitignore
README.md
jsconfig.json
package.json
tsconfig.json
webpack.config.js

README.md

sarad

Write a program only by a simple click

Demo

Left click to generate a code and right click to erase a code.

screenshot

How it works

Sarad is a word salad friendly programming language. Its interpreter never output any error for any generated program. Sarad code can be automatically generated by an LSTM model with RecurrentJS.

  1. Select input sentences for training from processing sample codes.
int whichBar = mouseX / barWidth;
if (whichBar != lastBar) {
  int barX = whichBar * barWidth;
  fill(barX, 100, mouseY);
  rect(barX, 0, barWidth, height);
  lastBar = whichBar;
}
  1. Convert them to sarad codes with the pde2sarad. Digits('0'-'9') are converted to 'D' and general variable names are changed to 'V0'-'V4'.
=V0 / mouseX V1
if != V0 V2
  =V3 * V0 V1
  fill/3 V3 DDD mouseY
  rect/4 V3 0 V1 height
  =V2 V0

Sarad is also a stack-oriented programming language written in a polish notation.

  1. The model is trained with the sarad-learner.

  2. Generate a code with the tained LSTM model.

if V0
  stroke/1 DDD
else
  stroke/1 0
line/4 - mouseX DD mouseX + mouseX DD mouseY
D DDD 0
vertex/3 - width DD - mouseY 1 0
  1. Assign digits to 'D', convert the operator into infix notation and eliminate dead code.
if(V0)
  stroke(656)
else
  stroke(0)
line((mouseX - 51), mouseX, (mouseX + 75), mouseY)
vertex((width - 16), (mouseY - 1), 0)

Acknowledgement

Libraries

RecurrentJS / p5.js / lz-string / lodash

License

MIT