-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchatbot_contest.py
More file actions
47 lines (42 loc) · 1.57 KB
/
chatbot_contest.py
File metadata and controls
47 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import random
class FreudBot:
def __init__(self, name):
self.name = name
self.memory = []
def respond(self, message):
# Simple Freud-inspired response logic
freudisms = [
"Tell me more about your childhood.",
"How does that make you feel?",
"Do you think this relates to your unconscious mind?",
"Perhaps there is a deeper meaning to your words.",
"Let's explore your dreams further.",
"Do you see a connection to your parents?",
"What do you think this says about your desires?",
"Is there a hidden wish behind that thought?",
"How do you interpret this conflict?",
"Could this be a manifestation of repression?"
]
# Learn from previous message
self.memory.append(message)
if len(self.memory) > 1:
return f"{random.choice(freudisms)} (Reflecting on: '{self.memory[-2]}')"
else:
return random.choice(freudisms)
def run_contest(turns=20):
bot1 = FreudBot("FreudBot_A")
bot2 = FreudBot("FreudBot_B")
message = "Let's begin our psychoanalytic contest."
print("="*40)
print("FREUD CHATBOT CONTEST: 20/20 SPLIT")
print("="*40)
for i in range(turns):
print(f"\n[FreudBot_A] Turn {i+1}")
message = bot1.respond(message)
print(f"A: {message}")
print(f"\n[FreudBot_B] Turn {i+1}")
message = bot2.respond(message)
print(f"B: {message}")
print("\nContest complete.")
if __name__ == "__main__":
run_contest(20)