Libraryless. Click here for Pure Java version (1883L/12K/42K).
!747 m { static new MultiMap<S, S> map; static boolean fancyOpening = true; static float mirrorChance = 0.0f; // 0.1f; !include #1001296 // MultiMap p { readLocally("map"); makeAndroid3("Leo Bot at " + getComputerID() + "."); } static S lookup(S s) { L<S> results = map.get(s); if (results.isEmpty()) return s; return new Random().nextFloat() <= mirrorChance ? s : oneOf(results); } static synchronized S answer(S input, L<S> history) { if (input.startsWith("!")) { history = (L) unstructure(input.substring(1)); input = history.get(history.size()-1); } if (history.size() == 1) { // ignore contents of first line actually S output = "hallo"; if (fancyOpening) output = lookup(output); return output; } else { S ninput = normalize(input); S lastInput = history.size() >= 3 ? normalize(history.get(history.size()-3)) : null; S lastOutput = normalize(history.get(history.size()-2)); // inner/cross learning algorithm map.put(lastOutput, ninput); if (lastInput != null && !lastInput.equals(lastOutput)) map.put(lastInput, ninput); saveLocally("map"); return lookup(input); } } static S normalize(S s) { //L<S> tok = dropPunctuation(javaTok(s)); // TODO return s.intern(); } }
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
1 comment(s) hidden. show
Snippet ID: | #1001294 |
Snippet name: | Leo Bot |
Eternal ID of this version: | #1001294/1 |
Text MD5: | 3754fd26461d2856015fac61b128832d |
Transpilation MD5: | 534156241c1fa8ad3c3778a4910e9801 |
Author: | stefan |
Category: | leopold |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-11-13 18:06:20 |
Source code size: | 1434 bytes / 53 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 915 / 1259 |
Referenced in: | [show references] |