sarad
Write a program only by a simple click
Demo
Left click to generate a code and right click to erase a code.
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.
- 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;
}
- 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.
-
The model is trained with the sarad-learner.
-
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
- 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