-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1976 lines (1762 loc) · 72.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Chemical Zen - Sokobond in JS</title>
<style>
table {
border-spacing: 0px;
}
#board {
position:relative;
z-index: 0;
}
#left_arrow{
position: absolute;
top: 50%;
left: 0%;
z-index: 100;
}
#right_arrow{
position: absolute;
top: 50%;
left: 100%;
z-index: 100;
}
#top_arrow{
position: absolute;
top: 0%;
left: 50%;
z-index: 100;
}
#bottom_arrow{
position: absolute;
top: 100%;
left: 50%;
z-index: 100;
}
#puzzle_title {
font-size: larger;
z-index: 99;
top: 25px;
left: 190px;
color: white;
text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
}
#Item_Menu {
border: solid;
border-width: 1px;
}
#input_area{
font-family: "Courier New";
}
@keyframes animatezoom {
from {
top: 0;
left: 0;
transform: scale(0);
}
to {
top: 25%;
left: 25%;
transform: scale(1);
}
}
.win {
position: absolute;
top: 25%;
left: 25%;
width: 210px;
z-index: 50;
animation-name: animatezoom;
animation-duration: 4s;
}
.win_vacuum {
width: 100px;
height: 100px;
}
.win_bond_vert {
width: 10px;
height: 100px;
}
.win_bond_horiz {
width: 100px;
height: 10px;
}
.win_hyperspace {
text-align: center;
width: 10px;
height: 10px;
}
td {
position: relative;
margin: 0px;
padding: 0px;
}
svg {
position: absolute;
top: 0px;
left: 0px;
display: block;
overflow: visible;
}
.vacuum {
width: 50px;
height: 50px;
}
.bond_vert {
width: 5px;
height: 50px;
}
.bond_horiz {
width: 50px;
height: 5px;
}
.hyperspace {
text-align: center;
width: 5px;
height: 5px;
}
.wall {
background-color: CornflowerBlue;
}
.move_to {
border: dashed;
border-width: 1px;
}
.editor {
border: solid;
border-width: 1px;
}
.selected{
background-color: yellow;
}
/*https://www.w3schools.com/w3css/4/w3pro.css*/
/* W3PRO.CSS 4.13 June 2019 by Jan Egil and Borge Refsnes */
html{box-sizing:border-box}
*,*:before,*:after{box-sizing:inherit}
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
body{margin:0}
article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}summary{display:list-item}
audio,canvas,progress,video{display:inline-block}progress{vertical-align:baseline}
audio:not([controls]){display:none;height:0}[hidden],template{display:none}
a{background-color:transparent}a:active,a:hover{outline-width:0}
abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}
b,strong{font-weight:bolder}dfn{font-style:italic}mark{background:#ff0;color:#000}
small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sub{bottom:-0.25em}sup{top:-0.5em}figure{margin:1em 40px}img{border-style:none}
code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}hr{box-sizing:content-box;height:0;overflow:visible}
button,input,select,textarea,optgroup{font:inherit;margin:0}optgroup{font-weight:bold}
button,input{overflow:visible}button,select{text-transform:none}
button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}
button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}
button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}
fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:.35em .625em .75em}
legend{color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}
[type=checkbox],[type=radio]{padding:0}
[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}
[type=search]{-webkit-appearance:textfield;outline-offset:-2px}
[type=search]::-webkit-search-decoration{-webkit-appearance:none}
::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}
/* End extract */
html,body{font-family:Verdana,sans-serif;font-size:15px;line-height:1.5}
html{overflow-x:hidden}
h1{font-size:36px}h2{font-size:30px}h3{font-size:24px}h4{font-size:20px}h5{font-size:18px}h6{font-size:16px}.w3-serif{font-family:serif}
h1,h2,h3,h4,h5,h6{font-family:"Segoe UI",Arial,sans-serif;font-weight:400;margin:10px 0}.w3-wide{letter-spacing:4px}
hr{border:0;border-top:1px solid #eee;margin:20px 0}
.w3-image{max-width:100%;height:auto}img{vertical-align:middle}a{color:inherit}
.w3-table,.w3-table-all{border-collapse:collapse;border-spacing:0;width:100%;display:table}.w3-table-all{border:1px solid #ccc}
.w3-bordered tr,.w3-table-all tr{border-bottom:1px solid #ddd}.w3-striped tbody tr:nth-child(even){background-color:#f1f1f1}
.w3-table-all tr:nth-child(odd){background-color:#fff}.w3-table-all tr:nth-child(even){background-color:#f1f1f1}
.w3-hoverable tbody tr:hover,.w3-ul.w3-hoverable li:hover{background-color:#ccc}.w3-centered tr th,.w3-centered tr td{text-align:center}
.w3-table td,.w3-table th,.w3-table-all td,.w3-table-all th{padding:8px 8px;display:table-cell;text-align:left;vertical-align:top}
.w3-table th:first-child,.w3-table td:first-child,.w3-table-all th:first-child,.w3-table-all td:first-child{padding-left:16px}
/*.w3-btn,.w3-button{border:none;display:inline-block;padding:8px 16px;vertical-align:middle;overflow:hidden;text-decoration:none;color:inherit;background-color:inherit;text-align:center;cursor:pointer;white-space:nowrap}*/
.w3-btn:hover{box-shadow:0 8px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19)}
.w3-btn,.w3-button{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
.w3-disabled,.w3-btn:disabled,.w3-button:disabled{cursor:not-allowed;opacity:0.3}.w3-disabled *,:disabled *{pointer-events:none}
.w3-btn.w3-disabled:hover,.w3-btn:disabled:hover{box-shadow:none}
.w3-badge,.w3-tag{background-color:#000;color:#fff;display:inline-block;padding-left:8px;padding-right:8px;text-align:center}.w3-badge{border-radius:50%}
.w3-ul{list-style-type:none;padding:0;margin:0}.w3-ul li{padding:8px 16px;border-bottom:1px solid #ddd}.w3-ul li:last-child{border-bottom:none}
.w3-tooltip,.w3-display-container{position:relative}.w3-tooltip .w3-text{display:none}.w3-tooltip:hover .w3-text{display:inline-block}
.w3-ripple:active{opacity:0.5}.w3-ripple{transition:opacity 0s}
.w3-input{padding:8px;display:block;border:none;border-bottom:1px solid #ccc;width:100%}
.w3-select{padding:9px 0;width:100%;border:none;border-bottom:1px solid #ccc}
.w3-dropdown-click,.w3-dropdown-hover{position:relative;display:inline-block;cursor:pointer}
.w3-dropdown-hover:hover .w3-dropdown-content{display:block}
.w3-dropdown-hover:first-child,.w3-dropdown-click:hover{background-color:#ccc;color:#000}
.w3-dropdown-hover:hover > .w3-button:first-child,.w3-dropdown-click:hover > .w3-button:first-child{background-color:#ccc;color:#000}
.w3-dropdown-content{cursor:auto;color:#000;background-color:#fff;display:none;position:absolute;min-width:160px;margin:0;padding:0;z-index:1}
.w3-check,.w3-radio{width:24px;height:24px;position:relative;top:6px}
.w3-sidebar{height:100%;width:200px;background-color:#fff;position:fixed!important;z-index:1;overflow:auto}
.w3-bar-block .w3-dropdown-hover,.w3-bar-block .w3-dropdown-click{width:100%}
.w3-bar-block .w3-dropdown-hover .w3-dropdown-content,.w3-bar-block .w3-dropdown-click .w3-dropdown-content{min-width:100%}
.w3-bar-block .w3-dropdown-hover .w3-button,.w3-bar-block .w3-dropdown-click .w3-button{width:100%;text-align:left;padding:8px 16px}
.w3-main,#main{transition:margin-left .4s}
.w3-modal{z-index:3;display:none;padding-top:100px;position:fixed;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:rgb(0,0,0);background-color:rgba(0,0,0,0.4)}
.w3-modal-content{margin:auto;background-color:#fff;position:relative;padding:0;outline:0;width:600px}
.w3-bar{width:100%;overflow:hidden}.w3-center .w3-bar{display:inline-block;width:auto}
.w3-bar .w3-bar-item{padding:8px 16px;float:left;width:auto;border:none;display:block;outline:0}
.w3-bar .w3-dropdown-hover,.w3-bar .w3-dropdown-click{position:static;float:left}
.w3-bar .w3-button{white-space:normal}
.w3-bar-block .w3-bar-item{width:100%;display:block;padding:8px 16px;text-align:left;border:none;white-space:normal;float:none;outline:0}
.w3-bar-block.w3-center .w3-bar-item{text-align:center}.w3-block{display:block;width:100%}
.w3-responsive{display:block;overflow-x:auto}
.w3-container:after,.w3-container:before,.w3-panel:after,.w3-panel:before,.w3-row:after,.w3-row:before,.w3-row-padding:after,.w3-row-padding:before,
.w3-cell-row:before,.w3-cell-row:after,.w3-clear:after,.w3-clear:before,.w3-bar:before,.w3-bar:after{content:"";display:table;clear:both}
.w3-col,.w3-half,.w3-third,.w3-twothird,.w3-threequarter,.w3-quarter{float:left;width:100%}
.w3-col.s1{width:8.33333%}.w3-col.s2{width:16.66666%}.w3-col.s3{width:24.99999%}.w3-col.s4{width:33.33333%}
.w3-col.s5{width:41.66666%}.w3-col.s6{width:49.99999%}.w3-col.s7{width:58.33333%}.w3-col.s8{width:66.66666%}
.w3-col.s9{width:74.99999%}.w3-col.s10{width:83.33333%}.w3-col.s11{width:91.66666%}.w3-col.s12{width:99.99999%}
@media (min-width:601px){.w3-col.m1{width:8.33333%}.w3-col.m2{width:16.66666%}.w3-col.m3,.w3-quarter{width:24.99999%}.w3-col.m4,.w3-third{width:33.33333%}
.w3-col.m5{width:41.66666%}.w3-col.m6,.w3-half{width:49.99999%}.w3-col.m7{width:58.33333%}.w3-col.m8,.w3-twothird{width:66.66666%}
.w3-col.m9,.w3-threequarter{width:74.99999%}.w3-col.m10{width:83.33333%}.w3-col.m11{width:91.66666%}.w3-col.m12{width:99.99999%}}
@media (min-width:993px){.w3-col.l1{width:8.33333%}.w3-col.l2{width:16.66666%}.w3-col.l3{width:24.99999%}.w3-col.l4{width:33.33333%}
.w3-col.l5{width:41.66666%}.w3-col.l6{width:49.99999%}.w3-col.l7{width:58.33333%}.w3-col.l8{width:66.66666%}
.w3-col.l9{width:74.99999%}.w3-col.l10{width:83.33333%}.w3-col.l11{width:91.66666%}.w3-col.l12{width:99.99999%}}
.w3-rest{overflow:hidden}.w3-stretch{margin-left:-16px;margin-right:-16px}
.w3-content,.w3-auto{margin-left:auto;margin-right:auto}.w3-content{max-width:980px}.w3-auto{max-width:1140px}
.w3-cell-row{display:table;width:100%}.w3-cell{display:table-cell}
.w3-cell-top{vertical-align:top}.w3-cell-middle{vertical-align:middle}.w3-cell-bottom{vertical-align:bottom}
.w3-hide{display:none!important}.w3-show-block,.w3-show{display:block!important}.w3-show-inline-block{display:inline-block!important}
@media (max-width:1205px){.w3-auto{max-width:95%}}
@media (max-width:600px){.w3-modal-content{margin:0 10px;width:auto!important}.w3-modal{padding-top:30px}
.w3-dropdown-hover.w3-mobile .w3-dropdown-content,.w3-dropdown-click.w3-mobile .w3-dropdown-content{position:relative}
.w3-hide-small{display:none!important}.w3-mobile{display:block;width:100%!important}.w3-bar-item.w3-mobile,.w3-dropdown-hover.w3-mobile,.w3-dropdown-click.w3-mobile{text-align:center}
.w3-dropdown-hover.w3-mobile,.w3-dropdown-hover.w3-mobile .w3-btn,.w3-dropdown-hover.w3-mobile .w3-button,.w3-dropdown-click.w3-mobile,.w3-dropdown-click.w3-mobile .w3-btn,.w3-dropdown-click.w3-mobile .w3-button{width:100%}}
@media (max-width:768px){.w3-modal-content{width:500px}.w3-modal{padding-top:50px}}
@media (min-width:993px){.w3-modal-content{width:900px}.w3-hide-large{display:none!important}.w3-sidebar.w3-collapse{display:block!important}}
@media (max-width:992px) and (min-width:601px){.w3-hide-medium{display:none!important}}
@media (max-width:992px){.w3-sidebar.w3-collapse{display:none}.w3-main{margin-left:0!important;margin-right:0!important}.w3-auto{max-width:100%}}
.w3-top,.w3-bottom{position:fixed;width:100%;z-index:1}.w3-top{top:0}.w3-bottom{bottom:0}
.w3-overlay{position:fixed;display:none;width:100%;height:100%;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.5);z-index:2}
.w3-display-topleft{position:absolute;left:0;top:0}.w3-display-topright{position:absolute;right:0;top:0}
.w3-display-bottomleft{position:absolute;left:0;bottom:0}.w3-display-bottomright{position:absolute;right:0;bottom:0}
.w3-display-middle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%)}
.w3-display-left{position:absolute;top:50%;left:0%;transform:translate(0%,-50%);-ms-transform:translate(-0%,-50%)}
.w3-display-right{position:absolute;top:50%;right:0%;transform:translate(0%,-50%);-ms-transform:translate(0%,-50%)}
.w3-display-topmiddle{position:absolute;left:50%;top:0;transform:translate(-50%,0%);-ms-transform:translate(-50%,0%)}
.w3-display-bottommiddle{position:absolute;left:50%;bottom:0;transform:translate(-50%,0%);-ms-transform:translate(-50%,0%)}
.w3-display-container:hover .w3-display-hover{display:block}.w3-display-container:hover span.w3-display-hover{display:inline-block}.w3-display-hover{display:none}
.w3-display-position{position:absolute}
.w3-circle{border-radius:50%}
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
.w3-card,.w3-card-2{box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)}
.w3-card-4,.w3-hover-shadow:hover{box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19)}
.w3-spin{animation:w3-spin 2s infinite linear}@keyframes w3-spin{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}}
.w3-animate-fading{animation:fading 10s infinite}@keyframes fading{0%{opacity:0}50%{opacity:1}100%{opacity:0}}
.w3-animate-opacity{animation:opac 0.8s}@keyframes opac{from{opacity:0} to{opacity:1}}
.w3-animate-top{position:relative;animation:animatetop 0.4s}@keyframes animatetop{from{top:-300px;opacity:0} to{top:0;opacity:1}}
.w3-animate-left{position:relative;animation:animateleft 0.4s}@keyframes animateleft{from{left:-300px;opacity:0} to{left:0;opacity:1}}
.w3-animate-right{position:relative;animation:animateright 0.4s}@keyframes animateright{from{right:-300px;opacity:0} to{right:0;opacity:1}}
.w3-animate-bottom{position:relative;animation:animatebottom 0.4s}@keyframes animatebottom{from{bottom:-300px;opacity:0} to{bottom:0;opacity:1}}
.w3-animate-zoom {animation:animatezoom 0.6s}@keyframes animatezoom{from{transform:scale(0)} to{transform:scale(1)}}
.w3-animate-input{transition:width 0.4s ease-in-out}.w3-animate-input:focus{width:100%!important}
.w3-opacity,.w3-hover-opacity:hover{opacity:0.60}.w3-opacity-off,.w3-hover-opacity-off:hover{opacity:1}
.w3-opacity-max{opacity:0.25}.w3-opacity-min{opacity:0.75}
.w3-greyscale-max,.w3-grayscale-max,.w3-hover-greyscale:hover,.w3-hover-grayscale:hover{filter:grayscale(100%)}
.w3-greyscale,.w3-grayscale{filter:grayscale(75%)}.w3-greyscale-min,.w3-grayscale-min{filter:grayscale(50%)}
.w3-sepia{filter:sepia(75%)}.w3-sepia-max,.w3-hover-sepia:hover{filter:sepia(100%)}.w3-sepia-min{filter:sepia(50%)}
.w3-tiny{font-size:10px!important}.w3-small{font-size:12px!important}.w3-medium{font-size:15px!important}.w3-large{font-size:18px!important}
.w3-xlarge{font-size:24px!important}.w3-xxlarge{font-size:36px!important}.w3-xxxlarge{font-size:48px!important}.w3-jumbo{font-size:64px!important}
.w3-left-align{text-align:left!important}.w3-right-align{text-align:right!important}.w3-justify{text-align:justify!important}.w3-center{text-align:center!important}
.w3-border-0{border:0!important}.w3-border{border:1px solid #ccc!important}
.w3-border-top{border-top:1px solid #ccc!important}.w3-border-bottom{border-bottom:1px solid #ccc!important}
.w3-border-left{border-left:1px solid #ccc!important}.w3-border-right{border-right:1px solid #ccc!important}
.w3-topbar{border-top:6px solid #ccc!important}.w3-bottombar{border-bottom:6px solid #ccc!important}
.w3-leftbar{border-left:6px solid #ccc!important}.w3-rightbar{border-right:6px solid #ccc!important}
.w3-section,.w3-code{margin-top:16px!important;margin-bottom:16px!important}
.w3-margin{margin:16px!important}.w3-margin-top{margin-top:16px!important}.w3-margin-bottom{margin-bottom:16px!important}
.w3-margin-left{margin-left:16px!important}.w3-margin-right{margin-right:16px!important}
.w3-padding-small{padding:4px 8px!important}.w3-padding{padding:8px 16px!important}.w3-padding-large{padding:12px 24px!important}
.w3-padding-16{padding-top:16px!important;padding-bottom:16px!important}.w3-padding-24{padding-top:24px!important;padding-bottom:24px!important}
.w3-padding-32{padding-top:32px!important;padding-bottom:32px!important}.w3-padding-48{padding-top:48px!important;padding-bottom:48px!important}
.w3-padding-64{padding-top:64px!important;padding-bottom:64px!important}
.w3-left{float:left!important}.w3-right{float:right!important}
.w3-button:hover{color:#000!important;background-color:#ccc!important}
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
.w3-hover-none:hover{box-shadow:none!important}
</style>
</head>
<body translate="no" >
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" initial-scale="1.0">
<title>Chemical Zen - Sokobond in JS</title>
</head>
<body ONKEYUP="Key_Input(event.keyCode);">
<!-- https://www.w3schools.com/w3css/w3css_mobile.asp -->
<nav class="w3-sidebar w3-bar-block w3-card w3-animate-top" id="mySidebar">
<div class="w3-container w3-theme-d2">
<span onclick="closeSidebar()" class="w3-button w3-display-topright w3-large">X</span><br>
</div>
<div>--- Game ---</div>
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();alert(how_to_play);">How to play</a>
<div>Puzzle:</div>
<select name="puzzle_select" id="puzzle_select" onchange="closeSidebar();Load_Puzzle(this.value);this.selectedIndex=0;">
<option value="" disabled selected>
---
</option>
</select>
<br>
<br>
<div>--- Editor ---</div>
<!-- <a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();Editor();">Last saved edit</a> -->
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();localStorage.editor_board = document.getElementById('input_area').value;Editor();">Editor Mode</a>
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();board_mode='game';Factory_Reset();ascii=document.getElementById('input_area').value;Build_Puzzle(ascii);previous_boards.push(ascii);Save_State();localStorage.editor_board=ascii;">Create / Play</a>
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();Crop_Editor_Board();">Crop editor</a>
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar(); if(confirm('Are you sure? This will erase the current editor settings.')){localStorage.editor_board = Blank_Editor_ASCII();Editor();}">Reset editor</a>
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();alert(building_a_puzzle);">ASCII codes explanation</a>
<div>--- Problems? ---</div>
<a class="w3-bar-item w3-button" href="#" onclick="closeSidebar();if(confirm('Are you sure? This will erase all saved settings.')){Factory_Reset();Game();}">Factory reset</a>
<div>--- Sokobond ---</div>
<a class="w3-bar-item w3-button" href="https://www.sokobond.com/" onclick="closeSidebar();" target="_blank" rel="noopener">Based on Original Sokobond</a>
<div>--- JS code ---</div>
<a class="w3-bar-item w3-button" href="https://github.com/vpelss/Sokobond_JS" onclick="closeSidebar();" target="_blank" rel="noopener">Github</a>
<a class="w3-bar-item w3-button" href="https://www.emogic.com" onclick="closeSidebar();" target="_blank" rel="noopener">Emogic</a>
</nav>
<header class="w3-bar w3-card w3-theme">
<button class="w3-bar-item w3-button w3-large w3-hover-theme" onclick="openSidebar();">☰</button>
<h6 class="w3-bar-item">Chemical Zen</h6>
</header>
<script type="text/javascript">
function openSidebar() {
document.getElementById("mySidebar").style.display = "block";
}
function closeSidebar() {
document.getElementById("mySidebar").style.display = "none";
}
closeSidebar();
</script>
<center>
<div id="board"></div><br>
<div id="ASCII">
Copy/Share puzzle. Or paste to import (then choose Game Mode)<br>
<textarea id="input_area" rows="4" cols="50"></textarea>
</div>
<p><a href="https://www.sokobond.com/" target="_blank" rel="noopener">Sokobond</a></p>
<p><audio autoplay loop='true' controls src="https://emogic.com/mine/Sokobond_JS/6 - Phat Phrog Studios - First Daylight.mp3" type="audio/mpeg"></audio></p>
</center>
<div id="Item_Menu" class="w3-display-middle w3-code" style="display:none;">
<a href="#" onclick="Editor_Place_Item('0');">Empty</a><br>
<div id="Item_Menu_Bonds">
<a href="#" onclick="Editor_Place_Item('1');">Bond 1</a><br>
<a href="#" onclick="Editor_Place_Item('2');">Bond 2</a><br>
<a href="#" onclick="Editor_Place_Item('3');">Bond 3</a><br>
<a href="#" onclick="Editor_Place_Item('4');">Bond 4</a><br>
</div>
<div id="Item_Menu_Atoms">
<a href="#" onclick="Editor_Place_Item('W');">Wall</a><br>
<a href="#" onclick="Editor_Place_Item('h');">Atom He</a><br>
<a href="#" onclick="Editor_Place_Item('H');">Atom H</a><br>
<a href="#" onclick="Editor_Place_Item('N');">Atom N</a><br>
<a href="#" onclick="Editor_Place_Item('O');">Atom O</a><br>
<a href="#" onclick="Editor_Place_Item('C');">Atom C</a><br>
<a href="#" onclick="Make_Me();">Make this Atom Me</a><br>
</div>
<div id="Item_Menu_Modifiers">
<a href="#" onclick="Editor_Place_Item('-');">Splitter</a><br>
<a href="#" onclick="Editor_Place_Item('+');">Joiner</a><br>
<a href="#" onclick="Editor_Place_Item('.');">Twister</a><br>
</div>
</div>
<div id="win"></div>
</body>
</html>
<script id="rendered-js" >
//global vars -----------------------
var error_msg = "";
var empty_chars = ["0"];
var atom_chars = ["H", "h", "O", "C", "N"];
var wall_chars = ["W"];
var modifier_chars = ["+", "-", "."];
var bond_chars = ["1", "2", "3", "4"];
var validate_board_pos = {}; //note: the keys (hyperspace,vacuum,bond_vert,bond_horiz) match state/class so we can easily do board error checking during the board build
validate_board_pos.hyperspace = empty_chars.concat(modifier_chars);
validate_board_pos.vacuum = empty_chars.concat(atom_chars, wall_chars);
validate_board_pos.bond_vert = empty_chars.concat(bond_chars);
validate_board_pos.bond_horiz = empty_chars.concat(bond_chars);
var direction = {
N: {
x: 0,
y: -1
},
S: {
x: 0,
y: 1
},
E: {
x: 1,
y: 0
},
W: {
x: -1,
y: 0
}
};
//allows us to save JSON.stringify(board) then easily rebuild each object on board.
var board = {}; //[x_y] can_be objects of type empty , atom , bond , bond_modifier
var molecule = {}; // will show which atoms are in same molecule or not : molecule[x_y] = 1 , 2 , 3 , 4 , etc. calculate before every move. It is required so we can push / pull via bonds the atoms in our molecule IN OREDR. We do not want to treat atoms in our molecule like external atoms. ?? otherwise we could jump to our tail and push / pull in wrong direction by bonds....
var molecule_last_count; //set in call to Build_Molecules() and increases on Molecule_Split(). used so we can easily set a new molecule number when a molecule splits.
var board_mode = "game"; //or 'editor'
var move = {}; //move[x_y] = x_new_y_new , a list of all potential moves for this turn so we can simply process moves if move attempt is successful
var atom_intended_move = {}; //atoms_intended_move[xNew_yNew] = 1; allows us to easily check to see if 2 atoms trying to occupy same space (a fail condition)
var previous_boards = []; //array for z - undo and to reset board. it will contain previous_boards.push(ascii). last one is current state
var touched = {}; //this allows us to easily determine if we have already processed an atom or bond. touched[x_y]=1;
var selected_square = "0_0"; //used for editor menu. triggers square identification
//SVG graphics variables --------------------------
var svg = {};
svg["-"] = `<svg width="100%" height="100%" viewBox="0 0 5 5">
<line x1="0" y1="2.5" x2="5" y2="2.5" style="stroke:black;stroke-width:2" />
</svg>`;
svg["+"] = `<svg width="100%" height="100%" viewBox="0 0 5 5">
<line x1="0" y1="2.5" x2="5" y2="2.5" style="stroke:black;stroke-width:1" />
<line x1="2.5" y1="0" x2="2.5" y2="5" style="stroke:black;stroke-width:1" />
</svg>`;
svg["."] = `<svg width="100%" height="100%" viewBox="0 0 5 5">
<circle cx="2.5" cy="2.5" r="1.5" stroke="black" stroke-width="1" fill="black">
</svg>`;
svg.valence_0 = ``;
svg.valence_1 = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 25 A 24 24 0 1 1 48 17 z" />
</circle>
</svg>`;
svg.valence_2 = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 25 A 24 24 0 1 1 48 17 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 1 25 A 24 24 0 1 1 2 33 z" />
</circle>
</svg>`;
svg.valence_3 = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 25 A 24 24 0 1 1 48 17 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 13 46 A 24 24 0 1 1 21 49 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 13 4 A 24 24 0 1 1 7 10 z" />
</circle>
</svg>`;
svg.valence_4 = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path=" M 1 24 A 24 24 0 1 1 1 25 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 26 1 A 24 24 90 1 1 25 1 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 26 A 24 24 180 1 1 49 25 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 24 49 A 24 24 270 1 1 25 49 z" />
</circle>
</svg>`;
svg.solid_circle = `<svg width="100%" height="100%" viewBox="0 0 50 50"><circle cx="50%" cy="50%" r="47%" stroke="black" stroke-width="2" fill="transparent"></circle></svg>`;
svg.dash_circle = `<svg width="100%" height="100%" viewBox="0 0 50 50"><circle cx="25" cy="25" r="24" stroke="black" stroke-width="2" stroke-dasharray="5,5" fill="transparent"></circle></svg>`;
svg.h = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle class="dash" cx="25" cy="25" r="24" fill="white"></circle>
<text font-family='arial' font-color='black' x="50%" y="50%" text-anchor="middle" stroke="black" stroke-width="1px" dy=".3em">He</text>
</svg>`;
svg.H = `<svg width="100%" height="100%" stroke="transparent" stroke-width="2" viewBox="0 0 50 50">
<circle cx="50%" cy="50%" r="47%" fill="IndianRed"></circle>
<text x="50%" y="50%" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">H</text>
</svg>`;
svg.O = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="24" fill="CornflowerBlue"></circle>
<text x="25" y="25" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">O</text>
</svg>`;
svg.N = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="24" fill="LightGreen"></circle>
<text x="25" y="25" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">N</text>
</svg>`;
svg.C = `<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="24" fill="Khaki"></circle>
<text x="25" y="25" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">C</text>
</svg>`;
svg.bond_vert_1 = `<svg width="100%" height="100%" viewBox="0 0 5 50">
<line x1="0" y1="25" x2="5" y2="25" style="stroke:black;stroke-width:2" />
</svg>`;
svg.bond_vert_2 = `<svg width="100%" height="100%" viewBox="0 0 5 50">
<line x1="0" y1="17" x2="5" y2="17" style="stroke:black;stroke-width:2" />
<line x1="0" y1="35" x2="5" y2="35" style="stroke:black;stroke-width:2" />
svg>`;
svg.bond_vert_3 = `<svg width="100%" height="100%" viewBox="0 0 5 50">
<line x1="0" y1="12.5" x2="5" y2="12.5" style="stroke:black;stroke-width:2" />
<line x1="0" y1="25" x2="5" y2="25" style="stroke:black;stroke-width:2" />
<line x1="0" y1="37.5" x2="5" y2="37.5" style="stroke:black;stroke-width:2" />
svg>`;
svg.bond_vert_4 = `<svg width="100%" height="100%" viewBox="0 0 5 50">
<line x1="0" y1="10" x2="5" y2="10" style="stroke:black;stroke-width:2" />
<line x1="0" y1="20" x2="5" y2="20" style="stroke:black;stroke-width:2" />
<line x1="0" y1="30" x2="5" y2="30" style="stroke:black;stroke-width:2" />
<line x1="0" y1="40" x2="5" y2="40" style="stroke:black;stroke-width:2" />
svg>`;
svg.bond_horiz_1 = `<svg width="100%" height="100%" viewBox="0 0 50 5">
<line x1="25" y1="0" x2="25" y2="5" style="stroke:black; stroke-width:2" />
</svg>`;
svg.bond_horiz_2 = `<svg width="100%" height="100%" viewBox="0 0 50 5">
<line x1="17" y1="0" x2="17" y2="5" style="stroke:black; stroke-width:2" />
<line x1="35" y1="0" x2="35" y2="5" style="stroke:black; stroke-width:2" />
</svg>`;
svg.bond_horiz_3 = `<svg width="100%" height="100%" viewBox="0 0 50 5">
<line x1="12.5" y1="0" x2="12.5" y2="5" style="stroke:black; stroke-width:2" />
<line x1="25" y1="0" x2="25" y2="5" style="stroke:black; stroke-width:2" />
<line x1="37.5" y1="0" x2="37.5" y2="5" style="stroke:black; stroke-width:2" />
</svg>`;
svg.bond_horiz_4 = `<svg width="100%" height="100%" viewBox="0 0 50 5">
<line x1="10" y1="0" x2="10" y2="5" style="stroke:black; stroke-width:2" />
<line x1="20" y1="0" x2="20" y2="5" style="stroke:black; stroke-width:2" />
<line x1="30" y1="0" x2="30" y2="5" style="stroke:black; stroke-width:2" />
<line x1="40" y1="0" x2="40" y2="5" style="stroke:black; stroke-width:2" />
</svg>`;
svg.win = `<table>
<tr>
<td class="win_vacuum">
<svg width="100%" height="100%" stroke="transparent" stroke-width="2" viewBox="0 0 50 50">
<circle cx="50%" cy="50%" r="47%" fill="IndianRed"></circle>
<text x="50%" y="50%" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">W</text>
</svg>
<svg width="100%" height="100%" viewBox="0 0 50 50"><circle cx="25" cy="25" r="24" stroke="black" stroke-width="2" stroke-dasharray="5,5" fill="transparent"></circle></svg>
<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 25 A 24 24 0 1 1 48 17 z" />
</circle>
</svg>
</td>
<td class="win_bond_vert">
<svg width="100%" height="100%" viewBox="0 0 5 50">
<line x1="0" y1="25" x2="5" y2="25" style="stroke:black;stroke-width:2" />
</svg>
</td>
<td class="win_vacuum">
<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="24" fill="CornflowerBlue"></circle>
<text x="25" y="25" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">I</text>
</svg>
<svg width="100%" height="100%" viewBox="0 0 50 50"><circle cx="50%" cy="50%" r="47%" stroke="black" stroke-width="2" fill="transparent"></circle></svg>
<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 25 A 24 24 0 1 1 48 17 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 1 25 A 24 24 0 1 1 2 33 z" />
</circle>
</svg>
</td>
</tr>
<tr>
<td class="win_bond_horiz"></td>
<td class="win_bond_hyperspace"></td>
<td class="win_bond_horiz">
<svg width="100%" height="100%" viewBox="0 0 50 5">
<line x1="25" y1="0" x2="25" y2="5" style="stroke:black; stroke-width:2" />
</svg>
</td>
</tr>
<tr><td class="win_vacuum">
</td>
<td class="win_bond_vert">
</td>
<td class="win_vacuum">
<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="24" fill="Khaki"></circle>
<text x="25" y="25" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">N</text>
</svg>
<svg width="100%" height="100%" viewBox="0 0 50 50"><circle cx="50%" cy="50%" r="47%" stroke="black" stroke-width="2" fill="transparent"></circle></svg>
<svg width="100%" height="100%" viewBox="0 0 50 50">
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path=" M 1 24 A 24 24 0 1 1 1 25 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 26 1 A 24 24 90 1 1 25 1 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 49 26 A 24 24 180 1 1 49 25 z" />
</circle>
<circle cx="0" cy="0" r="5" stroke="black" stroke-width="2" fill="white">
<animateMotion dur="10s" repeatCount="indefinite"
path="M 24 49 A 24 24 270 1 1 25 49 z" />
</circle>
</svg>
</td>
</tr>
<table>`;
//alert vars -----------------------------
var how_to_play = `
Chemical Zen needs no instruction...
cursor/arrows=move : or click dashed boxes
r: reset puzzle
z: undo current move
Goal: Join all atoms with free valences
`;
var building_a_puzzle = `Building puzzles in ASCII:
-the first line is an x_y value indicating the location of the atom you will control
-the following lines are the columns and rows of the puzzle
-the top left is x=0 , y=0 x being columns and y being rows
-characters can be W,0,1,2,3,4,h,H,O,N,C,+,-,.
-W = walls -they must be in locations where x and y are both even
-0 (zero) = empty -they can go anywhere
1,2,3,4 = bonds -they can go anywhere between two atoms, up to the capacity of the smallest valence. x and y must be even/odd or odd/even
h = helium -It has no free valence bonds and cannot join to other atoms. It must be in locations where x and y are both even
H = hydrogen -It has 1 free valence bonds. It must be in locations where x and y are both even
O = oxygen -It has 2 free valence bonds. It must be in locations where x and y are both even
N = nitrogen -It has 3 free valence bonds. It must be in locations where x and y are both even
C = carbon -It has 4 free valence bonds. It must be in locations where x and y are both even
+ = bond adder -bonds crossing this will increase by 1 if the atoms have free valences
- = bond subtractor -bonds crossing this will decrease by 1
. = bond twister - bonds crossing this will wrap around it `;
//puzzle vars ------------------------
var puzzles = {};
puzzles.lotus = `8_2
000000W0W0W000000
00000000000000000
0000W0W0C0W0W0000
00000000000000000
00W0W0000000W0W00
00000000000000000
W0W000H000H000W0W
00000000000000000
W000000000000000W
00000000000000000
W0W000H000H000W0W
00000000000000000
00W0W0000000W0W00
00000000000000000
0000W0W000W0W0000
00000000000000000
000000W0W0W000000
`;
puzzles.rosie = `8_12
W0W0W0W0W0W0W0W0W
00000000000000000
W000000000000000W
00000000000000000
W000H000C000H000W
00000000000000000
W000000000000000W
00000000000000000
W000H000W000H000W
00000000000000000
W000000000000000W
00000000000000000
W000H000C000H000W
00000000000000000
W000000000000000W
00000000000000000
W0W0W0W0W0W0W0W0W
`;
puzzles.three_doors = `8_10
W0W0W0W0W0W0W0W0W
00000000000000000
W000000000000000W
00000000000000000
W000000000000000W
00000000000000000
W0W0H0W0C0W0H0W0W
00000000000000000
W000000000000000W
00000000000000000
W00000H0h0H00000W
00000000000000000
W000000000000000W
00000000000000000
W0W0W0W0W0W0W0W0W
`;
puzzles.long_legs = `2_4
00W0W0W0W0W0W0W00
00000000000000000
W0W00000000000W0W
000-000000000-000
W0H00000000000H0W
000-000000000-000
W0W00000C00000W0W
00000-0-0-0-00000
00W0W000W000W0W00
00000000000000000
0000W0H0W0H0W0000
00000000000000000
0000W0W0W0W0W0000
`;
puzzles.construction = `2_2
W0W0W0W0W0W0W0W
000000000000000
W0H000000000H0W
000.0.0.0.0.000
W000O000000000W
000.0.0.0.0.000
W0000000000000W
000.0.0-0.0.000
W0000000000000W
000.0.0.0.0.000
W000000000C000W
000.0.0.0.0.000
W0H000000000H0W
000000000000000
W0W0W0W0W0W0W0W
`;
//constructors ------------------------
function Atom(x, y, letter) {
// Constructor
this.is_a = "atom";
this.x = x;
this.y = y;
this.letter = letter; //H, h, O, N, C
this.valence = {
h: 0,
H: 1,
O: 2,
N: 3,
C: 4
}[letter]; //set on create based on letter
this.forces = {};//keep a record of all attempted forces on this atom. If there are two conflicting forces, return a fail. must erase after a move
if (x <= 0 || y <= 0 || x >= board.width || y >= board.hight) {
//atoms cannot exist on edge. Only walls.
alert("Atom cannot go on the edge");
return new Empty(x, y, "0"); // return empty instead
}
this.Build_Molecules = function (molecule_number) {
let x_y = this.x.toString() + "_" + this.y.toString();
if (typeof molecule[x_y] != "undefined") {
return false;
} //x_y is already part of (this?) molecule. step back in search tree
molecule[x_y] = molecule_number;
let all_news = Get_NEWS(this.x, this.y);
for (let key in direction)
if (direction.hasOwnProperty(key)) {
//N,S,E,W
let x_y_half_step = all_news[key].x_y_half_step;
let x_y_full_step = all_news[key].x_y_full_step;
if (board[x_y_half_step].is_a == "bond") {
//there is a bond
if (board[x_y_full_step].is_a === "atom") {
//this is a bonded atom!
board[x_y_full_step].Build_Molecules(molecule_number); //add it to the current molecule
}
}
}
return true; //NEWS search tree has been processed and all joined atoms added to molecule
};
this.Molecule_Split = function (molecule_number) {
//after a bond split, this will change the molecule # for all bonded atoms to this atom. the other side of the split molecule retains the old molecule #
let x_y = this.x.toString() + "_" + this.y.toString();
if (molecule[x_y] == molecule_number) {
return false;
} //x_y is already part of this molecule. (needed for bond loops)
molecule[x_y] = molecule_number;
let all_news = Get_NEWS(this.x, this.y);
for (let key in direction)
if (direction.hasOwnProperty(key)) {
//N,S,E,W
let x_y_half_step = all_news[key].x_y_half_step;
let x_y_full_step = all_news[key].x_y_full_step;
if (board[x_y_half_step].is_a == "bond") {
//there is a bond
if (board[x_y_full_step].is_a === "atom") {
//this is a bonded atom!
board[x_y_full_step].Molecule_Split(molecule_number);
}
}
}
return true;
};
this.Can_I_Move = function (force) {
//NEWS is the force in direction N,E,W or S
let x_y = this.x.toString() + "_" + this.y.toString();
let all_news = Get_NEWS(this.x, this.y);
let x_y_half_step = all_news[force].x_y_half_step;
let x_y_full_step = all_news[force].x_y_full_step;
//this was added for a snake eating tail case, where a bond is hitting a rotator. No error would trigger, and the move would break the loop.
//but this check is a logical check that should have been included anyway.
this.forces[force] = 1;//record all forces that push/pull on this atom.
if( Object.keys(this.forces).length > 1 ){//If there are two or more, they are conflicting forces, so we should return a false.
return false;
}
if (touched[x_y] === 1) {//this x_y has already been visited/processed. If it had not already replied false, then it must have been true.
return true;
}
touched[x_y] = 1; //else: set this touched{x_y}=1 so we don't recurse into this atom again and create infinite loops
//1. check for a wall hit
if (board[x_y_full_step].is_a === "wall") {
return false;
}
//2. check to see if another atom is moving to the same location
if (atom_intended_move[x_y_full_step]) {
//another atom is already moving here. fail
return false;
}
//3. state atom's intention of moving here
atom_intended_move[x_y_full_step] = 1; //used to ensure 2 atoms are not fighting to move to same space
//Logic
//a) each visited atom (Including our atom) will create a list of bonds,
//b) the atom will choose an unchecked bond, transmit the force (direction), and move to the next atom. See the bond object for bond modifier effects.
//c) when we reach an atom at the end of a branch (no more unchecked bonds), we check for an un-bonded atom in the direction of the force to this atom.
//d) we attempt to transmit the force (direction) to this un-bonded atom and await a true/false result
//e) if true we then backtrack to the previous atom and go to step b)
//f) note: false should always return us as directly as possible to the first atom
//4. step b) above
//note: we must not do the PUSH bond first. If we do, a rotator condition with a snake eating it's tail will fail.
let news_temp = ['N','E','W','S'];
news_temp.push( news_temp.splice(news_temp.indexOf(force) , 1) ); //find force in array, then remove it, and add it to the end
for(let key of news_temp)
//for (let key in all_news)
if (all_news.hasOwnProperty(key)) {
let x_y_half_step = all_news[key].x_y_half_step;
let receiving_atom = all_news[key].x_y_full_step; //is where receiving atom is
if (board[x_y_half_step].is_a === "bond") {
if ( board[x_y_half_step].Can_I_Move(force, key, x_y, receiving_atom) === false ) {//something downstream cannot move
return false;
}
}
}
//5. so now we see if non bonded atom, not touched, is in our way, then see if it can move
//steps c) & d) above
if (board[x_y_half_step].is_a !== "bond") {
//no bond in our way
if (board[x_y_full_step].is_a === "atom") {
//atom in our way
if (touched[x_y_full_step] !== 1) {//has not been touched
//if (molecule[x_y] != molecule[x_y_full_step]) //ONLY PUSH atoms that are not in our molecule as we can't (should not) push atoms in our molecule
//vinman issue: previously we have assumed molecule will move as a solid unit
//when we split a molecule, the transmitting molecule might need to push the receiving atom. We cannot control if the split will occur fist!!!!!!!!
//if we remove this condition to fix, will it cause other issues?
{
if (!board[x_y_full_step].Can_I_Move(force)) {
return false;
}
}
}
}
}
//if we are here, all downstream tests are good to move for this atom (based on current completed search tree).
//but this does not mean that the move will not fail due to another upcoming branch of the search tree
//so do not update this.x and this.y yet. only do it later, when we move all atoms at once.
move[x_y] = x_y_full_step; //this is used to move atoms later, if we are good to go
return true;
};
this.Join_To_Free_Atoms = function () {
//original sokobond 'seems' to attach to atoms with a higher free valance value first. we may need to do this too. see sokobond's gold - chandelier
//to do this find largest to smallest free valances around us and make a NEWS_sorted_array we can use in for (var key in all_news) eg: for (var key in all_news_sorted_array)
var NEWS_valances = {};
var all_news_sorted_array = []; //pop?
let all_news = Get_NEWS(this.x, this.y);