Uses 911K of libraries. Click here for Pure Java version (6412L/32K).
1 | !7 |
2 | |
3 | cmodule PhilosophyBot2 extends DynPrintLog {
|
4 | transient L unmappedLines = ll("good", "early morning");
|
5 | transient L unmappedQuestions = ll("what is the time", "how do you feel");
|
6 | transient SS mappings = ciMap(); |
7 | |
8 | transient S program = [[ |
9 | funnyAlgorithm |
10 | |
11 | funnyAlgorithm => proc {
|
12 | while (there are unmapped questions): |
13 | find (an unmapped question) x |
14 | find (an unmapped line) y |
15 | map x to y |
16 | } |
17 | |
18 | ]]; |
19 | |
20 | transient new PhilosophyBot1 bot; |
21 | |
22 | start-thread {
|
23 | bot.program = program; |
24 | bot.addNativePredicate("there are unmapped questions",
|
25 | () -> nempty(unmappedQuestions)); |
26 | bot.addNativePredicate("find (an unmapped question) x",
|
27 | () -> {
|
28 | print("find unmapped question x");
|
29 | if (empty(unmappedQuestions)) false; |
30 | ret litcimap(x := random(unmappedQuestions)); |
31 | }); |
32 | bot.addNativePredicate("find (an unmapped line) z",
|
33 | () -> {
|
34 | print("find unmapped line z");
|
35 | if (empty(unmappedLines)) false; |
36 | ret litcimap(z := random(unmappedLines)); |
37 | }); |
38 | |
39 | bot.addNativePredicate("map x to y",
|
40 | (SS map) -> {
|
41 | S x = map.get("x"), y = map.get("y");
|
42 | unmappedQuestions.remove(x); |
43 | unmappedLines.remove(y); |
44 | print("Remaining unmapped questions: " + l(unmappedQuestions));
|
45 | mappings.put(x, y); |
46 | print("Mapped question " + quote(x) + " to answer " + quote(y));
|
47 | true; |
48 | }); |
49 | |
50 | bot.run(); |
51 | } |
52 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1025598 |
| Snippet name: | Philosophy Bot 2 - match questions and answers [dev.] |
| Eternal ID of this version: | #1025598/17 |
| Text MD5: | 1206e9b685aced379d052016a5810031 |
| Transpilation MD5: | 213929de15df4666efc9478b826774b8 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-10-07 15:03:56 |
| Source code size: | 1513 bytes / 52 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 513 / 1169 |
| Version history: | 16 change(s) |
| Referenced in: | [show references] |