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
ID | Author/Program | Comment | Date |
---|---|---|---|
1117 | stefan | TODO: improve interaction on console | 2015-10-07 01:36:09 |