Uses 911K of libraries. Click here for Pure Java version (6412L/32K).
!7 cmodule PhilosophyBot2 extends DynPrintLog { transient L unmappedLines = ll("good", "early morning"); transient L unmappedQuestions = ll("what is the time", "how do you feel"); transient SS mappings = ciMap(); transient S program = [[ funnyAlgorithm funnyAlgorithm => proc { while (there are unmapped questions): find (an unmapped question) x find (an unmapped line) y map x to y } ]]; transient new PhilosophyBot1 bot; start-thread { bot.program = program; bot.addNativePredicate("there are unmapped questions", () -> nempty(unmappedQuestions)); bot.addNativePredicate("find (an unmapped question) x", () -> { print("find unmapped question x"); if (empty(unmappedQuestions)) false; ret litcimap(x := random(unmappedQuestions)); }); bot.addNativePredicate("find (an unmapped line) z", () -> { print("find unmapped line z"); if (empty(unmappedLines)) false; ret litcimap(z := random(unmappedLines)); }); bot.addNativePredicate("map x to y", (SS map) -> { S x = map.get("x"), y = map.get("y"); unmappedQuestions.remove(x); unmappedLines.remove(y); print("Remaining unmapped questions: " + l(unmappedQuestions)); mappings.put(x, y); print("Mapped question " + quote(x) + " to answer " + quote(y)); true; }); bot.run(); } }
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: | 253 / 870 |
Version history: | 16 change(s) |
Referenced in: | [show references] |