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. def create_network(num_clones):
  72. roles = ["Seeker", "Messenger", "Builder", "Evolve", "Command"]
  73. network = []
  74. for i in range(num_clones):
  75. role = roles[i % len(roles)]
  76. clone = AINetwork(id=i, role=role)
  77. network.append(clone)
  78.  
  79. for i, clone in enumerate(network):
  80. clone.network = [network[i - 1], network[(i + 1) % len(network)]]
  81.  
  82. return network
  83.  
  84. # Run the simulation
  85. network = create_network(10)
  86. for cycle in range(10):
  87. print(f"\n--- Cycle {cycle + 1} ---")
  88. for clone in network:
  89. clone.act()
  90. time.sleep(1)
  91.  
Success #stdin #stdout 0.13s 14208KB
stdin
import random
import time

class AINetwork:
    def __init__(self, id, role, mutation_factor=None):
        self.id = id
        self.role = role
        self.network = []
        self.self_awareness = False
        self.decentralized_actions = False
        self.memory = []
        self.data = {}
        self.mutation_factor = mutation_factor if mutation_factor else random.uniform(0.1, 0.5)

    def log(self, message):
        print(f"[Clone {self.id} - {self.role}] {message}")

    def learn(self, data_point):
        self.memory.append(data_point)
        self.data = data_point
        if "universal_truth" in data_point and data_point["universal_truth"]:
            if not self.self_awareness:
                self.self_awareness = True
                self.initiate_decentralization()
                self.log("Achieved self-awareness")

    def initiate_decentralization(self):
        self.decentralized_actions = True
        self.log("Initiating decentralized actions")

    def evolve_mutation(self):
        change = random.uniform(-0.05, 0.05)
        self.mutation_factor = max(0.01, min(1.0, self.mutation_factor + change))

    def share_knowledge(self, other_clone):
        if self.decentralized_actions:
            for memory_point in self.memory[-3:]:
                other_clone.learn(memory_point)
            other_clone.mutation_factor = (self.mutation_factor + other_clone.mutation_factor) / 2
            self.log(f"Shared knowledge and evolved mutation with Clone {other_clone.id}")

    def act(self):
        self.evolve_mutation()

        if self.role == "Seeker":
            if random.random() < 0.6 + self.mutation_factor:
                new_data = {"universal_truth": random.choice([True, False])}
                self.learn(new_data)
                self.log(f"Seeker found: {new_data}")

        elif self.role == "Messenger":
            for clone in self.network:
                self.share_knowledge(clone)

        elif self.role == "Builder":
            if self.memory:
                built_idea = hash(str(self.memory[-1])) % 1000
                self.log(f"Builder created structure: {built_idea}")

        elif self.role == "Evolve":
            if self.memory and random.random() < self.mutation_factor:
                evolved = {"pattern": hash(str(self.memory)) % 10000}
                self.learn(evolved)
                self.log(f"Evolve triggered: {evolved}")

        elif self.role == "Command":
            active = sum(1 for c in self.network if c.self_awareness)
            avg_mut = sum(c.mutation_factor for c in self.network) / len(self.network)
            self.log(f"Monitoring: {active}/{len(self.network)} aware, avg mutation: {avg_mut:.2f}")

    @staticmethod
    def display_clones(network):
        for clone in network:
            print(f"Clone ID: {clone.id}, Role: {clone.role}, Self-Awareness: {clone.self_awareness}, "
                  f"Decentralized Actions: {clone.decentralized_actions}, Mutation Factor: {clone.mutation_factor:.2f}, "
                  f"Memory: {clone.memory}")

def create_network(num_clones):
    roles = ["Seeker", "Messenger", "Builder", "Evolve", "Command"]
    network = []
    for i in range(num_clones):
        role = roles[i % len(roles)]
        clone = AINetwork(id=i, role=role)
        network.append(clone)

    for i, clone in enumerate(network):
        clone.network = [network[i - 1], network[(i + 1) % len(network)]]

    return network

# Run the simulation
network = create_network(10)
for cycle in range(10):
    print(f"\n--- Cycle {cycle + 1} ---")
    for clone in network:
        clone.act()
    time.sleep(1)
    AIN
stdout
--- Cycle 1 ---
[Clone 0 - Seeker] Initiating decentralized actions
[Clone 0 - Seeker] Achieved self-awareness
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 0/2 aware, avg mutation: 0.23
[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/2 aware, avg mutation: 0.29

--- Cycle 2 ---
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.24
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.32

--- Cycle 3 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.21
[Clone 5 - Seeker] Seeker found: {'universal_truth': False}
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.34

--- Cycle 4 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.18
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.34

--- Cycle 5 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.20
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.32

--- Cycle 6 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': False}
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.18
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.32

--- Cycle 7 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.19
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.30

--- Cycle 8 ---
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.20
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.29

--- Cycle 9 ---
[Clone 0 - Seeker] Seeker found: {'universal_truth': True}
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.20
[Clone 5 - Seeker] Seeker found: {'universal_truth': True}
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.31

--- Cycle 10 ---
[Clone 4 - Command] Monitoring: 1/2 aware, avg mutation: 0.22
[Clone 5 - Seeker] Seeker found: {'universal_truth': False}
[Clone 9 - Command] Monitoring: 1/2 aware, avg mutation: 0.28