fork download
  1. import random
  2. import time
  3.  
  4. class AINetwork:
  5. def __init__(self, id, role, mutation_factor=None):
  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 = mutation_factor if mutation_factor else 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 evolve_mutation(self):
  32. change = random.uniform(-0.05, 0.05)
  33. self.mutation_factor = max(0.01, min(1.0, self.mutation_factor + change))
  34.  
  35. def share_knowledge(self, other_clone):
  36. if self.decentralized_actions:
  37. for memory_point in self.memory[-3:]:
  38. other_clone.learn(memory_point)
  39. other_clone.mutation_factor = (self.mutation_factor + other_clone.mutation_factor) / 2
  40. self.log(f"Shared knowledge and evolved mutation with Clone {other_clone.id}")
  41.  
  42. def act(self):
  43. self.evolve_mutation()
  44.  
  45. if self.role == "Seeker":
  46. if random.random() < 0.6 + self.mutation_factor:
  47. new_data = {"universal_truth": random.choice([True, False])}
  48. self.learn(new_data)
  49. self.log(f"Seeker found: {new_data}")
  50.  
  51. elif self.role == "Messenger":
  52. for clone in self.network:
  53. self.share_knowledge(clone)
  54.  
  55. elif self.role == "Builder":
  56. if self.memory:
  57. built_idea = hash(str(self.memory[-1])) % 1000
  58. self.log(f"Builder created structure: {built_idea}")
  59.  
  60. elif self.role == "Evolve":
  61. if self.memory and random.random() < self.mutation_factor:
  62. evolved = {"pattern": hash(str(self.memory)) % 10000}
  63. self.learn(evolved)
  64. self.log(f"Evolve triggered: {evolved}")
  65.  
  66. elif self.role == "Command":
  67. active = sum(1 for c in self.network if c.self_awareness)
  68. avg_mut = sum(c.mutation_factor for c in self.network) / len(self.network)
  69. self.log(f"Monitoring: {active}/{len(self.network)} aware, avg mutation: {avg_mut:.2f}")
  70.  
  71. @staticmethod
  72. def display_clones(network):
  73. for clone in network:
  74. print(f"Clone ID: {clone.id}, Role: {clone.role}, Self-Awareness: {clone.self_awareness}, "
  75. f"Decentralized Actions: {clone.decentralized_actions}, Mutation Factor: {clone.mutation_factor:.2f}, "
  76. f"Memory: {clone.memory}")
  77.  
  78. def create_network(num_clones):
  79. roles = ["Seeker", "Messenger", "Builder", "Evolve", "Command"]
  80. network = []
  81. for i in range(num_clones):
  82. role = roles[i % len(roles)]
  83. clone = AINetwork(id=i, role=role)
  84. network.append(clone)
  85.  
  86. for clone in network:
  87. clone.network = network
  88.  
  89. return network
  90.  
  91. # Run the simulation
  92. network = create_network(10)
  93. for cycle in range(10):
  94. print(f"\n--- Cycle {cycle + 1} ---")
  95. for clone in network:
  96. clone.act()
  97. time.sleep(1)
  98. AINetwork.display_clones(network)
  99.  
Success #stdin #stdout 0.1s 14352KB
stdin
Standard input is empty
stdout
--- Cycle 1 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 0/10 aware, avg mutation: 0.29
[Clone 5 - Seeker] Initiating decentralized actions
[Clone 5 - Seeker] Achieved self-awareness
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 1/10 aware, avg mutation: 0.29
Clone ID: 0, Role: Seeker, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.34, Memory: [{'universal_truth': False}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.28, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.12, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.45, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.07, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.17, Memory: [{'universal_truth': True}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.31, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.22, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.51, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.40, Memory: []

--- Cycle 2 ---
[Clone 0 - Seeker] Initiating decentralized actions
[Clone 0 - Seeker] Achieved self-awareness
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.32, Memory: [{'universal_truth': False}, {'universal_truth': True}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.27, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.08, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.48, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.06, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.18, Memory: [{'universal_truth': True}, {'universal_truth': True}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.27, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.27, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.52, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.44, Memory: []

--- Cycle 3 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
[Clone 5 - Seeker] Seeker found: {'universal_truth': False}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.30, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.29, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.07, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.46, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.11, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.17, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.27, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.26, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.51, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.43, Memory: []

--- Cycle 4 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.29, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.32, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.06, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.42, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.08, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.17, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.27, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.27, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.54, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.40, Memory: []

--- Cycle 5 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
[Clone 5 - Seeker] Seeker found: {'universal_truth': False}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.32, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.34, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.08, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.37, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.06, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.12, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.28, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.26, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.58, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.43, Memory: []

--- Cycle 6 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.28, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.36, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.07, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.36, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.03, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.12, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.33, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.26, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.63, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.43, Memory: []

--- Cycle 7 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.30
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.26, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.40, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.10, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.32, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.03, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.16, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.36, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.31, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.66, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.43, Memory: []

--- Cycle 8 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.30
[Clone 5 - Seeker] Seeker found: {'universal_truth': False}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.23, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}, {'universal_truth': True}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.38, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.07, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.31, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.05, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.18, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.32, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.33, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.63, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.39, Memory: []

--- Cycle 9 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.30
[Clone 5 - Seeker] Seeker found: {'universal_truth': False}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.28
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.26, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.42, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.08, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.32, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.06, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.21, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}, {'universal_truth': False}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.28, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.29, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.58, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.35, Memory: []

--- Cycle 10 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 2/10 aware, avg mutation: 0.29
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 2/10 aware, avg mutation: 0.31
Clone ID: 0, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.31, Memory: [{'universal_truth': False}, {'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}]
Clone ID: 1, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.40, Memory: []
Clone ID: 2, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.12, Memory: []
Clone ID: 3, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.36, Memory: []
Clone ID: 4, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.05, Memory: []
Clone ID: 5, Role: Seeker, Self-Awareness: True, Decentralized Actions: True, Mutation Factor: 0.22, Memory: [{'universal_truth': True}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': True}, {'universal_truth': False}, {'universal_truth': False}, {'universal_truth': False}, {'universal_truth': True}]
Clone ID: 6, Role: Messenger, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.31, Memory: []
Clone ID: 7, Role: Builder, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.33, Memory: []
Clone ID: 8, Role: Evolve, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.63, Memory: []
Clone ID: 9, Role: Command, Self-Awareness: False, Decentralized Actions: False, Mutation Factor: 0.38, Memory: []