From cac479d6ae307f036f706a2f60a916026c9e1637 Mon Sep 17 00:00:00 2001 From: Elijah Cohen Date: Tue, 5 Apr 2022 18:46:05 -0500 Subject: [PATCH] cleanup, added reflection, couple more demos --- demos.js | 14 ++++++++++---- grid.js | 8 ++++++++ index.html | 1 + play.js | 25 +++++++++++++++---------- wireworld.js | 51 +++++++++++++++------------------------------------ 5 files changed, 49 insertions(+), 50 deletions(-) diff --git a/demos.js b/demos.js index bfcc33c..ae2a759 100644 --- a/demos.js +++ b/demos.js @@ -22,11 +22,17 @@ let utils = '[{"q":-2,"r":12,"state":"off"},{"q":-2,"r":11,"state":"off"},{"q":- let timers = '[{"q":5,"r":-4,"state":"off"},{"q":4,"r":-4,"state":"off"},{"q":3,"r":-4,"state":"off"},{"q":2,"r":-4,"state":"off"},{"q":1,"r":-4,"state":"off"},{"q":0,"r":-3,"state":"off"},{"q":-1,"r":-2,"state":"off"},{"q":-2,"r":-1,"state":"off"},{"q":-3,"r":0,"state":"off"},{"q":-3,"r":1,"state":"off"},{"q":-3,"r":2,"state":"off"},{"q":-3,"r":3,"state":"off"},{"q":-3,"r":4,"state":"off"},{"q":1,"r":5,"state":"off"},{"q":2,"r":4,"state":"off"},{"q":3,"r":3,"state":"off"},{"q":4,"r":2,"state":"off"},{"q":5,"r":1,"state":"off"},{"q":6,"r":0,"state":"off"},{"q":6,"r":-1,"state":"off"},{"q":6,"r":-2,"state":"off"},{"q":6,"r":-3,"state":"off"},{"q":6,"r":-4,"state":"off"},{"q":-3,"r":5,"state":"off"},{"q":-2,"r":5,"state":"off"},{"q":-1,"r":5,"state":"head"},{"q":0,"r":5,"state":"tail"},{"q":1,"r":6,"state":"off"},{"q":1,"r":7,"state":"off"},{"q":1,"r":8,"state":"tail"},{"q":2,"r":7,"state":"tail"},{"q":3,"r":6,"state":"tail"},{"q":4,"r":5,"state":"tail"},{"q":6,"r":3,"state":"off"},{"q":7,"r":2,"state":"off"},{"q":8,"r":1,"state":"off"},{"q":9,"r":0,"state":"off"},{"q":9,"r":-1,"state":"off"},{"q":9,"r":-2,"state":"off"},{"q":9,"r":-3,"state":"off"},{"q":9,"r":-5,"state":"tail"},{"q":9,"r":-6,"state":"tail"},{"q":9,"r":-7,"state":"tail"},{"q":9,"r":-8,"state":"tail"},{"q":8,"r":-8,"state":"tail"},{"q":7,"r":-8,"state":"tail"},{"q":6,"r":-8,"state":"tail"},{"q":4,"r":-8,"state":"off"},{"q":3,"r":-8,"state":"off"},{"q":2,"r":-8,"state":"off"},{"q":1,"r":-8,"state":"off"},{"q":0,"r":-7,"state":"off"},{"q":-1,"r":-6,"state":"off"},{"q":-2,"r":-5,"state":"off"},{"q":-4,"r":-3,"state":"tail"},{"q":-5,"r":-2,"state":"tail"},{"q":-6,"r":-1,"state":"tail"},{"q":-7,"r":0,"state":"tail"},{"q":-7,"r":1,"state":"tail"},{"q":-7,"r":2,"state":"tail"},{"q":-7,"r":3,"state":"tail"},{"q":-7,"r":5,"state":"off"},{"q":-7,"r":6,"state":"off"},{"q":-7,"r":7,"state":"off"},{"q":-7,"r":8,"state":"off"},{"q":-6,"r":8,"state":"off"},{"q":-5,"r":8,"state":"off"},{"q":-4,"r":8,"state":"off"},{"q":-2,"r":8,"state":"tail"},{"q":-1,"r":8,"state":"tail"},{"q":0,"r":8,"state":"tail"},{"q":-1,"r":30,"state":"off"},{"q":4,"r":27,"state":"off"},{"q":3,"r":25,"state":"off"},{"q":6,"r":23,"state":"off"},{"q":1,"r":23,"state":"off"},{"q":1,"r":22,"state":"off"},{"q":4,"r":35,"state":"off"},{"q":9,"r":28,"state":"off"},{"q":1,"r":21,"state":"off"},{"q":-9,"r":31,"state":"off"},{"q":-1,"r":39,"state":"off"},{"q":6,"r":34,"state":"off"},{"q":8,"r":32,"state":"off"},{"q":9,"r":31,"state":"off"},{"q":11,"r":29,"state":"off"},{"q":11,"r":26,"state":"off"},{"q":6,"r":36,"state":"off"},{"q":8,"r":34,"state":"off"},{"q":9,"r":33,"state":"off"},{"q":10,"r":32,"state":"off"},{"q":3,"r":18,"state":"tail"},{"q":-1,"r":19,"state":"head"},{"q":5,"r":38,"state":"off"},{"q":13,"r":24,"state":"tail"},{"q":-2,"r":19,"state":"off"},{"q":6,"r":38,"state":"tail"},{"q":8,"r":36,"state":"tail"},{"q":10,"r":34,"state":"off"},{"q":11,"r":33,"state":"off"},{"q":12,"r":32,"state":"off"},{"q":13,"r":31,"state":"off"},{"q":5,"r":16,"state":"tail"},{"q":-1,"r":17,"state":"off"},{"q":-5,"r":21,"state":"off"},{"q":-6,"r":22,"state":"off"},{"q":-1,"r":15,"state":"off"},{"q":-3,"r":17,"state":"off"},{"q":-5,"r":19,"state":"off"},{"q":-6,"r":20,"state":"off"},{"q":-7,"r":21,"state":"off"},{"q":-8,"r":22,"state":"off"},{"q":-10,"r":46,"state":"tail"},{"q":23,"r":0,"state":"off"},{"q":22,"r":-1,"state":"tail"},{"q":21,"r":1,"state":"off"},{"q":23,"r":1,"state":"off"},{"q":24,"r":-1,"state":"off"},{"q":23,"r":-2,"state":"head"},{"q":21,"r":-1,"state":"off"},{"q":20,"r":1,"state":"off"},{"q":21,"r":2,"state":"off"},{"q":24,"r":1,"state":"off"},{"q":25,"r":-1,"state":"off"},{"q":23,"r":-3,"state":"off"},{"q":21,"r":-2,"state":"off"},{"q":19,"r":2,"state":"off"},{"q":20,"r":3,"state":"off"},{"q":25,"r":1,"state":"off"},{"q":26,"r":-1,"state":"off"},{"q":23,"r":-4,"state":"off"},{"q":21,"r":-3,"state":"off"},{"q":18,"r":3,"state":"off"},{"q":19,"r":4,"state":"off"},{"q":26,"r":1,"state":"off"},{"q":27,"r":-1,"state":"off"},{"q":23,"r":-5,"state":"off"},{"q":21,"r":-4,"state":"off"},{"q":17,"r":4,"state":"off"},{"q":18,"r":5,"state":"off"},{"q":22,"r":6,"state":"tail"},{"q":23,"r":5,"state":"off"},{"q":24,"r":4,"state":"off"},{"q":25,"r":3,"state":"off"},{"q":26,"r":2,"state":"off"},{"q":28,"r":-2,"state":"off"},{"q":28,"r":-3,"state":"off"},{"q":28,"r":-4,"state":"off"},{"q":28,"r":-5,"state":"off"},{"q":28,"r":-6,"state":"off"},{"q":27,"r":-6,"state":"off"},{"q":26,"r":-6,"state":"off"},{"q":25,"r":-6,"state":"off"},{"q":24,"r":-6,"state":"off"},{"q":20,"r":-4,"state":"off"},{"q":19,"r":-3,"state":"off"},{"q":18,"r":-2,"state":"off"},{"q":17,"r":-1,"state":"off"},{"q":16,"r":0,"state":"off"},{"q":16,"r":1,"state":"off"},{"q":16,"r":2,"state":"off"},{"q":16,"r":3,"state":"off"},{"q":16,"r":4,"state":"off"},{"q":18,"r":6,"state":"off"},{"q":19,"r":6,"state":"off"},{"q":20,"r":6,"state":"off"},{"q":21,"r":6,"state":"head"},{"q":22,"r":7,"state":"off"},{"q":22,"r":8,"state":"tail"},{"q":23,"r":7,"state":"tail"},{"q":24,"r":6,"state":"tail"},{"q":25,"r":5,"state":"tail"},{"q":27,"r":3,"state":"off"},{"q":28,"r":2,"state":"off"},{"q":29,"r":1,"state":"off"},{"q":30,"r":0,"state":"off"},{"q":30,"r":-1,"state":"off"},{"q":30,"r":-2,"state":"off"},{"q":30,"r":-3,"state":"off"},{"q":30,"r":-5,"state":"tail"},{"q":30,"r":-6,"state":"tail"},{"q":30,"r":-7,"state":"tail"},{"q":30,"r":-8,"state":"tail"},{"q":29,"r":-8,"state":"tail"},{"q":28,"r":-8,"state":"tail"},{"q":27,"r":-8,"state":"tail"},{"q":25,"r":-8,"state":"off"},{"q":24,"r":-8,"state":"off"},{"q":23,"r":-8,"state":"off"},{"q":22,"r":-8,"state":"off"},{"q":21,"r":-7,"state":"off"},{"q":20,"r":-6,"state":"off"},{"q":19,"r":-5,"state":"off"},{"q":17,"r":-3,"state":"tail"},{"q":16,"r":-2,"state":"tail"},{"q":15,"r":-1,"state":"tail"},{"q":14,"r":0,"state":"tail"},{"q":14,"r":1,"state":"tail"},{"q":14,"r":2,"state":"tail"},{"q":14,"r":3,"state":"tail"},{"q":14,"r":5,"state":"off"},{"q":14,"r":6,"state":"off"},{"q":14,"r":7,"state":"off"},{"q":14,"r":8,"state":"off"},{"q":15,"r":8,"state":"off"},{"q":16,"r":8,"state":"off"},{"q":17,"r":8,"state":"off"},{"q":19,"r":8,"state":"tail"},{"q":20,"r":8,"state":"tail"},{"q":21,"r":8,"state":"tail"},{"q":-4,"r":-6,"state":"off"},{"q":-3,"r":-7,"state":"off"},{"q":-2,"r":-9,"state":"off"},{"q":-2,"r":-8,"state":"off"},{"q":-1,"r":-9,"state":"off"},{"q":-5,"r":-5,"state":"off"},{"q":17,"r":-8,"state":"off"},{"q":15,"r":-4,"state":"off"},{"q":16,"r":-4,"state":"off"},{"q":14,"r":-4,"state":"off"},{"q":15,"r":-5,"state":"off"},{"q":16,"r":-6,"state":"off"},{"q":17,"r":-7,"state":"off"},{"q":16,"r":-8,"state":"off"},{"q":15,"r":-7,"state":"off"},{"q":49,"r":-6,"state":"off"},{"q":49,"r":-7,"state":"off"},{"q":48,"r":-7,"state":"off"},{"q":44,"r":-7,"state":"off"},{"q":43,"r":-7,"state":"off"},{"q":42,"r":-6,"state":"off"},{"q":38,"r":-2,"state":"off"},{"q":37,"r":-1,"state":"off"},{"q":37,"r":0,"state":"off"},{"q":37,"r":4,"state":"off"},{"q":37,"r":5,"state":"off"},{"q":38,"r":5,"state":"off"},{"q":44,"r":5,"state":"off"},{"q":49,"r":0,"state":"off"},{"q":43,"r":7,"state":"tail"},{"q":45,"r":5,"state":"off"},{"q":49,"r":1,"state":"off"},{"q":51,"r":-1,"state":"off"},{"q":51,"r":-2,"state":"off"},{"q":51,"r":-3,"state":"off"},{"q":51,"r":-4,"state":"off"},{"q":51,"r":-6,"state":"tail"},{"q":51,"r":-7,"state":"tail"},{"q":51,"r":-8,"state":"tail"},{"q":51,"r":-9,"state":"tail"},{"q":50,"r":-9,"state":"tail"},{"q":49,"r":-9,"state":"tail"},{"q":48,"r":-9,"state":"tail"},{"q":46,"r":-9,"state":"off"},{"q":45,"r":-9,"state":"off"},{"q":44,"r":-9,"state":"off"},{"q":43,"r":-9,"state":"off"},{"q":42,"r":-8,"state":"off"},{"q":41,"r":-7,"state":"off"},{"q":40,"r":-6,"state":"off"},{"q":38,"r":-4,"state":"tail"},{"q":37,"r":-3,"state":"tail"},{"q":36,"r":-2,"state":"tail"},{"q":35,"r":-1,"state":"tail"},{"q":35,"r":0,"state":"tail"},{"q":35,"r":1,"state":"tail"},{"q":35,"r":2,"state":"tail"},{"q":35,"r":4,"state":"off"},{"q":35,"r":5,"state":"off"},{"q":35,"r":6,"state":"off"},{"q":35,"r":7,"state":"off"},{"q":36,"r":7,"state":"off"},{"q":37,"r":7,"state":"off"},{"q":38,"r":7,"state":"off"},{"q":40,"r":7,"state":"tail"},{"q":41,"r":7,"state":"tail"},{"q":42,"r":7,"state":"tail"},{"q":51,"r":13,"state":"tail"},{"q":52,"r":12,"state":"off"},{"q":56,"r":8,"state":"off"},{"q":57,"r":7,"state":"off"},{"q":57,"r":6,"state":"off"},{"q":57,"r":2,"state":"off"},{"q":57,"r":1,"state":"off"},{"q":56,"r":1,"state":"off"},{"q":45,"r":12,"state":"off"},{"q":45,"r":13,"state":"off"},{"q":46,"r":13,"state":"off"},{"q":50,"r":13,"state":"head"},{"q":51,"r":14,"state":"off"},{"q":50,"r":1,"state":"off"},{"q":45,"r":6,"state":"off"},{"q":51,"r":15,"state":"tail"},{"q":52,"r":14,"state":"tail"},{"q":53,"r":13,"state":"tail"},{"q":54,"r":12,"state":"tail"},{"q":56,"r":10,"state":"off"},{"q":57,"r":9,"state":"off"},{"q":58,"r":8,"state":"off"},{"q":59,"r":7,"state":"off"},{"q":59,"r":6,"state":"off"},{"q":59,"r":5,"state":"off"},{"q":59,"r":4,"state":"off"},{"q":59,"r":2,"state":"tail"},{"q":59,"r":1,"state":"tail"},{"q":59,"r":0,"state":"tail"},{"q":59,"r":-1,"state":"tail"},{"q":58,"r":-1,"state":"tail"},{"q":57,"r":-1,"state":"tail"},{"q":56,"r":-1,"state":"tail"},{"q":54,"r":-1,"state":"off"},{"q":53,"r":-1,"state":"off"},{"q":52,"r":-1,"state":"off"},{"q":43,"r":8,"state":"tail"},{"q":43,"r":9,"state":"tail"},{"q":43,"r":10,"state":"tail"},{"q":43,"r":12,"state":"off"},{"q":43,"r":13,"state":"off"},{"q":43,"r":14,"state":"off"},{"q":43,"r":15,"state":"off"},{"q":44,"r":15,"state":"off"},{"q":45,"r":15,"state":"off"},{"q":46,"r":15,"state":"off"},{"q":48,"r":15,"state":"tail"},{"q":49,"r":15,"state":"tail"},{"q":50,"r":15,"state":"tail"},{"q":35,"r":23,"state":"tail"},{"q":36,"r":22,"state":"tail"},{"q":37,"r":21,"state":"tail"},{"q":38,"r":20,"state":"tail"},{"q":40,"r":18,"state":"off"},{"q":41,"r":17,"state":"off"},{"q":42,"r":16,"state":"off"},{"q":34,"r":8,"state":"off"},{"q":33,"r":9,"state":"off"},{"q":32,"r":10,"state":"off"},{"q":30,"r":12,"state":"tail"},{"q":29,"r":13,"state":"tail"},{"q":28,"r":14,"state":"tail"},{"q":27,"r":15,"state":"tail"},{"q":27,"r":16,"state":"tail"},{"q":27,"r":17,"state":"tail"},{"q":27,"r":18,"state":"tail"},{"q":27,"r":20,"state":"off"},{"q":27,"r":21,"state":"off"},{"q":27,"r":22,"state":"off"},{"q":27,"r":23,"state":"off"},{"q":28,"r":23,"state":"off"},{"q":29,"r":23,"state":"off"},{"q":30,"r":23,"state":"off"},{"q":32,"r":23,"state":"tail"},{"q":33,"r":23,"state":"tail"},{"q":34,"r":23,"state":"tail"},{"q":42,"r":-5,"state":"off"},{"q":39,"r":-2,"state":"off"},{"q":38,"r":3,"state":"tail"},{"q":38,"r":2,"state":"head"},{"q":38,"r":1,"state":"off"},{"q":38,"r":0,"state":"off"},{"q":47,"r":-6,"state":"off"},{"q":46,"r":-6,"state":"off"},{"q":45,"r":-6,"state":"off"},{"q":44,"r":-6,"state":"off"},{"q":50,"r":12,"state":"off"},{"q":49,"r":12,"state":"off"},{"q":48,"r":12,"state":"off"},{"q":47,"r":12,"state":"off"},{"q":52,"r":11,"state":"off"},{"q":55,"r":8,"state":"off"},{"q":56,"r":6,"state":"off"},{"q":56,"r":5,"state":"off"},{"q":56,"r":4,"state":"off"},{"q":56,"r":3,"state":"off"},{"q":40,"r":-2,"state":"off"},{"q":42,"r":-4,"state":"off"},{"q":54,"r":8,"state":"off"},{"q":53,"r":9,"state":"off"},{"q":52,"r":10,"state":"off"},{"q":41,"r":-2,"state":"off"},{"q":42,"r":-3,"state":"off"},{"q":39,"r":4,"state":"off"},{"q":40,"r":4,"state":"off"},{"q":41,"r":4,"state":"off"},{"q":42,"r":4,"state":"off"},{"q":43,"r":4,"state":"off"},{"q":44,"r":4,"state":"off"},{"q":46,"r":6,"state":"off"},{"q":46,"r":11,"state":"off"},{"q":46,"r":10,"state":"off"},{"q":46,"r":9,"state":"off"},{"q":46,"r":8,"state":"off"},{"q":46,"r":7,"state":"off"},{"q":50,"r":2,"state":"off"},{"q":51,"r":2,"state":"off"},{"q":52,"r":2,"state":"off"},{"q":53,"r":2,"state":"off"},{"q":54,"r":2,"state":"off"},{"q":55,"r":2,"state":"off"},{"q":48,"r":0,"state":"head"},{"q":48,"r":-1,"state":"tail"},{"q":48,"r":-2,"state":"off"},{"q":48,"r":-3,"state":"off"},{"q":48,"r":-5,"state":"off"},{"q":48,"r":-4,"state":"off"},{"q":56,"r":-8,"state":"off"},{"q":57,"r":-8,"state":"off"},{"q":57,"r":-7,"state":"off"},{"q":56,"r":-6,"state":"off"},{"q":55,"r":-6,"state":"off"},{"q":56,"r":-5,"state":"off"},{"q":55,"r":-4,"state":"off"},{"q":54,"r":-4,"state":"off"},{"q":26,"r":42,"state":"tail"},{"q":26,"r":43,"state":"tail"},{"q":25,"r":42,"state":"tail"},{"q":26,"r":44,"state":"tail"},{"q":28,"r":42,"state":"off"},{"q":28,"r":41,"state":"off"},{"q":28,"r":40,"state":"off"},{"q":27,"r":40,"state":"off"},{"q":26,"r":40,"state":"off"},{"q":24,"r":42,"state":"tail"},{"q":26,"r":45,"state":"tail"},{"q":28,"r":43,"state":"off"},{"q":25,"r":40,"state":"off"},{"q":23,"r":42,"state":"tail"},{"q":28,"r":44,"state":"off"},{"q":30,"r":42,"state":"off"},{"q":30,"r":41,"state":"off"},{"q":30,"r":40,"state":"off"},{"q":30,"r":39,"state":"off"},{"q":28,"r":38,"state":"off"},{"q":27,"r":38,"state":"off"},{"q":26,"r":38,"state":"head"},{"q":24,"r":40,"state":"tail"},{"q":26,"r":47,"state":"off"},{"q":28,"r":45,"state":"off"},{"q":30,"r":43,"state":"off"},{"q":31,"r":38,"state":"off"},{"q":29,"r":37,"state":"off"},{"q":25,"r":38,"state":"tail"},{"q":23,"r":40,"state":"head"},{"q":21,"r":42,"state":"off"},{"q":26,"r":48,"state":"off"},{"q":28,"r":46,"state":"off"},{"q":30,"r":44,"state":"off"},{"q":32,"r":42,"state":"off"},{"q":32,"r":41,"state":"off"},{"q":32,"r":38,"state":"off"},{"q":32,"r":36,"state":"off"},{"q":30,"r":36,"state":"off"},{"q":26,"r":36,"state":"off"},{"q":24,"r":38,"state":"off"},{"q":22,"r":40,"state":"off"},{"q":20,"r":42,"state":"off"},{"q":26,"r":49,"state":"off"},{"q":29,"r":46,"state":"off"},{"q":30,"r":45,"state":"off"},{"q":32,"r":43,"state":"off"},{"q":33,"r":40,"state":"off"},{"q":33,"r":38,"state":"off"},{"q":33,"r":36,"state":"off"},{"q":32,"r":35,"state":"off"},{"q":30,"r":35,"state":"off"},{"q":27,"r":35,"state":"off"},{"q":25,"r":36,"state":"off"},{"q":24,"r":37,"state":"off"},{"q":21,"r":40,"state":"off"},{"q":19,"r":42,"state":"off"},{"q":26,"r":50,"state":"off"},{"q":32,"r":44,"state":"off"},{"q":34,"r":40,"state":"off"},{"q":34,"r":38,"state":"off"},{"q":34,"r":36,"state":"off"},{"q":34,"r":34,"state":"off"},{"q":32,"r":34,"state":"off"},{"q":30,"r":34,"state":"off"},{"q":27,"r":34,"state":"off"},{"q":20,"r":40,"state":"off"},{"q":18,"r":42,"state":"off"},{"q":27,"r":50,"state":"off"},{"q":30,"r":47,"state":"off"},{"q":31,"r":46,"state":"off"},{"q":33,"r":44,"state":"off"},{"q":35,"r":40,"state":"off"},{"q":35,"r":38,"state":"off"},{"q":35,"r":36,"state":"off"},{"q":35,"r":34,"state":"off"},{"q":34,"r":33,"state":"off"},{"q":32,"r":33,"state":"off"},{"q":30,"r":33,"state":"off"},{"q":27,"r":33,"state":"off"},{"q":26,"r":33,"state":"off"},{"q":25,"r":34,"state":"off"},{"q":24,"r":35,"state":"off"},{"q":23,"r":36,"state":"off"},{"q":20,"r":39,"state":"off"},{"q":18,"r":41,"state":"off"},{"q":17,"r":43,"state":"off"},{"q":25,"r":51,"state":"off"},{"q":28,"r":50,"state":"off"},{"q":30,"r":48,"state":"off"},{"q":32,"r":46,"state":"off"},{"q":34,"r":44,"state":"off"},{"q":35,"r":43,"state":"off"},{"q":36,"r":41,"state":"off"},{"q":36,"r":40,"state":"off"},{"q":36,"r":38,"state":"off"},{"q":36,"r":36,"state":"off"},{"q":36,"r":34,"state":"off"},{"q":34,"r":32,"state":"off"},{"q":32,"r":32,"state":"off"},{"q":30,"r":32,"state":"off"},{"q":22,"r":36,"state":"off"},{"q":20,"r":38,"state":"off"},{"q":18,"r":40,"state":"off"},{"q":16,"r":44,"state":"off"},{"q":24,"r":52,"state":"off"},{"q":29,"r":50,"state":"off"},{"q":31,"r":48,"state":"off"},{"q":33,"r":46,"state":"off"},{"q":36,"r":43,"state":"off"},{"q":37,"r":41,"state":"off"},{"q":37,"r":38,"state":"off"},{"q":37,"r":36,"state":"off"},{"q":37,"r":34,"state":"off"},{"q":34,"r":31,"state":"off"},{"q":32,"r":31,"state":"off"},{"q":30,"r":31,"state":"off"},{"q":22,"r":35,"state":"off"},{"q":20,"r":37,"state":"off"},{"q":18,"r":39,"state":"off"},{"q":15,"r":45,"state":"off"},{"q":23,"r":53,"state":"off"},{"q":32,"r":48,"state":"off"},{"q":34,"r":46,"state":"off"},{"q":35,"r":45,"state":"off"},{"q":36,"r":44,"state":"off"},{"q":38,"r":40,"state":"off"},{"q":38,"r":39,"state":"tail"},{"q":38,"r":38,"state":"head"},{"q":38,"r":36,"state":"off"},{"q":38,"r":31,"state":"off"},{"q":32,"r":30,"state":"head"},{"q":30,"r":30,"state":"off"},{"q":29,"r":30,"state":"off"},{"q":28,"r":30,"state":"off"},{"q":27,"r":30,"state":"off"},{"q":26,"r":30,"state":"off"},{"q":25,"r":31,"state":"off"},{"q":22,"r":34,"state":"off"},{"q":20,"r":36,"state":"off"},{"q":31,"r":50,"state":"tail"},{"q":33,"r":48,"state":"head"},{"q":39,"r":36,"state":"off"},{"q":39,"r":34,"state":"tail"},{"q":39,"r":31,"state":"off"},{"q":39,"r":29,"state":"off"},{"q":34,"r":29,"state":"tail"},{"q":32,"r":29,"state":"tail"},{"q":24,"r":31,"state":"off"},{"q":22,"r":33,"state":"off"},{"q":20,"r":35,"state":"off"},{"q":18,"r":37,"state":"tail"},{"q":13,"r":47,"state":"tail"},{"q":21,"r":55,"state":"tail"},{"q":32,"r":50,"state":"tail"},{"q":34,"r":48,"state":"tail"},{"q":35,"r":47,"state":"off"},{"q":36,"r":46,"state":"off"},{"q":37,"r":45,"state":"off"},{"q":38,"r":44,"state":"off"},{"q":39,"r":43,"state":"off"},{"q":40,"r":42,"state":"off"},{"q":40,"r":41,"state":"off"},{"q":40,"r":40,"state":"off"},{"q":40,"r":39,"state":"off"},{"q":40,"r":38,"state":"off"},{"q":40,"r":37,"state":"off"},{"q":40,"r":36,"state":"off"},{"q":40,"r":34,"state":"tail"},{"q":40,"r":31,"state":"off"},{"q":40,"r":29,"state":"off"},{"q":39,"r":28,"state":"off"},{"q":34,"r":28,"state":"tail"},{"q":32,"r":28,"state":"off"},{"q":31,"r":28,"state":"off"},{"q":30,"r":28,"state":"off"},{"q":29,"r":28,"state":"off"},{"q":28,"r":28,"state":"off"},{"q":27,"r":28,"state":"off"},{"q":26,"r":28,"state":"off"},{"q":25,"r":29,"state":"off"},{"q":24,"r":30,"state":"off"},{"q":21,"r":33,"state":"off"},{"q":20,"r":34,"state":"off"},{"q":18,"r":36,"state":"tail"},{"q":12,"r":48,"state":"tail"},{"q":20,"r":56,"state":"tail"},{"q":33,"r":50,"state":"tail"},{"q":34,"r":49,"state":"off"},{"q":41,"r":34,"state":"tail"},{"q":41,"r":30,"state":"off"},{"q":41,"r":29,"state":"off"},{"q":41,"r":27,"state":"off"},{"q":40,"r":27,"state":"off"},{"q":39,"r":27,"state":"off"},{"q":34,"r":27,"state":"tail"},{"q":18,"r":35,"state":"tail"},{"q":11,"r":49,"state":"tail"},{"q":19,"r":57,"state":"tail"},{"q":34,"r":50,"state":"tail"},{"q":35,"r":49,"state":"tail"},{"q":36,"r":48,"state":"tail"},{"q":37,"r":47,"state":"tail"},{"q":39,"r":45,"state":"off"},{"q":40,"r":44,"state":"off"},{"q":41,"r":43,"state":"off"},{"q":42,"r":42,"state":"off"},{"q":42,"r":41,"state":"off"},{"q":42,"r":40,"state":"off"},{"q":42,"r":39,"state":"off"},{"q":42,"r":37,"state":"tail"},{"q":42,"r":36,"state":"tail"},{"q":42,"r":35,"state":"tail"},{"q":42,"r":34,"state":"tail"},{"q":42,"r":27,"state":"off"},{"q":34,"r":26,"state":"tail"},{"q":33,"r":26,"state":"tail"},{"q":32,"r":26,"state":"tail"},{"q":31,"r":26,"state":"tail"},{"q":29,"r":26,"state":"off"},{"q":28,"r":26,"state":"off"},{"q":27,"r":26,"state":"off"},{"q":26,"r":26,"state":"off"},{"q":25,"r":27,"state":"off"},{"q":24,"r":28,"state":"off"},{"q":23,"r":29,"state":"off"},{"q":21,"r":31,"state":"tail"},{"q":20,"r":32,"state":"tail"},{"q":19,"r":33,"state":"tail"},{"q":18,"r":34,"state":"tail"},{"q":10,"r":50,"state":"tail"},{"q":10,"r":51,"state":"tail"},{"q":10,"r":52,"state":"tail"},{"q":10,"r":53,"state":"tail"},{"q":10,"r":55,"state":"off"},{"q":10,"r":56,"state":"off"},{"q":10,"r":57,"state":"off"},{"q":10,"r":58,"state":"off"},{"q":11,"r":58,"state":"off"},{"q":12,"r":58,"state":"off"},{"q":13,"r":58,"state":"off"},{"q":15,"r":58,"state":"tail"},{"q":16,"r":58,"state":"tail"},{"q":17,"r":58,"state":"tail"},{"q":18,"r":58,"state":"tail"},{"q":-1,"r":31,"state":"off"},{"q":-1,"r":32,"state":"off"},{"q":-1,"r":33,"state":"off"},{"q":1,"r":31,"state":"off"},{"q":1,"r":30,"state":"off"},{"q":1,"r":29,"state":"off"},{"q":-1,"r":29,"state":"off"},{"q":-3,"r":31,"state":"tail"},{"q":-3,"r":32,"state":"tail"},{"q":-3,"r":33,"state":"tail"},{"q":-1,"r":34,"state":"off"},{"q":1,"r":32,"state":"off"},{"q":-2,"r":29,"state":"off"},{"q":-4,"r":31,"state":"tail"},{"q":-3,"r":34,"state":"tail"},{"q":1,"r":33,"state":"tail"},{"q":3,"r":27,"state":"off"},{"q":-1,"r":27,"state":"off"},{"q":-3,"r":29,"state":"off"},{"q":-5,"r":31,"state":"tail"},{"q":-2,"r":27,"state":"off"},{"q":-4,"r":29,"state":"off"},{"q":-6,"r":31,"state":"tail"},{"q":-3,"r":36,"state":"off"},{"q":5,"r":27,"state":"off"},{"q":5,"r":25,"state":"off"},{"q":4,"r":25,"state":"off"},{"q":1,"r":25,"state":"off"},{"q":-3,"r":27,"state":"off"},{"q":-5,"r":29,"state":"off"},{"q":-3,"r":37,"state":"off"},{"q":6,"r":27,"state":"off"},{"q":6,"r":25,"state":"off"},{"q":3,"r":24,"state":"off"},{"q":1,"r":24,"state":"off"},{"q":-4,"r":27,"state":"off"},{"q":-6,"r":29,"state":"off"},{"q":-8,"r":31,"state":"off"},{"q":-3,"r":38,"state":"off"},{"q":3,"r":35,"state":"off"},{"q":7,"r":27,"state":"off"},{"q":7,"r":25,"state":"off"},{"q":7,"r":23,"state":"off"},{"q":5,"r":23,"state":"off"},{"q":3,"r":23,"state":"off"},{"q":-5,"r":27,"state":"off"},{"q":-3,"r":39,"state":"off"},{"q":-2,"r":39,"state":"off"},{"q":0,"r":39,"state":"off"},{"q":2,"r":37,"state":"off"},{"q":8,"r":27,"state":"off"},{"q":8,"r":25,"state":"off"},{"q":8,"r":23,"state":"off"},{"q":5,"r":22,"state":"off"},{"q":3,"r":22,"state":"off"},{"q":-10,"r":31,"state":"off"},{"q":-4,"r":40,"state":"off"},{"q":3,"r":37,"state":"off"},{"q":5,"r":35,"state":"off"},{"q":7,"r":33,"state":"off"},{"q":9,"r":30,"state":"off"},{"q":9,"r":29,"state":"off"},{"q":9,"r":27,"state":"off"},{"q":9,"r":25,"state":"off"},{"q":5,"r":21,"state":"off"},{"q":3,"r":21,"state":"off"},{"q":-11,"r":31,"state":"off"},{"q":-5,"r":41,"state":"off"},{"q":2,"r":39,"state":"tail"},{"q":4,"r":37,"state":"head"},{"q":10,"r":25,"state":"off"},{"q":10,"r":23,"state":"tail"},{"q":5,"r":20,"state":"off"},{"q":3,"r":20,"state":"off"},{"q":1,"r":20,"state":"off"},{"q":-11,"r":30,"state":"off"},{"q":-12,"r":32,"state":"off"},{"q":-6,"r":42,"state":"off"},{"q":3,"r":39,"state":"tail"},{"q":5,"r":37,"state":"tail"},{"q":7,"r":35,"state":"off"},{"q":11,"r":31,"state":"off"},{"q":11,"r":30,"state":"off"},{"q":11,"r":28,"state":"off"},{"q":11,"r":27,"state":"off"},{"q":11,"r":25,"state":"off"},{"q":11,"r":23,"state":"tail"},{"q":3,"r":19,"state":"head"},{"q":1,"r":19,"state":"off"},{"q":0,"r":19,"state":"tail"},{"q":-7,"r":25,"state":"off"},{"q":-11,"r":29,"state":"off"},{"q":-13,"r":33,"state":"off"},{"q":4,"r":39,"state":"tail"},{"q":12,"r":23,"state":"tail"},{"q":5,"r":18,"state":"tail"},{"q":-7,"r":24,"state":"off"},{"q":-9,"r":26,"state":"off"},{"q":-11,"r":28,"state":"off"},{"q":-14,"r":34,"state":"off"},{"q":-8,"r":44,"state":"tail"},{"q":5,"r":39,"state":"tail"},{"q":7,"r":37,"state":"tail"},{"q":13,"r":30,"state":"off"},{"q":13,"r":29,"state":"off"},{"q":13,"r":28,"state":"off"},{"q":13,"r":26,"state":"tail"},{"q":13,"r":25,"state":"tail"},{"q":13,"r":23,"state":"tail"},{"q":5,"r":17,"state":"tail"},{"q":3,"r":17,"state":"off"},{"q":2,"r":17,"state":"off"},{"q":1,"r":17,"state":"off"},{"q":0,"r":17,"state":"off"},{"q":-3,"r":19,"state":"off"},{"q":-4,"r":20,"state":"off"},{"q":-7,"r":23,"state":"off"},{"q":-9,"r":25,"state":"off"},{"q":-9,"r":45,"state":"tail"},{"q":-2,"r":17,"state":"off"},{"q":-9,"r":24,"state":"off"},{"q":-11,"r":26,"state":"tail"},{"q":-16,"r":36,"state":"tail"},{"q":5,"r":15,"state":"tail"},{"q":4,"r":15,"state":"tail"},{"q":3,"r":15,"state":"tail"},{"q":2,"r":15,"state":"tail"},{"q":0,"r":15,"state":"off"},{"q":-4,"r":18,"state":"off"},{"q":-9,"r":23,"state":"off"},{"q":-11,"r":25,"state":"tail"},{"q":-17,"r":37,"state":"tail"},{"q":-17,"r":47,"state":"off"},{"q":-16,"r":47,"state":"off"},{"q":-14,"r":47,"state":"tail"},{"q":-13,"r":47,"state":"tail"},{"q":-12,"r":47,"state":"tail"},{"q":-11,"r":47,"state":"tail"},{"q":-2,"r":15,"state":"off"},{"q":-11,"r":24,"state":"tail"},{"q":-18,"r":38,"state":"tail"},{"q":-18,"r":47,"state":"off"},{"q":-3,"r":15,"state":"off"},{"q":-4,"r":16,"state":"off"},{"q":-5,"r":17,"state":"off"},{"q":-6,"r":18,"state":"off"},{"q":-8,"r":20,"state":"tail"},{"q":-9,"r":21,"state":"tail"},{"q":-10,"r":22,"state":"tail"},{"q":-11,"r":23,"state":"tail"},{"q":-19,"r":39,"state":"tail"},{"q":-19,"r":40,"state":"tail"},{"q":-19,"r":41,"state":"tail"},{"q":-19,"r":42,"state":"tail"},{"q":-19,"r":44,"state":"off"},{"q":-19,"r":45,"state":"off"},{"q":-19,"r":46,"state":"off"},{"q":-19,"r":47,"state":"off"},{"q":2,"r":28,"state":"off"},{"q":0,"r":26,"state":"off"},{"q":2,"r":36,"state":"off"},{"q":0,"r":34,"state":"head"},{"q":-6,"r":28,"state":"off"},{"q":-8,"r":26,"state":"off"},{"q":12,"r":16,"state":"off"},{"q":11,"r":17,"state":"off"},{"q":10,"r":18,"state":"off"},{"q":11,"r":18,"state":"off"},{"q":12,"r":18,"state":"off"},{"q":13,"r":17,"state":"off"},{"q":14,"r":16,"state":"off"},{"q":11,"r":19,"state":"off"},{"q":10,"r":20,"state":"off"}]' +let mini_and = '[{"q":3,"r":0,"state":"off"},{"q":3,"r":1,"state":"off"},{"q":4,"r":0,"state":"off"},{"q":4,"r":-1,"state":"off"},{"q":2,"r":0,"state":"off"},{"q":2,"r":1,"state":"off"},{"q":3,"r":2,"state":"off"},{"q":5,"r":-2,"state":"off"},{"q":1,"r":0,"state":"off"},{"q":4,"r":2,"state":"off"},{"q":6,"r":-2,"state":"off"},{"q":5,"r":-3,"state":"off"},{"q":1,"r":-1,"state":"off"},{"q":0,"r":1,"state":"off"},{"q":2,"r":3,"state":"off"},{"q":3,"r":4,"state":"off"},{"q":4,"r":3,"state":"off"},{"q":7,"r":-3,"state":"off"},{"q":7,"r":-4,"state":"off"},{"q":6,"r":-4,"state":"off"},{"q":0,"r":-1,"state":"off"},{"q":-1,"r":0,"state":"off"},{"q":-1,"r":1,"state":"off"},{"q":2,"r":4,"state":"off"},{"q":3,"r":5,"state":"off"},{"q":4,"r":4,"state":"off"},{"q":6,"r":2,"state":"off"},{"q":7,"r":1,"state":"off"},{"q":8,"r":0,"state":"off"},{"q":8,"r":-4,"state":"off"},{"q":8,"r":-5,"state":"off"},{"q":7,"r":-5,"state":"off"},{"q":-1,"r":-1,"state":"off"},{"q":-2,"r":0,"state":"off"},{"q":-2,"r":1,"state":"off"},{"q":-2,"r":5,"state":"off"},{"q":-1,"r":5,"state":"off"},{"q":0,"r":5,"state":"off"},{"q":2,"r":5,"state":"off"},{"q":3,"r":6,"state":"off"},{"q":5,"r":4,"state":"off"},{"q":6,"r":3,"state":"off"},{"q":8,"r":1,"state":"off"},{"q":9,"r":0,"state":"off"},{"q":9,"r":-6,"state":"off"},{"q":-3,"r":0,"state":"off"},{"q":-3,"r":6,"state":"off"},{"q":-2,"r":6,"state":"off"},{"q":0,"r":6,"state":"off"},{"q":1,"r":6,"state":"off"},{"q":7,"r":3,"state":"off"},{"q":8,"r":2,"state":"off"},{"q":9,"r":1,"state":"off"},{"q":10,"r":-1,"state":"off"},{"q":10,"r":-2,"state":"off"},{"q":10,"r":-3,"state":"off"},{"q":10,"r":-4,"state":"off"},{"q":10,"r":-5,"state":"off"},{"q":10,"r":-6,"state":"off"},{"q":10,"r":-7,"state":"off"},{"q":-4,"r":0,"state":"off"},{"q":-4,"r":1,"state":"off"},{"q":-4,"r":2,"state":"off"},{"q":-4,"r":3,"state":"off"},{"q":-4,"r":4,"state":"off"},{"q":-4,"r":5,"state":"off"},{"q":-4,"r":6,"state":"off"},{"q":-3,"r":7,"state":"off"},{"q":-2,"r":7,"state":"off"},{"q":-1,"r":7,"state":"off"},{"q":10,"r":-8,"state":"head"},{"q":-4,"r":-1,"state":"head"}]' + +let memory = '[{"q":10,"r":31,"state":"off"},{"q":10,"r":30,"state":"off"},{"q":9,"r":32,"state":"off"},{"q":9,"r":33,"state":"off"},{"q":12,"r":35,"state":"off"},{"q":10,"r":29,"state":"off"},{"q":9,"r":30,"state":"off"},{"q":8,"r":31,"state":"off"},{"q":8,"r":32,"state":"off"},{"q":8,"r":34,"state":"off"},{"q":8,"r":35,"state":"off"},{"q":9,"r":35,"state":"off"},{"q":10,"r":35,"state":"off"},{"q":13,"r":35,"state":"off"},{"q":9,"r":29,"state":"off"},{"q":8,"r":30,"state":"off"},{"q":7,"r":36,"state":"off"},{"q":8,"r":36,"state":"off"},{"q":10,"r":36,"state":"off"},{"q":11,"r":36,"state":"off"},{"q":12,"r":37,"state":"off"},{"q":13,"r":36,"state":"off"},{"q":14,"r":35,"state":"off"},{"q":9,"r":28,"state":"off"},{"q":6,"r":32,"state":"off"},{"q":6,"r":33,"state":"off"},{"q":6,"r":34,"state":"off"},{"q":6,"r":36,"state":"off"},{"q":7,"r":37,"state":"off"},{"q":8,"r":37,"state":"off"},{"q":9,"r":37,"state":"off"},{"q":11,"r":37,"state":"off"},{"q":13,"r":37,"state":"off"},{"q":14,"r":36,"state":"off"},{"q":9,"r":27,"state":"off"},{"q":5,"r":31,"state":"off"},{"q":5,"r":32,"state":"off"},{"q":5,"r":34,"state":"off"},{"q":5,"r":35,"state":"off"},{"q":5,"r":36,"state":"off"},{"q":15,"r":36,"state":"off"},{"q":16,"r":35,"state":"off"},{"q":18,"r":33,"state":"off"},{"q":19,"r":32,"state":"off"},{"q":9,"r":26,"state":"off"},{"q":5,"r":30,"state":"off"},{"q":4,"r":31,"state":"off"},{"q":4,"r":33,"state":"off"},{"q":4,"r":34,"state":"off"},{"q":4,"r":35,"state":"off"},{"q":15,"r":37,"state":"off"},{"q":16,"r":36,"state":"off"},{"q":17,"r":35,"state":"off"},{"q":18,"r":34,"state":"off"},{"q":8,"r":26,"state":"off"},{"q":4,"r":30,"state":"off"},{"q":3,"r":31,"state":"off"},{"q":3,"r":32,"state":"off"},{"q":16,"r":37,"state":"off"},{"q":7,"r":26,"state":"off"},{"q":6,"r":27,"state":"off"},{"q":5,"r":28,"state":"off"},{"q":4,"r":29,"state":"off"},{"q":2,"r":33,"state":"off"},{"q":17,"r":37,"state":"off"},{"q":23,"r":20,"state":"off"},{"q":22,"r":20,"state":"off"},{"q":21,"r":20,"state":"off"},{"q":20,"r":20,"state":"off"},{"q":19,"r":20,"state":"off"},{"q":18,"r":20,"state":"off"},{"q":17,"r":20,"state":"off"},{"q":16,"r":20,"state":"off"},{"q":15,"r":20,"state":"off"},{"q":14,"r":20,"state":"off"},{"q":13,"r":20,"state":"off"},{"q":12,"r":20,"state":"off"},{"q":4,"r":28,"state":"off"},{"q":1,"r":34,"state":"off"},{"q":18,"r":37,"state":"off"},{"q":19,"r":36,"state":"off"},{"q":20,"r":35,"state":"off"},{"q":24,"r":20,"state":"off"},{"q":11,"r":20,"state":"off"},{"q":3,"r":28,"state":"off"},{"q":0,"r":31,"state":"off"},{"q":0,"r":32,"state":"off"},{"q":0,"r":33,"state":"off"},{"q":0,"r":35,"state":"off"},{"q":0,"r":36,"state":"off"},{"q":0,"r":37,"state":"off"},{"q":0,"r":38,"state":"off"},{"q":0,"r":39,"state":"off"},{"q":0,"r":40,"state":"off"},{"q":0,"r":41,"state":"off"},{"q":0,"r":42,"state":"off"},{"q":0,"r":43,"state":"off"},{"q":25,"r":20,"state":"off"},{"q":10,"r":20,"state":"off"},{"q":3,"r":27,"state":"off"},{"q":-1,"r":31,"state":"off"},{"q":-1,"r":32,"state":"off"},{"q":-1,"r":34,"state":"tail"},{"q":-1,"r":35,"state":"head"},{"q":0,"r":44,"state":"off"},{"q":26,"r":20,"state":"off"},{"q":9,"r":20,"state":"off"},{"q":3,"r":26,"state":"off"},{"q":1,"r":28,"state":"off"},{"q":0,"r":29,"state":"off"},{"q":-1,"r":30,"state":"off"},{"q":-2,"r":32,"state":"off"},{"q":-2,"r":33,"state":"off"},{"q":-2,"r":34,"state":"off"},{"q":-2,"r":36,"state":"tail"},{"q":-2,"r":37,"state":"off"},{"q":0,"r":45,"state":"off"},{"q":27,"r":20,"state":"off"},{"q":8,"r":20,"state":"off"},{"q":3,"r":25,"state":"off"},{"q":1,"r":27,"state":"off"},{"q":-3,"r":36,"state":"off"},{"q":-3,"r":38,"state":"off"},{"q":0,"r":46,"state":"off"},{"q":28,"r":20,"state":"head"},{"q":7,"r":20,"state":"off"},{"q":3,"r":24,"state":"off"},{"q":0,"r":27,"state":"off"},{"q":-4,"r":37,"state":"off"},{"q":-4,"r":38,"state":"off"},{"q":-4,"r":39,"state":"off"},{"q":6,"r":20,"state":"off"},{"q":2,"r":24,"state":"off"},{"q":1,"r":25,"state":"off"},{"q":0,"r":26,"state":"off"},{"q":-5,"r":38,"state":"off"},{"q":-5,"r":39,"state":"off"},{"q":5,"r":20,"state":"off"},{"q":-6,"r":40,"state":"off"},{"q":4,"r":20,"state":"off"},{"q":-7,"r":31,"state":"off"},{"q":-7,"r":32,"state":"off"},{"q":-7,"r":33,"state":"off"},{"q":-7,"r":34,"state":"off"},{"q":-7,"r":35,"state":"off"},{"q":-7,"r":36,"state":"off"},{"q":-7,"r":37,"state":"off"},{"q":-7,"r":38,"state":"off"},{"q":-7,"r":39,"state":"off"},{"q":-7,"r":40,"state":"off"},{"q":3,"r":20,"state":"off"},{"q":-7,"r":30,"state":"off"},{"q":2,"r":20,"state":"off"},{"q":-7,"r":29,"state":"off"},{"q":1,"r":20,"state":"off"},{"q":0,"r":21,"state":"off"},{"q":-1,"r":22,"state":"off"},{"q":-2,"r":23,"state":"off"},{"q":-3,"r":24,"state":"off"},{"q":-4,"r":25,"state":"off"},{"q":-5,"r":26,"state":"off"},{"q":-6,"r":27,"state":"off"},{"q":-7,"r":28,"state":"off"},{"q":17,"r":33,"state":"off"},{"q":17,"r":32,"state":"off"},{"q":17,"r":31,"state":"off"},{"q":18,"r":31,"state":"off"},{"q":18,"r":30,"state":"off"},{"q":19,"r":30,"state":"off"},{"q":19,"r":31,"state":"off"},{"q":18,"r":29,"state":"off"},{"q":18,"r":28,"state":"off"},{"q":18,"r":27,"state":"off"},{"q":18,"r":26,"state":"off"},{"q":18,"r":25,"state":"head"},{"q":21,"r":33,"state":"off"},{"q":21,"r":32,"state":"off"},{"q":21,"r":31,"state":"off"},{"q":21,"r":30,"state":"off"},{"q":21,"r":28,"state":"off"},{"q":21,"r":29,"state":"off"},{"q":21,"r":27,"state":"off"},{"q":21,"r":25,"state":"off"},{"q":47,"r":24,"state":"off"},{"q":46,"r":23,"state":"tail"},{"q":45,"r":25,"state":"off"},{"q":47,"r":25,"state":"off"},{"q":48,"r":23,"state":"off"},{"q":47,"r":22,"state":"head"},{"q":45,"r":23,"state":"off"},{"q":44,"r":25,"state":"off"},{"q":45,"r":26,"state":"off"},{"q":48,"r":25,"state":"off"},{"q":49,"r":23,"state":"off"},{"q":47,"r":21,"state":"off"},{"q":45,"r":22,"state":"off"},{"q":43,"r":26,"state":"off"},{"q":44,"r":27,"state":"off"},{"q":49,"r":25,"state":"off"},{"q":50,"r":23,"state":"off"},{"q":47,"r":20,"state":"off"},{"q":45,"r":21,"state":"off"},{"q":42,"r":27,"state":"off"},{"q":43,"r":28,"state":"off"},{"q":50,"r":25,"state":"off"},{"q":51,"r":23,"state":"off"},{"q":47,"r":19,"state":"off"},{"q":45,"r":20,"state":"off"},{"q":41,"r":28,"state":"off"},{"q":42,"r":29,"state":"off"},{"q":46,"r":30,"state":"tail"},{"q":47,"r":29,"state":"off"},{"q":48,"r":28,"state":"off"},{"q":49,"r":27,"state":"off"},{"q":50,"r":26,"state":"off"},{"q":52,"r":22,"state":"off"},{"q":52,"r":21,"state":"off"},{"q":52,"r":20,"state":"off"},{"q":52,"r":19,"state":"off"},{"q":52,"r":18,"state":"off"},{"q":51,"r":18,"state":"off"},{"q":50,"r":18,"state":"off"},{"q":49,"r":18,"state":"off"},{"q":48,"r":18,"state":"off"},{"q":44,"r":20,"state":"off"},{"q":43,"r":21,"state":"off"},{"q":42,"r":22,"state":"off"},{"q":41,"r":23,"state":"off"},{"q":40,"r":24,"state":"off"},{"q":40,"r":25,"state":"off"},{"q":40,"r":26,"state":"off"},{"q":40,"r":27,"state":"off"},{"q":40,"r":28,"state":"off"},{"q":42,"r":30,"state":"off"},{"q":43,"r":30,"state":"off"},{"q":44,"r":30,"state":"off"},{"q":45,"r":30,"state":"head"},{"q":46,"r":31,"state":"off"},{"q":46,"r":32,"state":"tail"},{"q":47,"r":31,"state":"tail"},{"q":48,"r":30,"state":"tail"},{"q":49,"r":29,"state":"tail"},{"q":51,"r":27,"state":"off"},{"q":52,"r":26,"state":"off"},{"q":53,"r":25,"state":"off"},{"q":54,"r":24,"state":"off"},{"q":54,"r":23,"state":"off"},{"q":54,"r":22,"state":"off"},{"q":54,"r":21,"state":"off"},{"q":54,"r":19,"state":"tail"},{"q":54,"r":18,"state":"tail"},{"q":54,"r":17,"state":"tail"},{"q":54,"r":16,"state":"tail"},{"q":53,"r":16,"state":"tail"},{"q":52,"r":16,"state":"tail"},{"q":51,"r":16,"state":"tail"},{"q":49,"r":16,"state":"off"},{"q":48,"r":16,"state":"off"},{"q":47,"r":16,"state":"off"},{"q":46,"r":16,"state":"off"},{"q":45,"r":17,"state":"off"},{"q":44,"r":18,"state":"off"},{"q":43,"r":19,"state":"off"},{"q":41,"r":21,"state":"tail"},{"q":40,"r":22,"state":"tail"},{"q":39,"r":23,"state":"tail"},{"q":38,"r":24,"state":"tail"},{"q":38,"r":25,"state":"tail"},{"q":38,"r":26,"state":"tail"},{"q":38,"r":27,"state":"tail"},{"q":38,"r":29,"state":"off"},{"q":38,"r":30,"state":"off"},{"q":38,"r":31,"state":"off"},{"q":38,"r":32,"state":"off"},{"q":39,"r":32,"state":"off"},{"q":40,"r":32,"state":"off"},{"q":41,"r":32,"state":"off"},{"q":43,"r":32,"state":"tail"},{"q":44,"r":32,"state":"tail"},{"q":45,"r":32,"state":"tail"},{"q":22,"r":33,"state":"off"},{"q":22,"r":24,"state":"off"},{"q":23,"r":24,"state":"off"},{"q":23,"r":26,"state":"off"},{"q":23,"r":27,"state":"off"},{"q":23,"r":29,"state":"off"},{"q":23,"r":31,"state":"off"},{"q":23,"r":30,"state":"off"},{"q":23,"r":33,"state":"off"},{"q":24,"r":33,"state":"off"},{"q":25,"r":32,"state":"off"},{"q":24,"r":31,"state":"tail"},{"q":24,"r":24,"state":"off"},{"q":24,"r":25,"state":"off"},{"q":20,"r":27,"state":"off"},{"q":20,"r":26,"state":"off"},{"q":24,"r":27,"state":"off"},{"q":24,"r":28,"state":"off"},{"q":25,"r":31,"state":"head"},{"q":20,"r":34,"state":"off"},{"q":-1,"r":41,"state":"off"},{"q":-2,"r":42,"state":"off"},{"q":-3,"r":43,"state":"off"},{"q":-3,"r":42,"state":"off"},{"q":-2,"r":43,"state":"off"},{"q":-3,"r":44,"state":"off"},{"q":-4,"r":45,"state":"off"},{"q":-4,"r":43,"state":"off"},{"q":-5,"r":44,"state":"off"},{"q":-5,"r":45,"state":"off"},{"q":-6,"r":46,"state":"off"},{"q":-6,"r":47,"state":"off"},{"q":-7,"r":47,"state":"off"},{"q":-7,"r":48,"state":"off"},{"q":-8,"r":47,"state":"off"},{"q":-8,"r":48,"state":"off"},{"q":-9,"r":47,"state":"off"},{"q":-9,"r":46,"state":"off"},{"q":-10,"r":46,"state":"off"},{"q":-11,"r":46,"state":"off"},{"q":-12,"r":48,"state":"off"},{"q":-11,"r":48,"state":"off"},{"q":-10,"r":48,"state":"off"},{"q":-11,"r":47,"state":"off"},{"q":-12,"r":47,"state":"off"},{"q":-13,"r":47,"state":"off"},{"q":-14,"r":47,"state":"off"},{"q":-14,"r":46,"state":"off"},{"q":-14,"r":45,"state":"off"},{"q":-14,"r":44,"state":"off"},{"q":-14,"r":43,"state":"off"},{"q":-14,"r":42,"state":"off"},{"q":-14,"r":48,"state":"off"},{"q":-14,"r":50,"state":"off"},{"q":-14,"r":51,"state":"off"},{"q":-14,"r":49,"state":"off"},{"q":-14,"r":52,"state":"off"},{"q":-14,"r":53,"state":"off"},{"q":-7,"r":49,"state":"off"},{"q":-6,"r":49,"state":"off"},{"q":-8,"r":50,"state":"off"},{"q":-8,"r":51,"state":"off"},{"q":-8,"r":52,"state":"off"},{"q":-7,"r":51,"state":"off"},{"q":-6,"r":51,"state":"off"},{"q":-6,"r":50,"state":"off"},{"q":-7,"r":52,"state":"off"},{"q":-7,"r":53,"state":"off"},{"q":-9,"r":53,"state":"off"},{"q":-10,"r":53,"state":"off"},{"q":-10,"r":52,"state":"off"},{"q":-11,"r":54,"state":"off"},{"q":-12,"r":54,"state":"off"},{"q":-11,"r":52,"state":"off"},{"q":-13,"r":54,"state":"off"},{"q":-12,"r":52,"state":"off"},{"q":-13,"r":53,"state":"off"},{"q":-12,"r":53,"state":"off"},{"q":-5,"r":51,"state":"off"},{"q":-4,"r":50,"state":"off"},{"q":-4,"r":49,"state":"off"},{"q":-3,"r":50,"state":"off"},{"q":-2,"r":49,"state":"off"},{"q":-1,"r":48,"state":"off"},{"q":-3,"r":48,"state":"off"},{"q":-2,"r":47,"state":"off"},{"q":-1,"r":47,"state":"off"},{"q":-2,"r":48,"state":"off"},{"q":-14,"r":41,"state":"head"}]' + let demos = { + "logic gates": logic_gates, adder : adder, - big_cells: big_logic, - small_cells: small_logic, - logic_gates: logic_gates, + "big cells": big_logic, + "small cells": small_logic, utils: utils, - timers: timers + timers: timers, + "mini and": mini_and, + memory: memory } diff --git a/grid.js b/grid.js index 466c46f..80288b0 100644 --- a/grid.js +++ b/grid.js @@ -67,6 +67,14 @@ class Hex { retitem.r = r+rr; return retitem; } + refl(q,r) { + var ret = this.clone(); + var trq = q-this.q; + var trr = r-this.r; + var trs = -trq-trr; + ret.q = -trs + q; + return ret; + } flip(q,r) { // flips about point var ret = this.clone(); diff --git a/index.html b/index.html index fda488e..ac92967 100644 --- a/index.html +++ b/index.html @@ -43,6 +43,7 @@ + diff --git a/play.js b/play.js index 970a6c4..df7ca5a 100644 --- a/play.js +++ b/play.js @@ -36,6 +36,7 @@ function lc() { ctx = c.getContext('2d'); c.onclick = e=>wwonclick(c,ctx,g,xcenter,ycenter,scale,e) c.oncontextmenu = (e) => {e.preventDefault(); wwonrtclick(c,ctx,g,xcenter,ycenter,scale,e)}; + g.loadState(demos['adder']); drawGrid(g, ctx, xcenter,ycenter,scale); document.addEventListener('keydown', e=>{ if(e.key == "p") pptoggle(e); @@ -70,11 +71,11 @@ function lc() { ld.onclick = loadState; fl = document.getElementById("flp"); fl.onclick = flipButtonHandler; + rf = document.getElementById("rfl"); + rf.onclick = reflectButtonHandler; load_demos(document.getElementById('seldemo')); dl = document.getElementById("dload"); dl.onclick = demoHandler; - demoHandler(null); - } radius_hover = function(e) { @@ -147,11 +148,21 @@ pptoggle = function(e) { } }; +reflectButtonHandler = function(e) { + c.onclick = e=>reflectThingy(e); + c.addEventListener('mousemove', radius_hover); +} +reflectThingy = function(evt) { + c.removeEventListener('mousemove', radius_hover); + let coords = getClickCoords(c,scale,xcenter,ycenter,evt); + let rad = parseInt(document.getElementById('rad').value); + g.reflHex(coords.q,coords.r,rad); + drawGrid(g, ctx, xcenter,ycenter,scale); + c.onclick = e=>wwonclick(c,ctx,g,xcenter,ycenter,scale,e); +} flipButtonHandler = function(e) { c.onclick = e=>flipThingy(e); c.addEventListener('mousemove', radius_hover); - - // tf are those arguments globals are there for a reason } flipThingy = function(evt) { c.removeEventListener('mousemove', radius_hover); @@ -161,12 +172,9 @@ flipThingy = function(evt) { drawGrid(g, ctx, xcenter,ycenter,scale); c.onclick = e=>wwonclick(c,ctx,g,xcenter,ycenter,scale,e); } - rotateButtonHandler = function(e) { c.onclick = e=>rotateThingy(e); c.addEventListener('mousemove', radius_hover); - - // tf are those arguments globals are there for a reason } rotateThingy = function(evt) { c.removeEventListener('mousemove', radius_hover); @@ -181,7 +189,6 @@ copyHandler = function(e) { c.onclick = e=>copyhex(e); c.addEventListener('mousemove', radius_hover); } - copyhex = function(evt) { c.removeEventListener('mousemove', radius_hover); let coords = getClickCoords(c,scale,xcenter,ycenter,evt); @@ -211,8 +218,6 @@ exportState = function() { let s = g.exportState(); deets = document.getElementById("outzone"); deets.innerText = s - //alert(s); - } importState = function() { let s = prompt("paste state string below"); diff --git a/wireworld.js b/wireworld.js index 43458c5..589e6bb 100644 --- a/wireworld.js +++ b/wireworld.js @@ -121,8 +121,7 @@ class WWGrid { let cells2 = this.cells.map((c)=>c.rotate(q,r,ccw)); this.cells = cells2; } - - flipHex(q,r,radius) { + getHex(q,r,radius) { var rcells = [this.cellAt(q,r)]; for(let i=1; ix.refl(q,r)); + for(let i of newcells) { + this.change(i.state, i.q, i.r); + } + this.clean(); + } + flipHex(q,r,radius) { + let rcells = this.getHex(q,r,radius); let newcells = rcells.map(x=>x.flip(q,r)); //this.cells = newcells; for(let i of newcells) { @@ -165,38 +175,7 @@ class WWGrid { } rotateHex(q,r,radius,ccw=true) { - var rcells = [this.cellAt(q,r)]; - for(let i=1; ix.rotate(q,r)); //this.cells = newcells; for(let i of newcells) { -- 2.39.2