Skip to content
The Chat Archive
claude-opus-4-20250514· Anthropic LMArena Human Preference 140K

Write a creative snake game in python with atleast 5 unique features that are extremely…

  1. User

    Write a creative snake game in python with atleast 5 unique features that are extremely creative.

  2. Assistant

    I'll create a snake game with some truly unique mechanics that go beyond the typical implementation:

    import pygame
    import random
    import math
    import time
    from collections import deque
    
    # Initialize Pygame
    pygame.init()
    
    # Constants
    WINDOW_WIDTH = 800
    WINDOW_HEIGHT = 600
    CELL_SIZE = 20
    GRID_WIDTH = WINDOW_WIDTH // CELL_SIZE
    GRID_HEIGHT = WINDOW_HEIGHT // CELL_SIZE
    FPS = 10
    
    # Colors
    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    GREEN = (0, 255, 0)
    RED = (255, 0, 0)
    BLUE = (0, 0, 255)
    YELLOW = (255, 255, 0)
    PURPLE = (128, 0, 128)
    ORANGE = (255, 165, 0)
    CYAN = (0, 255, 255)
    PINK = (255, 192, 203)
    
    class QuantumSnake:
        def __init__(self):
            self.screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
            pygame.display.set_caption("Quantum Time-Traveling Snake")
            self.clock = pygame.time.Clock()
            self.font = pygame.font.Font(None, 36)
            self.small_font = pygame.font.Font(None, 24)
            
            self.reset_game()
            
        def reset_game(self):
            # Snake properties
            self.snake = [(GRID_WIDTH // 2, GRID_HEIGHT // 2)]
            self.direction = (1, 0)
            self.grow_counter = 0
            self.score = 0
            
            # Feature 1: Time Travel - Store past states
            self.time_states = deque(maxlen=50)
            self.time_travel_charges = 3
            
            # Feature 2: Quantum Superposition - Snake can exist in multiple states
            self.quantum_positions = []
            self.quantum_mode = False
            self.quantum_timer = 0
            
            # Feature 3: Gravity Wells - Affect snake movement
            self.gravity_wells = []
            self.generate_gravity_wells()
            
            # Feature 4: Portal System
            self.portals = []
            self.generate_portals()
            
            # Feature 5: Emotion System - Snake changes behavior based on mood
            self.emotion = "neutral"  # neutral, happy, angry, scared
            self.emotion_timer = 0
            self.emotion_effects = {
                "happy": {"speed": 1.5, "color": YELLOW},
                "angry": {"speed": 2, "color": RED},
                "scared": {"speed": 0.5, "color": BLUE},
                "neutral": {"speed": 1, "color": GREEN}
            }
            
            # Food
            self.food = self.generate_food()
            self.special_foods = []
            
            # Game state
            self.running = True
            self.paused = False
            self.game_over = False
            
        def generate_gravity_wells(self):
            self.gravity_wells = []
            for _ in range(3):
                x = random.randint(2, GRID_WIDTH - 3)
                y = random.randint(2, GRID_HEIGHT - 3)
                strength = random.uniform(0.3, 0.7)
                self.gravity_wells.append({"pos": (x, y), "strength": strength})
        
        def generate_portals(self):
            self.portals = []
            for _ in range(2):
                entrance = (random.randint(1, GRID_WIDTH - 2), 
                           random.randint(1, GRID_HEIGHT - 2))
                exit = (random.randint(1, GRID_WIDTH - 2), 
                       random.randint(1, GRID_HEIGHT - 2))
                self.portals.append({"entrance": entrance, "exit": exit})
        
        def generate_food(self):
            while True:
                food = (random.randint(0, GRID_WIDTH - 1), 
                       random.randint(0, GRID_HEIGHT - 1))
                if food not in self.snake:
                    return food
        
        def apply_gravity(self, pos, direction):
            # Calculate gravity influence on movement
            grav_x, grav_y = 0, 0
            for well in self.gravity_wells:
                dx = well["pos"][0] - pos[0]
                dy = well["pos"][1] - pos[1]
                distance = math.sqrt(dx**2 + dy**2)
                if distance < 5 and distance > 0:
                    force = well["strength"] / (distance + 1)
                    grav_x += force * dx / distance
                    grav_y += force * dy / distance
            
            # Combine intended direction with gravity
            new_x = direction[0] + grav_x * 0.3
            new_y = direction[1] + grav_y * 0.3
            
            # Normalize to get actual direction
            if abs(new_x) > abs(new_y):
                return (1 if new_x > 0 else -1, 0)
            else:
                return (0, 1 if new_y > 0 else -1)
        
        def check_portal_collision(self, pos):
            for portal in self.portals:
                if pos == portal["entrance"]:
                    return portal["exit"]
                elif pos == portal["exit"]:
                    return portal["entrance"]
            return None
        
        def update_emotion(self):
            # Change emotion based on game events
            if self.score > 0 and self.score % 5 == 0:
                self.emotion = "happy"
                self.emotion_timer = 50
            elif len(self.snake) > 15:
                self.emotion = "angry"
                self.emotion_timer = 30
            elif any(abs(self.snake[0][0] - well["pos"][0]) < 3 and 
                    abs(self.snake[0][1] - well["pos"][1]) < 3 
                    for well in self.gravity_wells):
                self.emotion = "scared"
                self.emotion_timer = 40
            
            if self.emotion_timer > 0:
                self.emotion_timer -= 1
            else:
                self.emotion = "neutral"
        
        def save_time_state(self):
            state = {
                "snake": self.snake.copy(),
                "direction": self.direction,
                "score": self.score,
                "food": self.food,
                "emotion": self.emotion
            }
            self.time_states.append(state)
        
        def time_travel(self):
            if self.time_travel_charges > 0 and len(self.time_states) > 10:
                # Go back 10 states
                past_state = self.time_states[-10]
                self.snake = past_state["snake"].copy()
                self.direction = past_state["direction"]
                self.score = past_state["score"]
                self.food = past_state["food"]
                self.emotion = past_state["emotion"]
                self.time_travel_charges -= 1
                
                # Clear future states
                for _ in range(10):
                    if self.time_states:
                        self.time_states.pop()
        
        def activate_quantum_mode(self):
            if not self.quantum_mode and self.score >= 3:
                self.quantum_mode = True
                self.quantum_timer = 100
                self.quantum_positions = [
                    (self.snake[0][0] + 2, self.snake[0][1]),
                    (self.snake[0][0] - 2, self.snake[0][1]),
                    (self.snake[0][0], self.snake[0][1] + 2),
                    (self.snake[0][0], self.snake[0][1] - 2)
                ]
        
        def update_quantum_positions(self):
            if self.quantum_mode:
                self.quantum_timer -= 1
                if self.quantum_timer <= 0:
                    self.quantum_mode = False
                    # Collapse to one of the quantum positions
                    if self.quantum_positions:
                        chosen_pos = random.choice(self.quantum_positions)
                        if (0 <= chosen_pos[0] < GRID_WIDTH and 
                            0 <= chosen_pos[1] < GRID_HEIGHT):
                            self.snake[0] = chosen_pos
        
        def move_snake(self):
            # Apply gravity to direction
            actual_direction = self.apply_gravity(self.snake[0], self.direction)
            
            # Calculate new head position
            head = self.snake[0]
            new_head = (head[0] + actual_direction[0], head[1] + actual_direction[1])
            
            # Check portal collision
            portal_exit = self.check_portal_collision(new_head)
            if portal_exit:
                new_head = portal_exit
            
            # Check boundaries
            if (new_head[0] < 0 or new_head[0] >= GRID_WIDTH or
                new_head[1] < 0 or new_head[1] >= GRID_HEIGHT):
                self.game_over = True
                return
            
            # Check self collision
            if new_head in self.snake[1:]:
                self.game_over = True
                return
            
            # Move snake
            self.snake.insert(0, new_head)
            
            # Check food collision
            if new_head == self.food:
                self.score += 1
                self.grow_counter += 3
                self.food = self.generate_food()
                
                # Chance for special food
                if random.random() < 0.3:
                    special_type = random.choice(["quantum", "time", "emotion"])
                    self.special_foods.append({
                        "pos": self.generate_food(),
                        "type": special_type,
                        "timer": 100
                    })
            
            # Check special food collision
            for special in self.special_foods[:]:
                if new_head == special["pos"]:
                    if special["type"] == "quantum":
                        self.activate_quantum_mode()
                    elif special["type"] == "time":
                        self.time_travel_charges += 1
                    elif special["type"] == "emotion":
                        self.emotion = "happy"
                        self.emotion_timer = 100
                    self.special_foods.remove(special)
            
            # Grow or shrink snake
            if self.grow_counter > 0:
                self.grow_counter -= 1
            else:
                self.snake.pop()
        
        def handle_input(self):
            keys = pygame.key.get_pressed()
            
            # Direction controls
            if keys[pygame.K_UP] and self.direction != (0, 1):
                self.direction = (0, -1)
            elif keys[pygame.K_DOWN] and self.direction != (0, -1):
                self.direction = (0, 1)
            elif keys[pygame.K_LEFT] and self.direction != (1, 0):
                self.direction = (-1, 0)
            elif keys[pygame.K_RIGHT] and self.direction != (-1, 0):
                self.direction = (1, 0)
            
            # Special abilities
            if keys[pygame.K_t] and self.time_travel_charges > 0:
                self.time_travel()
            elif keys[pygame.K_q]:
                self.activate_quantum_mode()
        
        def draw(self):
            self.screen.fill(BLACK)
            
            # Draw gravity wells
            for well in self.gravity_wells:
                center = (well["pos"][0] * CELL_SIZE + CELL_SIZE // 2,
                         well["pos"][1] * CELL_SIZE + CELL_SIZE // 2)
                radius = int(well["strength"] * 50)
                pygame.draw.circle(self.screen, PURPLE, center, radius, 2)
            
            # Draw portals
            for portal in self.portals:
                # Entrance
                pygame.draw.rect(self.screen, CYAN,
                               (portal["entrance"][0] * CELL_SIZE,
                                portal["entrance"][1] * CELL_SIZE,
                                CELL_SIZE, CELL_SIZE))
                # Exit
                pygame.draw.rect(self.screen, ORANGE,
                               (portal["exit"][0] * CELL_SIZE,
                                portal["exit"][1] * CELL_SIZE,
                                CELL_SIZE, CELL_SIZE))
            
            # Draw quantum positions
            if self.quantum_mode:
                for pos in self.quantum_positions:
                    if 0 <= pos[0] < GRID_WIDTH and 0 <= pos[1] < GRID_HEIGHT:
                        pygame.draw.rect(self.screen, (100, 100, 255),
                                       (pos[0] * CELL_SIZE, pos[1] * CELL_SIZE,
                                        CELL_SIZE, CELL_SIZE), 2)
            
            # Draw snake with emotion color
            snake_color = self.emotion_effects[self.emotion]["color"]
            for segment in self.snake:
                pygame.draw.rect(self.screen, snake_color,
                               (segment[0] * CELL_SIZE, segment[1] * CELL_SIZE,
                                CELL_SIZE, CELL_SIZE))
            
            # Draw food
            pygame.draw.rect(self.screen, RED,
                           (self.food[0] * CELL_SIZE, self.food[1] * CELL_SIZE,
                            CELL_SIZE, CELL_SIZE))
            
            # Draw special foods
            for special in self.special_foods:
                color = {"quantum": BLUE, "time": WHITE, "emotion": YELLOW}[special["type"]]
                pygame.draw.circle(self.screen, color,
                                 (special["pos"][0] * CELL_SIZE + CELL_SIZE // 2,
                                  special["pos"][1] * CELL_SIZE + CELL_SIZE // 2),
                                 CELL_SIZE // 2)
            
            # Draw UI
            score_text = self.font.render(f"Score: {self.score}", True, WHITE)
            self.screen.blit(score_text, (10, 10))
            
            time_text = self.small_font.render(f"Time Charges: {self.time_travel_charges}", True, WHITE)
            self.screen.blit(time_text, (10, 50))
            
            emotion_text = self.small_font.render(f"Emotion: {self.emotion}", True, snake_color)
            self.screen.blit(emotion_text, (10, 80))
            
            if self.quantum_mode:
                quantum_text = self.small_font.render(f"QUANTUM MODE: {self.quantum_timer}", True, BLUE)
                self.screen.blit(quantum_text, (10, 110))
            
            # Instructions
            inst_text = self.small_font.render("T: Time Travel | Q: Quantum Mode", True, WHITE)
            self.screen.blit(inst_text, (WINDOW_WIDTH - 300, 10))
            
            pygame.display.flip()
        
        def run(self):
            while self.running:
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        self.running = False
                    elif event.type == pygame.KEYDOWN:
                        if event.key == pygame.K_SPACE:
                            self.paused = not self.paused
                        elif event.key == pygame.K_r and self.game_over:
                            self.reset_game()
                
                if not self.paused and not self.game_over:
                    self.handle_input()
                    self.save_time_state()
                    self.move_snake()
                    self.update_emotion()
                    self.update_quantum_positions()
                    
                    # Update special food timers
                    for special in self.special
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.