Repository navigation
Expand file tree
/
Copy pathtest_armourbound_integration.py
More file actions
182 lines (130 loc) · 7.09 KB
/
Copy pathtest_armourbound_integration.py
File metadata and controls
182 lines (130 loc) · 7.09 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import unittest
from typing import List
class TestArmourboundIntegration(unittest.TestCase):
def test_plan_moon_mission_contents(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
plan = ai.plan_moon_mission()
self.assertIsInstance(plan, list)
self.assertGreaterEqual(len(plan), 24)
self.assertTrue(plan[0].lower().startswith("define mission objectives"))
def test_guardian_get_strategic_plan(self):
# Import the opponent which integrates the planner
from amalgamation_game.opponents.guardian_opponent import RoyalGuardianOpponent
opp = RoyalGuardianOpponent()
strategy = opp.get_strategic_plan()
self.assertIsInstance(strategy, list)
# Ensure integration returns the same first step
self.assertTrue(strategy[0].lower().startswith("define mission objectives"))
def test_reason_step_toward_moon(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
# Test default (no context) — returns objectives phase with kid-friendly language
reason = ai.reason_step_toward_moon()
self.assertIsInstance(reason, str)
self.assertIn("trip", reason.lower()) # "Is this a trip with friends..."
# Test fallback case (unknown phase)
reason = ai.reason_step_toward_moon({"phase": "unknown"})
self.assertIn("Guardian", reason)
# Test each phase
phases = ["objectives", "vehicle", "trajectory", "systems", "risk", "execute"]
for phase in phases:
reason = ai.reason_step_toward_moon({"phase": phase})
self.assertIsInstance(reason, str)
self.assertGreater(len(reason), 10)
def test_learn_domain_language_dolphins(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
# Test dolphin language learning plan
dolphin_plan = ai.learn_domain_language("dolphins")
self.assertIsInstance(dolphin_plan, list)
self.assertGreaterEqual(len(dolphin_plan), 10)
self.assertTrue(any("dolphin" in step.lower() for step in dolphin_plan))
self.assertTrue(any("sounds" in step.lower() or "talk" in step.lower() for step in dolphin_plan))
def test_learn_domain_language_moon(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
# Test that 'moon' domain returns the moon mission plan
moon_plan = ai.learn_domain_language("moon")
mission_plan = ai.plan_moon_mission()
self.assertEqual(moon_plan, mission_plan)
def test_learn_domain_language_ancient_runes(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
# Test ancient runes learning plan
runes_plan = ai.learn_domain_language("ancient_runes")
self.assertIsInstance(runes_plan, list)
self.assertGreaterEqual(len(runes_plan), 10)
self.assertTrue(any("futhark" in step.lower() for step in runes_plan))
def test_learn_domain_language_quantum_mechanics(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
# Test quantum mechanics learning plan
quantum_plan = ai.learn_domain_language("quantum_mechanics")
self.assertIsInstance(quantum_plan, list)
self.assertGreaterEqual(len(quantum_plan), 10)
self.assertTrue(any("schrödinger" in step.lower() for step in quantum_plan))
def test_learn_domain_language_fallback(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
# Test generic fallback for unknown domain with kid-friendly language
unknown_plan = ai.learn_domain_language("cryptozoology")
self.assertIsInstance(unknown_plan, list)
self.assertGreaterEqual(len(unknown_plan), 10)
self.assertTrue(any("explore" in step.lower() for step in unknown_plan))
def test_ai_registration_and_discovery(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
# Create and register multiple AIs
guardian1 = ArmourboundGuardianAI()
guardian1.register_as("Guardian_Alpha")
guardian2 = ArmourboundGuardianAI()
guardian2.register_as("Guardian_Beta")
# Test discovery
registered = guardian1.list_registered_agents()
self.assertIn("Guardian_Alpha", registered)
self.assertIn("Guardian_Beta", registered)
# Test retrieval
retrieved = ArmourboundGuardianAI.get_agent("Guardian_Alpha")
self.assertEqual(retrieved, guardian1)
def test_ai_send_message_moon_plan(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
sender = ArmourboundGuardianAI()
sender.register_as("Sender")
recipient = ArmourboundGuardianAI()
recipient.register_as("Recipient")
# Send a message about moon planning
response = sender.send_message("Recipient", "Can you plan a moon mission?")
self.assertTrue(response["success"])
self.assertIn("moon", response["response_text"].lower())
self.assertEqual(response["sender"], "Sender")
self.assertEqual(response["recipient"], "Recipient")
def test_ai_send_message_domain_learning(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
sender = ArmourboundGuardianAI()
sender.register_as("Sender2")
recipient = ArmourboundGuardianAI()
recipient.register_as("Recipient2")
# Send a message about domain learning
response = sender.send_message("Recipient2", "Help me learn about dolphins")
self.assertTrue(response["success"])
self.assertIn("dolphin", response["response_text"].lower())
def test_ai_receive_message_greeting(self):
from amalgamation_game.armourbound_guardian import ArmourboundGuardianAI
ai = ArmourboundGuardianAI()
ai.register_as("TestGuardian")
# Test greeting response
response = ai.receive_message("Visitor", "Hello, how are you?")
self.assertIsInstance(response, str)
self.assertIn("Council Protector", response)
self.assertIn("Visitor", response)
def test_ai_send_message_unregistered_recipient(self):
from armourbound_guardian import ArmourboundGuardianAI
sender = ArmourboundGuardianAI()
sender.register_as("SenderX")
# Try to send to unregistered recipient
response = sender.send_message("NonExistent", "Hello!")
self.assertFalse(response["success"])
self.assertIn("No agent named", response["response_text"])
self.assertEqual(response["error"], "Agent not found")
if __name__ == '__main__':
unittest.main()