Download Jar. Uses 3874K of libraries. Click here for Pure Java version (21820L/156K).
1 | !7 |
2 | |
3 | sS yesName = "Katze"; |
4 | sS noName = "Nichtkatze"; |
5 | |
6 | sS yesText = [[ |
7 | Katze |
8 | Cat |
9 | Captain |
10 | ]]; |
11 | |
12 | sS noText = [[ |
13 | Bier |
14 | Hallo |
15 | Kalt |
16 | ]]; |
17 | |
18 | static Set<S> yesLiterals = ciSet(), noLiterals = ciSet(); |
19 | |
20 | static Bool algo_0_1(S s) { |
21 | if (yesLiterals.contains(s)) true; |
22 | if (noLiterals.contains(s)) false; |
23 | null; |
24 | } |
25 | |
26 | static Bool algo_0_2(S s) { |
27 | s = trim(s); |
28 | try bool algo_0_1(s); |
29 | S s2 = collapseWord(s); |
30 | if (neq(s, s2)) |
31 | try bool algo_0_1(s2); |
32 | null; |
33 | } |
34 | |
35 | static Bool algo_0_3(S s) { |
36 | try bool algo_0_2(s); |
37 | S s2 = firstWord(s); |
38 | if (neq(s, s2)) |
39 | try bool algo_0_2(s); |
40 | null; |
41 | } |
42 | |
43 | p { |
44 | autoRestart(); |
45 | independentSmartBot(); |
46 | onNewTriple(f onTriple); |
47 | sahara(); |
48 | consoleHeight(500); |
49 | showMessagesInGerman(true); |
50 | logModuleOutput(); |
51 | readLinePrefix("[] Eingabe: "); |
52 | addAll_withCollapsed(yesLiterals, tlftj(yesText)); |
53 | addAll_withCollapsed(noLiterals, tlftj(noText)); |
54 | for (T3<S> t : triplesWithB("heißt")) onTriple(t); |
55 | bot(); |
56 | centerBigConsole2(); |
57 | focusConsole(random(tossCoin() ? yesLiterals : noLiterals); |
58 | controls2_default(); |
59 | } |
60 | |
61 | svoid controls_feedback(S text) { |
62 | disableConsoleInput(); |
63 | hideControls2(); |
64 | showControls(withCenteredTitle("Ich glaube:", |
65 | vstackWithSpacing(setFontSize(15, jcenteredBoldLabel(text)), |
66 | centeredButtons( |
67 | "Das ist korrekt", r { |
68 | print("=> KORREKT"); |
69 | uploadOutputSinceLastInput(); |
70 | reset(); |
71 | }, |
72 | "Das ist nicht korrekt", r { |
73 | print("=> INKORREKT"); |
74 | fS s = lastInput(); |
75 | //uploadOutputSinceLastInput(); |
76 | |
77 | showControls(vstackWithSpacing( |
78 | setFontSize(13, jcenteredBoldLabel("Was heißt " + quote(s) + " denn?")), |
79 | jcenteredbuttons( |
80 | "Es heißt " + yesName, r { correct(s, true) }, |
81 | "Es heißt " + noName, r { correct(s, false) }, |
82 | "Es heißt was anderes", r { correct(s, null) }))); |
83 | })))); |
84 | } |
85 | |
86 | answer { |
87 | Bool b = algo_0_3(s); |
88 | S a = formatSatz(s, b); |
89 | controls_feedback(a); |
90 | try answer a; |
91 | } |
92 | |
93 | sS formatSatz(S s, Bool b) { |
94 | ret quote(s) + " " + ( |
95 | isTrue(b) ? "bedeutet '" + yesName + "'" |
96 | : isFalse(b) ? "bedeutet '" + noName + "'" |
97 | : "bedeutet weder " + yesName + " noch " + noName); |
98 | } |
99 | |
100 | svoid controls2_default() { |
101 | showControls2(jcenteredlabel("Schreib doch mal was " + yesName + "-iges oder " + noName + "-iges:")); |
102 | } |
103 | |
104 | svoid correct(S input, Bool b) { |
105 | print(formatSatz(input, b)); |
106 | post(quote(input), "heißt", boolSwitch(b, yesName, noName, "weder " + yesName + " noch " + noName)); |
107 | uploadOutputSinceLastInput(); |
108 | reset(); |
109 | } |
110 | |
111 | svoid reset { |
112 | hideControls(); |
113 | enableConsoleInput(); |
114 | focusConsole(); |
115 | } |
116 | |
117 | svoid onTriple(T3<S> t) { |
118 | if (eqic(t.b, "heißt") && isQuoted(t.a)) { |
119 | if (eqic(t.c, yesName)) add_withCollapsed(yesLiterals, unquote(t.a)); |
120 | else if (eqic(t.c, noName)) add_withCollapsed(noLiterals, unquote(t.a)); |
121 | } |
122 | } |
Began life as a copy of #1013840
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1013876 |
Snippet name: | Katze Oder Nichtkatze Bot [dev.] |
Eternal ID of this version: | #1013876/1 |
Text MD5: | 7e32a30c07195f11b2b71f4f2a1bbea9 |
Transpilation MD5: | e9156cb9c29020475cd6077ccf03e2c3 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-03-09 14:29:13 |
Source code size: | 2940 bytes / 122 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 534 / 1841 |
Referenced in: | [show references] |