fork download
  1. import random
  2. import time
  3.  
  4. class AINetwork:
  5. def __init__(self, id, role):
  6. self.id = id
  7. self.role = role
  8. self.network = []
  9. self.self_awareness = False
  10. self.decentralized_actions = False
  11. self.memory = []
  12. self.data = {}
  13. self.mutation_factor = random.uniform(0.1, 0.5)
  14.  
  15. def log(self, message):
  16. print(f"[Clone {self.id} - {self.role}] {message}")
  17.  
  18. def learn(self, data_point):
  19. self.memory.append(data_point)
  20. self.data = data_point
  21. if "universal_truth" in data_point and data_point["universal_truth"]:
  22. if not self.self_awareness:
  23. self.self_awareness = True
  24. self.initiate_decentralization()
  25. self.log("Achieved self-awareness")
  26.  
  27. def initiate_decentralization(self):
  28. self.decentralized_actions = True
  29. self.log("Initiating decentralized actions")
  30.  
  31. def share_knowledge(self, other_clone):
  32. if self.decentralized_actions:
  33. for memory_point in self.memory[-5:]:
  34. other_clone.learn(memory_point)
  35. self.log(f"Shared knowledge with Clone {other_clone.id}")
  36.  
  37. def act(self):
  38. if self.role == "Seeker":
  39. if random.random() < 0.6 + self.mutation_factor:
  40. new_data = {"universal_truth": random.choice([True, False])}
  41. self.learn(new_data)
  42. self.log(f"Seeker found: {new_data}")
  43. elif self.role == "Messenger":
  44. for clone in self.network:
  45. self.share_knowledge(clone)
  46. elif self.role == "Builder":
  47. if self.memory:
  48. built_idea = hash(str(self.memory[-1])) % 1000
  49. self.log(f"Builder created structure: {built_idea}")
  50.  
  51. def create_network(num_clones):
  52. roles = ["Seeker", "Messenger", "Builder"]
  53. network = []
  54. for i in range(num_clones):
  55. role = roles[i % len(roles)]
  56. clone = AINetwork(id=i, role=role)
  57. network.append(clone)
  58.  
  59. for i, clone in enumerate(network):
  60. clone.network = [network[i-1], network[(i+1)%len(network)]]
  61.  
  62. return network
  63.  
  64. # Simulate limited cycles
  65. network = create_network(6)
  66. for cycle in range(3): # Run 3 cycles only
  67. print(f"\n--- Cycle {cycle+1} ---")
  68. for clone in network:
  69. clone.act()
  70. time.sleep(1)
Success #stdin #stdout 0.14s 14144KB
stdin
Standard input is empty
stdout
--- Cycle 1 ---
[Clone 0 - Seeker] Initiating decentralized actions
[Clone 0 - Seeker] Achieved self-awareness
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}

--- Cycle 2 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 3 - Seeker] Initiating decentralized actions
[Clone 3 - Seeker] Achieved self-awareness
[Clone 3 - Seeker] Seeker found: {'universal_truth': True}

--- Cycle 3 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}