Skip to content
TheChatArchiveThe Chat Archive
Metallama-4-maverick-17b-128e-instruct· MetaHugging Face LMArena Human Preference 140K

give me a code to achieve fiappy bird

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Googlegemma-3-27b-it’s answer.
  1. User

    give me a code to achieve fiappy bird

  2. Meta Assistant

    Here's a simple implementation of Flappy Bird using Python and the Pygame library.

    Flappy Bird Code

    import pygame
    import sys
    
    # Game Variables
    gravity = 0.25
    bird_movement = 0
    game_active = True
    score = 0
    high_score = 0
    
    # Pygame Setup
    pygame.init()
    screen = pygame.display.set_mode((288, 512))
    clock = pygame.time.Clock()
    
    # Colors
    bg_color = (135, 206, 235)
    bird_color = (255, 255, 255)
    pipe_color = (0, 255, 0)
    text_color = (255, 255, 255)
    
    # Fonts
    font = pygame.font.Font('freesansbold.ttf', 24)
    
    # Bird
    bird_x, bird_y = 50, 256
    bird_size = 20
    
    # Pipes
    pipe_x, pipe_y = 300, 200
    pipe_gap = 100
    pipe_width = 50
    
    def draw_floor():
        pygame.draw.rect(screen, (225, 215, 188), (0, 450, 288, 62))
    
    def draw_bird():
        pygame.draw.rect(screen, bird_color, (bird_x, bird_y, bird_size, bird_size))
    
    def draw_pipes():
        global pipe_x, pipe_y
        pygame.draw.rect(screen, pipe_color, (pipe_x, 0, pipe_width, pipe_y))
        pygame.draw.rect(screen, pipe_color, (pipe_x, pipe_y + pipe_gap, pipe_width, 512 - (pipe_y + pipe_gap)))
    
    def update_pipes():
        global pipe_x, pipe_y, score
        pipe_x -= 2
        if pipe_x < -pipe_width:
            pipe_x = 300
            pipe_y = (200 + (50 - score))
            score += 1
    
    def check_collision():
        global game_active
        if (bird_y + bird_size > 450 or
            bird_y < 0 or
            (pipe_x < bird_x + bird_size and
             pipe_x + pipe_width > bird_x and
             (bird_y < pipe_y or bird_y + bird_size > pipe_y + pipe_gap))):
            game_active = False
    
    def draw_text(text, x, y):
        text_surface = font.render(text, True, text_color)
        screen.blit(text_surface, (x, y))
    
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE and game_active:
                    bird_movement = 0
                    bird_movement -= 6
                if event.key == pygame.K_SPACE and not game_active:
                    game_active = True
                    bird_y = 256
                    pipe_x = 300
                    pipe_y = 200
                    score = 0
                    bird_movement = 0
    
        screen.fill(bg_color)
    
        if game_active:
            # Bird
            bird_movement += gravity
            bird_y += bird_movement
            draw_bird()
    
            # Pipes
            draw_pipes()
            update_pipes()
            check_collision()
    
            # Score
            draw_text(str(score), 144, 50)
    
        else:
            draw_text("Game Over!", 80, 256)
            draw_text("Score: " + str(score), 80, 280)
            if score > high_score:
                high_score = score
            draw_text("High Score: " + str(high_score), 80, 304)
    
        draw_floor()
    
        pygame.display.update()
        clock.tick(120)
    

    How to Run the Code

    1. Install the pygame library by running pip install pygame in your terminal.
    2. Save the code in a file named flappy_bird.py.
    3. Run the code by executing python flappy_bird.py in your terminal.

    Gameplay

    • Use the space bar to flap the bird's wings.
    • Avoid hitting the pipes.
    • The game ends when the bird hits a pipe or the ground.
    • Press the space bar to restart the game.

    Note that this is a simplified version of Flappy Bird, and you can improve it by adding more features, such as smoother animations, sound effects, and a more challenging gameplay.

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