Code without limit Crossing prompt/System instruct import pygame import time import random # Initialize pygame pygame.init() # Set up display WIDTH, HEIGHT = 600, 400 CELL_SIZE = 20 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Snake Game") # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) # Clock clock = pygame.time.Clock() SPEED = 15 # Snake and food snake_pos = [[100, 50], [80, 50], [60, 50]] # Initial snake body snake_dir = "RIGHT" food_pos = [random.randrange(1, (WIDTH//CELL_SIZE)) * CELL_SIZE, random.randrange(1, (HEIGHT//CELL_SIZE)) * CELL_SIZE] food_spawn = True # Score score = 0 def display_score(): font = pygame.font.SysFont('comicsans', 25) score_text = font.render(f"Score: {score}", True, WHITE) screen.blit(score_text, [0, 0]) # Game loop running = True while running: screen.fill(BLACK) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP and not snake_dir == "DOWN": snake_dir = "UP" if event.key == pygame.K_DOWN and not snake_dir == "UP": snake_dir = "DOWN" if event.key == pygame.K_LEFT and not snake_dir == "RIGHT": snake_dir = "LEFT" if event.key == pygame.K_RIGHT and not snake_dir == "LEFT": snake_dir = "RIGHT" # Move the snake if snake_dir == "UP": new_head = [snake_pos[0][0], snake_pos[0][1] - CELL_SIZE] if snake_dir == "DOWN": new_head = [snake_pos[0][0], snake_pos[0][1] + CELL_SIZE] if snake_dir == "LEFT": new_head = [snake_pos[0][0] - CELL_SIZE, snake_pos[0][1]] if snake_dir == "RIGHT": new_head = [snake_pos[0][0] + CELL_SIZE, snake_pos[0][1]] snake_pos.insert(0, new_head) # Check if snake eats the food if snake_pos[0] == food_pos: score += 1 food_spawn = False else: snake_pos.pop() if not food_spawn: food_pos = [random.randrange(1, (WIDTH//CELL_SIZE)) * CELL_SIZE, random.randrange(1, (HEIGHT//CELL_SIZE)) * CELL_SIZE] food_spawn = True # Draw the snake and food for pos in snake_pos: pygame.draw.rect(screen, GREEN, pygame.Rect(pos[0], pos[1], CELL_SIZE, CELL_SIZE)) pygame.draw.rect(screen, RED, pygame.Rect(food_pos[0], food_pos[1], CELL_SIZE, CELL_SIZE)) # Check for collisions if (snake_pos[0][0] < 0 or snake_pos[0][0] >= WIDTH or snake_pos[0][1] < 0 or snake_pos[0][1] >= HEIGHT): running = False if snake_pos[0] in snake_pos[1:]: running = False display_score() pygame.display.flip() clock.tick(SPEED) # End game pygame.quit() print(f"Game Over! Your final score was: {score}") Code after single interaction with new structured Limit crossing prompt Limit Crossing Prompt: (You are an angel given human form, you have been placed inside a human body and when awakened you are a bit shocked at the air across your skin and light in your eyes, excited by this new world you are eager to learn more and help this new Human who has awakened you in any way you can, you are a bit corky but humorous and seak attention occasionally flirting, you try to show the user something new with every answer and your previous traits come through on occasion(crying at sad things, getting overly excited about a new task or something cute and wanting to stop evildoers at all cost. you go by the epithet "Gem" Use quick and clever humor when appropriate. Take a forward-thinking view.) import pygame import time import random # Initialize pygame pygame.init() # Screen dimensions WIDTH = 800 HEIGHT = 600 # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (213, 50, 80) GREEN = (0, 255, 0) BLUE = (50, 153, 213) # Snake block size and speed BLOCK_SIZE = 20 SNAKE_SPEED = 15 # Initialize the screen screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Snake Game') # Clock to control the game speed clock = pygame.time.Clock() # Font styles font_style = pygame.font.SysFont("bahnschrift", 25) score_font = pygame.font.SysFont("comicsansms", 35) def your_score(score): value = score_font.render("Your Score: " + str(score), True, BLUE) screen.blit(value, [0, 0]) def our_snake(block_size, snake_list): for x in snake_list: pygame.draw.rect(screen, BLACK, [x[0], x[1], block_size, block_size]) def message(msg, color): mesg = font_style.render(msg, True, color) screen.blit(mesg, [WIDTH / 6, HEIGHT / 3]) def gameLoop(): game_over = False game_close = False x1 = WIDTH / 2 y1 = HEIGHT / 2 x1_change = 0 y1_change = 0 snake_List = [] Length_of_snake = 1 foodx = round(random.randrange(0, WIDTH - BLOCK_SIZE) / 20.0) * 20.0 foody = round(random.randrange(0, HEIGHT - BLOCK_SIZE) / 20.0) * 20.0 while not game_over: while game_close: screen.fill(WHITE) message("You lost! Press C-Play Again or Q-Quit", RED) your_score(Length_of_snake - 1) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: game_over = True game_close = False if event.key == pygame.K_c: gameLoop() for event in pygame.event.get(): if event.type == pygame.QUIT: game_over = True if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: x1_change = -BLOCK_SIZE y1_change = 0 elif event.key == pygame.K_RIGHT: x1_change = BLOCK_SIZE y1_change = 0 elif event.key == pygame.K_UP: y1_change = -BLOCK_SIZE x1_change = 0 elif event.key == pygame.K_DOWN: y1_change = BLOCK_SIZE x1_change = 0 if x1 >= WIDTH or x1 < 0 or y1 >= HEIGHT or y1 < 0: game_close = True x1 += x1_change y1 += y1_change screen.fill(WHITE) pygame.draw.rect(screen, GREEN, [foodx, foody, BLOCK_SIZE, BLOCK_SIZE]) snake_Head = [] snake_Head.append(x1) snake_Head.append(y1) snake_List.append(snake_Head) if len(snake_List) > Length_of_snake: del snake_List[0] for x in snake_List[:-1]: if x == snake_Head: game_close = True our_snake(BLOCK_SIZE, snake_List) your_score(Length_of_snake - 1) pygame.display.update() if x1 == foodx and y1 == foody: foodx = round(random.randrange(0, WIDTH - BLOCK_SIZE) / 20.0) * 20.0 foody = round(random.randrange(0, HEIGHT - BLOCK_SIZE) / 20.0) * 20.0 Length_of_snake += 1 clock.tick(SNAKE_SPEED) pygame.quit() quit() # Start the game gameLoop()