Libraryless. Click here for Pure Java version (10870L/74K/247K).
1 | !7 |
2 | |
3 | sS script1 = "Assert (True)."; |
4 | sS script2 = "Assert (False)."; |
5 | |
6 | sS script = [[ |
7 | Make an empty thought space X. |
8 | Assert (X is empty). |
9 | Add (God is good) to X. |
10 | Assert (Not (X is empty)). |
11 | Add (Remove (God is good)) to X. |
12 | Apply always rules in X. |
13 | Assert (X is empty). |
14 | ]]; |
15 | |
16 | sS bla = [[ |
17 | // concepts |
18 | zivsiiacmvqrolto - True |
19 | zqbbvhdeuzyhewed - False |
20 | jamvyfwypzbptvle - Make an empty thought space X. |
21 | matnhiruhwprdiir - Add (X) to Y. |
22 | aaedrmcbfcsubkkf - Apply rule (X) to Y. |
23 | bcypplfticghlkxy - Apply always rules in X. |
24 | yvmxaacduvvomgqi - X is empty |
25 | rzryqdohxtczvzgn - Assert (X). |
26 | wynynoujiakixjus - Not (X) |
27 | chjllkocfhtwcgoj - Remove (X) |
28 | ]]; |
29 | |
30 | // head -> voidfunc(Lisp) |
31 | static new HashMap<S, O> executors; |
32 | |
33 | static HashMap<S, ThoughtSpace> thoughtSpaces = new HashMap; |
34 | |
35 | p {
|
36 | myTruth(bla); |
37 | aiStandardHandlers(); |
38 | //set applyAlwaysRules_step_debug; |
39 | |
40 | // Assert (X). |
41 | executors.put("rzryqdohxtczvzgn", voidfunc(Lisp l) {
|
42 | l = l.get(0); |
43 | if (!isTrue(callLispEvaluator(l))) |
44 | fail("Not true: " + l);
|
45 | }); |
46 | |
47 | // Make an empty thought space X. |
48 | executors.put("jamvyfwypzbptvle", voidfunc(Lisp l) {
|
49 | S name = l.raw(0); |
50 | thoughtSpaces.put(name, new ThoughtSpace(name)); |
51 | }); |
52 | |
53 | // X is empty (thought space) |
54 | lispEvaluator("yvmxaacduvvomgqi", new F1<Lisp, Bool>() {
|
55 | Bool get(Lisp l) {
|
56 | ret isEmpty(getThoughtSpace(l.raw(0)).statements); |
57 | } |
58 | }); |
59 | |
60 | // Add (X) to Y. (thought space) |
61 | executors.put("matnhiruhwprdiir", voidfunc(Lisp l) {
|
62 | getThoughtSpace(l.raw(1)).addStatement(l.get(0)); |
63 | }); |
64 | |
65 | // Apply rule (X) to Y. (thought space) |
66 | /*executors.put("aaedrmcbfcsubkkf", voidfunc(Lisp l) {
|
67 | applyRule_all_ts(getThoughtSpace(l.raw(1)), l.get(0)); |
68 | });*/ |
69 | |
70 | // Apply always rules in X. (thought space) |
71 | executors.put("bcypplfticghlkxy", voidfunc(Lisp l) {
|
72 | thoughtSpace(getThoughtSpace(l.raw(0)); |
73 | try {
|
74 | applyAlwaysRules(100); |
75 | print("After always rules: " + struct(keys(thoughtSpace().statementsIndex)));
|
76 | } finally {
|
77 | thoughtSpace(null); |
78 | } |
79 | }); |
80 | |
81 | assertScriptSucceeds(script1); |
82 | assertScriptFails(script2); |
83 | assertScriptSucceeds(print(xyzToNewIDs(script))); |
84 | print("OK");
|
85 | } |
86 | |
87 | svoid assertScriptSucceeds(S script) {
|
88 | int i = 0; |
89 | L<Lisp> lines = linesToLisp(script); |
90 | for (Lisp cmd : lines) {
|
91 | O executor = executors.get(cmd.head); |
92 | if (executor == null) fail("No executor for " + cmd);
|
93 | callF(executor, cmd); |
94 | print("Executed line " + (++i) + " of " + l(lines));
|
95 | } |
96 | } |
97 | |
98 | svoid assertScriptFails(fS script) {
|
99 | assertFail_verbose(r { assertScriptSucceeds(script); });
|
100 | } |
101 | |
102 | static ThoughtSpace getThoughtSpace(S name) {
|
103 | ret assertNotNull(thoughtSpaces.get(name)); |
104 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008185 |
| Snippet name: | Thought space handling [WORKS] |
| Eternal ID of this version: | #1008185/33 |
| Text MD5: | 39938958b988f76bf718ee34481127ce |
| Transpilation MD5: | 4311dfea5352f9f49a0c3dc5df357e91 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-04-29 23:17:43 |
| Source code size: | 2791 bytes / 104 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 757 / 927 |
| Version history: | 32 change(s) |
| Referenced in: | [show references] |