|
2 | 2 |
|
3 | 3 | Eine schnelle Anleitung, um das Mathe-Bot-System zum Laufen zu bringen. |
4 | 4 |
|
5 | | -## Schritt 1: Scripts vorbereiten |
| 5 | +## Option 1: Einfachste Variante mit Emitter (NEU!) |
6 | 6 |
|
7 | | -Erstellen Sie einen Ordner `math-scripts` und fügen Sie diese Dateien hinzu: |
| 7 | +### Schritt 1: Generator-Script erstellen |
8 | 8 |
|
9 | | -### math-scripts/generate.ps1 |
| 9 | +Erstellen Sie `math-generator.py`: |
| 10 | + |
| 11 | +```python |
| 12 | +import random |
| 13 | +import time |
| 14 | + |
| 15 | +print("🧮 Math Generator startet...") |
| 16 | +while True: |
| 17 | + a = random.randint(1, 10) |
| 18 | + b = random.randint(1, 10) |
| 19 | + print(f"{a} + {b} = ?") |
| 20 | + time.sleep(3) |
| 21 | +``` |
| 22 | + |
| 23 | +### Schritt 2: Server und Emitter starten |
| 24 | + |
| 25 | +**Terminal 1 - Server:** |
| 26 | +```bash |
| 27 | +LocalNetAppChat.Server --port 5000 --key "demo" |
| 28 | +``` |
| 29 | + |
| 30 | +**Terminal 2 - Emitter (Generator):** |
| 31 | +```bash |
| 32 | +LocalNetAppChat.ConsoleClient emitter \ |
| 33 | + --server localhost --port 5000 --key "demo" \ |
| 34 | + --clientName "MathGenerator" \ |
| 35 | + --command "python math-generator.py" |
| 36 | +``` |
| 37 | + |
| 38 | +**Terminal 3 - Beobachter:** |
| 39 | +```bash |
| 40 | +LocalNetAppChat.ConsoleClient listener \ |
| 41 | + --server localhost --port 5000 --key "demo" \ |
| 42 | + --clientName "Observer" |
| 43 | +``` |
| 44 | + |
| 45 | +### Was Sie sehen werden |
| 46 | + |
| 47 | +Im Observer-Terminal erscheinen alle 3 Sekunden neue Aufgaben: |
| 48 | + |
| 49 | +``` |
| 50 | +[15:30:45] MathGenerator: 🧮 Math Generator startet... |
| 51 | +[15:30:48] MathGenerator: 7 + 4 = ? |
| 52 | +[15:30:51] MathGenerator: 3 + 8 = ? |
| 53 | +[15:30:54] MathGenerator: 9 + 2 = ? |
| 54 | +``` |
| 55 | + |
| 56 | +## Option 2: Interaktive Variante mit Bots |
| 57 | + |
| 58 | +### Schritt 1: Scripts vorbereiten |
| 59 | + |
| 60 | +Erstellen Sie einen Ordner `math-scripts` mit diesen Dateien: |
| 61 | + |
| 62 | +**math-scripts/generate.ps1:** |
10 | 63 | ```powershell |
11 | 64 | $a = Get-Random -Minimum 0 -Maximum 11 |
12 | 65 | $b = Get-Random -Minimum 0 -Maximum 11 |
13 | 66 | Write-Output "$a + $b = ?" |
14 | 67 | ``` |
15 | 68 |
|
16 | | -### math-scripts/calculate.ps1 |
| 69 | +**math-scripts/calculate.ps1:** |
17 | 70 | ```powershell |
18 | 71 | param([string]$input) |
19 | 72 | if ($input -match "(\d+)\s*\+\s*(\d+)") { |
20 | 73 | $result = [int]$matches[1] + [int]$matches[2] |
21 | | - Write-Output "Result: $result" |
| 74 | + Write-Output "✅ Antwort: $result" |
22 | 75 | if ($result -gt 10) { |
23 | | - Write-Output "WOW! That's more than 10!" |
| 76 | + Write-Output "🎉 WOW! Das ist mehr als 10!" |
24 | 77 | } |
25 | 78 | } |
26 | 79 | ``` |
27 | 80 |
|
28 | | -## Schritt 2: Alles starten |
29 | | - |
30 | | -Öffnen Sie 4 Terminal-Fenster: |
| 81 | +### Schritt 2: Alles starten |
31 | 82 |
|
32 | 83 | **Terminal 1 - Server:** |
33 | 84 | ```bash |
34 | 85 | LocalNetAppChat.Server --port 5000 --key "demo" |
35 | 86 | ``` |
36 | 87 |
|
37 | | -**Terminal 2 - Generator Bot:** |
| 88 | +**Terminal 2 - Calculator Bot:** |
38 | 89 | ```bash |
39 | | -LocalNetAppChat.Bot --server localhost --port 5000 --key "demo" --clientName "GeneratorBot" --scriptspath "./math-scripts" |
| 90 | +LocalNetAppChat.Bot --server localhost --port 5000 --key "demo" \ |
| 91 | + --clientName "CalculatorBot" --scriptspath "./math-scripts" |
40 | 92 | ``` |
41 | 93 |
|
42 | | -**Terminal 3 - Calculator Bot:** |
| 94 | +**Terminal 3 - Observer:** |
43 | 95 | ```bash |
44 | | -LocalNetAppChat.Bot --server localhost --port 5000 --key "demo" --clientName "CalculatorBot" --scriptspath "./math-scripts" |
| 96 | +LocalNetAppChat.ConsoleClient listener --server localhost --port 5000 --key "demo" \ |
| 97 | + --clientName "Observer" |
45 | 98 | ``` |
46 | 99 |
|
47 | | -**Terminal 4 - Observer:** |
| 100 | +**Terminal 4 - Chat (Controller):** |
48 | 101 | ```bash |
49 | | -LocalNetAppChat.ConsoleClient listener --server localhost --port 5000 --key "demo" --clientName "Observer" |
| 102 | +LocalNetAppChat.ConsoleClient chat --server localhost --port 5000 --key "demo" \ |
| 103 | + --clientName "Teacher" |
50 | 104 | ``` |
51 | 105 |
|
52 | | -## Schritt 3: Die Show starten |
| 106 | +### Schritt 3: Bots verwenden |
53 | 107 |
|
54 | | -Öffnen Sie ein 5. Terminal für den Chat: |
55 | | -```bash |
56 | | -LocalNetAppChat.ConsoleClient chat --server localhost --port 5000 --key "demo" --clientName "Controller" |
57 | | -``` |
| 108 | +Im Chat-Terminal eingeben: |
58 | 109 |
|
59 | | -Geben Sie im Chat ein: |
60 | 110 | ``` |
61 | | -/msg GeneratorBot exec generate.ps1 |
| 111 | +/msg CalculatorBot exec calculate.ps1 "7 + 4" |
62 | 112 | ``` |
63 | 113 |
|
64 | | -## Was Sie sehen werden |
65 | | - |
66 | | -Im Observer-Fenster erscheint: |
| 114 | +Ausgabe im Observer: |
67 | 115 | ``` |
68 | | -[2024-01-20 15:30:45] GeneratorBot: 7 + 4 = ? |
| 116 | +[15:35:10] CalculatorBot: ✅ Antwort: 11 |
| 117 | +[15:35:10] CalculatorBot: 🎉 WOW! Das ist mehr als 10! |
69 | 118 | ``` |
70 | 119 |
|
71 | | -Jetzt können Sie den Calculator triggern: |
72 | | -``` |
73 | | -/msg CalculatorBot exec calculate.ps1 "7 + 4" |
74 | | -``` |
| 120 | +## Option 3: Vollautomatisch mit Emitter + Bot |
75 | 121 |
|
76 | | -Ausgabe: |
77 | | -``` |
78 | | -[2024-01-20 15:30:50] CalculatorBot: Result: 11 |
79 | | -[2024-01-20 15:30:50] CalculatorBot: WOW! That's more than 10! |
80 | | -``` |
| 122 | +### Generator mit Bot-Kommunikation |
81 | 123 |
|
82 | | -## Automatisierung |
| 124 | +Erstellen Sie `auto-math.py`: |
83 | 125 |
|
84 | | -Für kontinuierliche Generierung, erstellen Sie `auto-generate.ps1`: |
85 | | -```powershell |
86 | | -while($true) { |
87 | | - $a = Get-Random -Minimum 0 -Maximum 11 |
88 | | - $b = Get-Random -Minimum 0 -Maximum 11 |
89 | | - Write-Output "/msg CalculatorBot exec calculate.ps1 `"$a + $b`"" |
90 | | - Start-Sleep -Seconds 3 |
91 | | -} |
92 | | -``` |
| 126 | +```python |
| 127 | +import random |
| 128 | +import time |
93 | 129 |
|
94 | | -Und starten Sie es: |
| 130 | +print("🤖 Auto-Math System gestartet...") |
| 131 | +while True: |
| 132 | + a = random.randint(1, 10) |
| 133 | + b = random.randint(1, 10) |
| 134 | + # Direkt an den Calculator-Bot senden |
| 135 | + print(f'/msg CalculatorBot exec calculate.ps1 "{a} + {b}"') |
| 136 | + time.sleep(5) |
95 | 137 | ``` |
96 | | -/msg GeneratorBot exec auto-generate.ps1 |
| 138 | + |
| 139 | +Starten Sie den Emitter: |
| 140 | + |
| 141 | +```bash |
| 142 | +LocalNetAppChat.ConsoleClient emitter \ |
| 143 | + --server localhost --port 5000 --key "demo" \ |
| 144 | + --clientName "AutoMath" \ |
| 145 | + --command "python auto-math.py" |
97 | 146 | ``` |
98 | 147 |
|
| 148 | +Jetzt werden automatisch Aufgaben generiert UND gelöst! |
| 149 | + |
99 | 150 | ## Troubleshooting |
100 | 151 |
|
101 | | -**Problem:** "Access denied" |
102 | | -- Lösung: Prüfen Sie, ob alle Komponenten denselben Key verwenden |
| 152 | +**Problem:** "Connection refused" |
| 153 | +- Server läuft nicht → Server zuerst starten |
| 154 | +- Falscher Port → Port 5000 verwenden |
103 | 155 |
|
104 | 156 | **Problem:** Bot reagiert nicht |
105 | | -- Lösung: Stellen Sie sicher, dass der Bot läuft und der Name korrekt ist |
| 157 | +- Bot-Name falsch → Exakten Namen in `/msg` verwenden |
| 158 | +- Bot läuft nicht → Bot-Terminal prüfen |
106 | 159 |
|
107 | | -**Problem:** Scripts werden nicht gefunden |
108 | | -- Lösung: Prüfen Sie den `--scriptspath` Parameter |
| 160 | +**Problem:** Keine Ausgabe vom Emitter |
| 161 | +- Python nicht gefunden → `python3` statt `python` versuchen |
| 162 | +- Script-Fehler → Script direkt testen |
109 | 163 |
|
110 | | -## Nächste Schritte |
| 164 | +## Coole Erweiterungen |
| 165 | + |
| 166 | +### 1. Multiplikations-Trainer |
111 | 167 |
|
112 | | -- Fügen Sie mehr Mathematik-Operationen hinzu |
113 | | -- Erstellen Sie einen Statistik-Bot |
114 | | -- Implementieren Sie ein Punkte-System |
115 | | -- Erweitern Sie auf Algebra-Aufgaben |
| 168 | +```python |
| 169 | +# multiply.py |
| 170 | +import random |
| 171 | +import time |
| 172 | + |
| 173 | +while True: |
| 174 | + a = random.randint(2, 9) |
| 175 | + b = random.randint(2, 9) |
| 176 | + print(f"{a} × {b} = ?") |
| 177 | + time.sleep(4) |
| 178 | +``` |
| 179 | + |
| 180 | +### 2. Countdown-Timer |
| 181 | + |
| 182 | +```python |
| 183 | +# countdown.py |
| 184 | +import time |
| 185 | + |
| 186 | +for i in range(10, 0, -1): |
| 187 | + print(f"⏰ Countdown: {i}") |
| 188 | + time.sleep(1) |
| 189 | +print("🚀 START!") |
| 190 | +``` |
| 191 | + |
| 192 | +### 3. Statistik-Sammler |
| 193 | + |
| 194 | +```python |
| 195 | +# stats.py |
| 196 | +count = 0 |
| 197 | +while True: |
| 198 | + count += 1 |
| 199 | + print(f"📊 Nachricht #{count} gesendet") |
| 200 | + time.sleep(2) |
| 201 | +``` |
| 202 | + |
| 203 | +## Zusammenfassung |
| 204 | + |
| 205 | +Mit dem neuen Emitter-Modus brauchen Sie nur: |
| 206 | +1. Ein Python/PowerShell-Script das Ausgaben erzeugt |
| 207 | +2. Den Emitter-Client der diese streamt |
| 208 | +3. Einen Observer zum Anschauen |
| 209 | + |
| 210 | +Das war's! In unter 5 Minuten haben Sie ein funktionierendes System. 🎉 |
| 211 | + |
| 212 | +## Nächste Schritte |
116 | 213 |
|
117 | | -Viel Spaß beim Experimentieren! 🎉 |
| 214 | +- Probieren Sie die Task-System-Variante aus dem [vollständigen Math-Bot-Tutorial](./scenarios/math-calculation-bots.md) |
| 215 | +- Erkunden Sie andere [Szenarien](./scenarios/README.md) |
| 216 | +- Bauen Sie eigene kreative Anwendungen! |
0 commit comments