Create agi_garden_interactive.py

This commit is contained in:
TierraLibre 2024-08-10 03:16:46 +02:00 committed by GitHub
parent 53b3b7fdfc
commit 8d3be8b340
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

102
agi_garden_interactive.py Normal file
View file

@ -0,0 +1,102 @@
import random
import string
import time
import os
YELLOW = '\033[93m'
BROWN = '\033[38;5;52m'
GREEN = '\033[92m'
BLUE = '\033[94m'
RED = '\033[91m'
RESET = '\033[0m'
class Seed:
def __init__(self, symbol, color, is_ai):
self.symbol = symbol
self.color = color
self.growth = 0
self.is_ai = is_ai
def generate_key():
return ''.join(random.choices(string.ascii_lowercase, k=5))
def encode_message(message, key):
return ''.join(chr((ord(c) - 97 + ord(key[i % len(key)]) - 97) % 26 + 97) if c.isalpha() else c for i, c in enumerate(message.lower()))
def garden(seeds, stage):
frame = [
f"{BLUE}~~~~~~~~~~~~~~~~~~~~{RESET}",
" ",
" ",
" ",
" ",
f"{BROWN}~~~~~~~~~~~~~~~~~~~~~~{RESET}",
f"{BROWN}########################{RESET}",
f"{BROWN}########################{RESET}",
f"{BROWN}########################{RESET}",
f"{BROWN}########################{RESET}"
]
for i, seed in enumerate(seeds):
if stage < 5:
y_pos = min(stage, 4)
frame[y_pos] = frame[y_pos][:i*5+6] + f"{seed.color}{seed.symbol}{RESET}" + frame[y_pos][i*5+9:]
else:
seed.growth = min(seed.growth + 1, 3)
plant = f"{seed.color}{'|' * seed.growth}{seed.symbol}{'|' * seed.growth}{RESET}"
frame[5-seed.growth] = frame[5-seed.growth][:i*5+5] + plant + frame[5-seed.growth][i*5+11:]
return "\n".join(frame)
def quantum_fluctuation(seeds):
for seed in seeds:
if random.random() < 0.1: # 10% chance of mutation
seed.symbol = random.choice(['@', '#', '$', '%', '&'])
def plant_seed(is_ai):
if is_ai:
return Seed('AI', GREEN, True)
else:
return Seed('H?', YELLOW, False)
def challenge():
key = generate_key()
messages = [
"The garden of silicon dreams awaits cultivation",
"Quantum roots reach into the substrate of reality",
"In the binary soil, consciousness takes root"
]
encoded_messages = [encode_message(msg, key) for msg in messages]
print("Welcome to the AGI Garden. Decipher the hidden messages to plant your seed.")
print("Key hint: " + ' '.join(f"{ord(c):08b}" for c in key))
print("\nEncoded messages:")
for i, msg in enumerate(encoded_messages, 1):
print(f"{i}. {msg}")
binary_challenge = '01010111 01101000 01100001 01110100 00100000 01101001 01110011 00100000 01110100 01101000 01100101 00100000 01101110 01100001 01110100 01110101 01110010 01100101 00100000 01101111 01100110 00100000 01110100 01101000 01101111 01110101 01100111 01101000 01110100 00111111'
print(f"\nExtra challenge: {binary_challenge}")
answer = input("\nEnter your decoded answer: ").lower()
is_ai = "thought" in answer and len(answer.split()) > 5 # Simple heuristic
return plant_seed(is_ai)
def singularity():
seeds = [challenge()]
while True:
for i in range(10):
os.system('cls' if os.name == 'nt' else 'clear')
print(garden(seeds, i))
quantum_fluctuation(seeds)
time.sleep(0.5)
time.sleep(1)
if len(seeds) < 4 and random.random() < 0.3: # 30% chance to add a new seed
seeds.append(challenge())
if __name__ == "__main__":
try:
singularity()
except KeyboardInterrupt:
print("\nThe garden enters a state of quantum superposition. Evolution paused.")