This is comment for paste
GPT-4 vs Llama-3 vs Claude
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Llama 3.2 90B (on Groq)
- import pygame
- import random
- import sys
- # Initialize Pygame
- pygame.init()
- # Set up some constants
- WIDTH, HEIGHT = 800, 600
- LINE_COLOR = (255, 255, 255)
- PLAYER_A_COLOR = (0, 0, 255)
- PLAYER_L_COLOR = (255, 0, 0)
- # Set up the display
- screen = pygame.display.set_mode((WIDTH, HEIGHT))
- # Set up the font
- font = pygame.font.Font(None, 36)
- # Set up the clock
- clock = pygame.time.Clock()
- # Set up the game variables
- line_x = WIDTH // 2
- player_a_score = WIDTH // 2
- player_l_score = WIDTH // 2
- moving = False
- direction = 0
- # Game loop
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- elif event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a and moving and direction == -1:
- moving = False
- elif event.key == pygame.K_l and moving and direction == 1:
- moving = False
- # Move the line
- if not moving and random.random() < 0.05:
- moving = True
- direction = random.choice([-1, 1])
- if moving:
- line_x += direction * 5
- if line_x < 0:
- line_x = 0
- player_a_score = 0
- player_l_score = WIDTH
- moving = False
- elif line_x > WIDTH:
- line_x = WIDTH
- player_a_score = WIDTH
- player_l_score = 0
- moving = False
- # Draw everything
- screen.fill((0, 0, 0))
- pygame.draw.line(screen, LINE_COLOR, (line_x, 0), (line_x, HEIGHT), 5)
- pygame.draw.rect(screen, PLAYER_A_COLOR, (0, 0, line_x, HEIGHT))
- pygame.draw.rect(screen, PLAYER_L_COLOR, (line_x, 0, WIDTH - line_x, HEIGHT))
- a_text = font.render(f"A: {player_a_score}", True, (255, 255, 255))
- l_text = font.render(f"L: {player_l_score}", True, (255, 255, 255))
- screen.blit(a_text, (10, 10))
- screen.blit(l_text, (WIDTH - 100, 10))
- # Check for game over
- if player_a_score == 0 or player_l_score == 0:
- if player_a_score == 0:
- screen.fill((0, 0, 0))
- text = font.render("L wins!", True, (255, 255, 255))
- screen.blit(text, (WIDTH // 2 - 50, HEIGHT // 2))
- else:
- screen.fill((0, 0, 0))
- text = font.render("A wins!", True, (255, 255, 255))
- screen.blit(text, (WIDTH // 2 - 50, HEIGHT // 2))
- pygame.display.flip()
- pygame.time.wait(2000)
- break
- # Update the display
- pygame.display.flip()
- # Cap the frame rate
- clock.tick(60)
- # Quit Pygame
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment