GPT 파이썬 소스코드 word3

파이썬 autogpt 랜덤 공 100개 이동 소스코드

GPT 파이썬 소스코드 word3
파이썬 autogpt 랜덤 공 100개 이동 소스코드 6

오토GPT를 이용하여 파이썬으로 랜덤 공 100개를 각각 랜덤한 색상으로 이동하도록 소스코드를 만들어달라고했습니다.

그리고 추가로 각 벽에 공이 부딪히면 반대방향으로 이동하도록 하였습니다.

영어명령문은 이렇습니다.

Make 100 balls in random colors and move them to random locations. If the ball hits each wall, move in the opposite direction

이렇게 명령을 내리니 이런 답변을 주더군요.

PLAN:

  • Install Pygame
  • Create a window to display the balls
  • Generate 100 balls with random colors and locations
  • Move the balls randomly
  • Detect when a ball hits a wall and change its direction accordingly

오토GPT가 공 100개를 랜덤한 색상으로 랜덤한 크기로 만들 후 이동시키는 코드를 만드는 방법을 알려주더군요.

그래서 제가 그럼 그렇게 코드를 만들어줘! 라고 했더니

Make a code like that

아래와 같은 소스코드를 만들어줬습니다.

import pygame
import random

# Initialize Pygame
pygame.init()

# Set up the window
window_width = 800
window_height = 600
window = pygame.display.set_mode((window_width, window_height))
pygame.display.set_caption("Bouncing Balls")

# Set up the clock
clock = pygame.time.Clock()

# Set up the balls
balls = []
for i in range(100):
    ball = {
        "x": random.randint(0, window_width),
        "y": random.randint(0, window_height),
        "radius": random.randint(10, 30),
        "color": (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)),
        "speed": [random.randint(-5, 5), random.randint(-5, 5)]
    }
    balls.append(ball)

# Main game loop
while True:
    # Handle events
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

    # Move the balls
    for ball in balls:
        ball["x"] += ball["speed"][0]
        ball["y"] += ball["speed"][1]

        # Check for collisions with walls
        if ball["x"] - ball["radius"] < 0 or ball["x"] + ball["radius"] > window_width:
            ball["speed"][0] = -ball["speed"][0]
        if ball["y"] - ball["radius"] < 0 or ball["y"] + ball["radius"] > window_height:
            ball["speed"][1] = -ball["speed"][1]

    # Draw the balls
    window.fill((255, 255, 255))
    for ball in balls:
        pygame.draw.circle(window, ball["color"], (ball["x"], ball["y"]), ball["radius"])

    # Update the display
    pygame.display.update()

    # Limit the frame rate
    clock.tick(60)

그리고 이 코드를 그대로 파이썬으로 돌려보았습니다.

정말 놀라운 일이 벌어졌죠.

2023 05 13 오후 8 58 55 word3
파이썬 autogpt 랜덤 공 100개 이동 소스코드 7
autoGPT word3
파이썬 autogpt 랜덤 공 100개 이동 소스코드 8

위의 플랜과 소스코드는 오토GPT가 직접 만들어주었으며 제가 한 부분은 ‘이렇게 만들어줘’ 라는것밖에 없었습니다.

프로그래머들의 실력이 기하급수적으로 늘어나는 시기가 될듯합니다.

오토지피티를 사용할 수 있는 개발자와 사용할수 없는 개발자 사이에 실력차이는 계속 늘어날듯하네요.

autoGPT 윈도우 버전 ai를 VM으로 하나 생성해서 프로그래밍 ai 를 이용하여 프로그램을 앞으로 쉽게 만들수 있다는게 믿을 수가 없네요.

오토지피티야! 위의 코드에 각 공마다 숫자를 겹치지 않도록 해봐!!

word3
파이썬 autogpt 랜덤 공 100개 이동 소스코드 9

진짜… 말도 안된다….. ㅎㅎㅎ 웃음밖에 안나오네.

위의 소스코드입니다.

import pygame
import random

# Initialize Pygame
pygame.init()

# Set up the window
window_width = 800
window_height = 600
window = pygame.display.set_mode((window_width, window_height))
pygame.display.set_caption("Bouncing Balls")

# Set up the clock
clock = pygame.time.Clock()

# Set up the balls
balls = []
for i in range(100):
    ball = {
        "x": random.randint(0, window_width),
        "y": random.randint(0, window_height),
        "radius": random.randint(10, 30),
        "color": (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)),
        "speed": [random.randint(-5, 5), random.randint(-5, 5)],
        "number": str(i+1)
    }
    balls.append(ball)

# Set up the font
font = pygame.font.SysFont("Arial", 20)

# Main game loop
while True:
    # Handle events
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

    # Move the balls
    for ball in balls:
        ball["x"] += ball["speed"][0]
        ball["y"] += ball["speed"][1]

        # Check for collisions with walls
        if ball["x"] - ball["radius"] < 0 or ball["x"] + ball["radius"] > window_width:
            ball["speed"][0] = -ball["speed"][0]
        if ball["y"] - ball["radius"] < 0 or ball["y"] + ball["radius"] > window_height:
            ball["speed"][1] = -ball["speed"][1]

    # Draw the balls
    window.fill((255, 255, 255))
    for ball in balls:
        pygame.draw.circle(window, ball["color"], (ball["x"], ball["y"]), ball["radius"])
        text = font.render(ball["number"], True, (255, 255, 255))
        text_rect = text.get_rect(center=(ball["x"], ball["y"]))
        window.blit(text, text_rect)

    # Update the display
    pygame.display.update()

    # Limit the frame rate
    clock.tick(60)

Background Image

저녁 뭐먹지??

Overlay Image