Advertisement
Guest User

GPT-4 vs Llama-3 vs Claude

a guest
Apr 19th, 2024
284
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | Source Code | 0 0
  1. =================================
  2.  
  3. Code Generated by GPT-4:
  4.  
  5. =================================
  6.  
  7. import pygame
  8. import random
  9. import time
  10.  
  11. pygame.init()
  12. width, height = 800, 600
  13. screen = pygame.display.set_mode((width, height))
  14. clock = pygame.time.Clock()
  15.  
  16. # Initial position of the line
  17. line_x = width // 2
  18.  
  19. def move_line():
  20. global line_x
  21. move_rate = random.choice([-5, 5]) # Line moves left or right randomly
  22. while 0 < line_x < width:
  23. line_x += move_rate
  24. yield
  25. if line_x <= 0 or line_x >= width:
  26. break
  27.  
  28. # Main game loop
  29. running = True
  30. line_movement = move_line()
  31. while running:
  32. for event in pygame.event.get():
  33. if event.type == pygame.QUIT:
  34. running = False
  35. elif event.type == pygame.KEYDOWN:
  36. if event.key == pygame.K_a and move_rate > 0: # Player A stops the line moving left
  37. line_movement = move_line()
  38. elif event.key == pygame.K_l and move_rate < 0: # Player L stops the line moving right
  39. line_movement = move_line()
  40.  
  41. next(line_movement, None) # Move the line
  42. screen.fill((0, 0, 0))
  43. pygame.draw.line(screen, (255, 255, 255), (line_x, 0), (line_x, height))
  44. pygame.display.flip()
  45. clock.tick(60)
  46.  
  47. pygame.quit()
  48.  
  49.  
  50. =================================
  51.  
  52. Code Generated by LlaMA-3:
  53.  
  54. =================================
  55.  
  56. import pygame
  57. import random
  58. import time
  59.  
  60. # Initialize Pygame
  61. pygame.init()
  62.  
  63. # Set up the game window dimensions
  64. WINDOW_WIDTH = 800
  65. WINDOW_HEIGHT = 600
  66. screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
  67.  
  68. # Set up the title of the window
  69. pygame.display.set_caption("Territory Tussle")
  70.  
  71. # Define some colors
  72. WHITE = (255, 255, 255)
  73. BLACK = (0, 0, 0)
  74. RED = (255, 0, 0)
  75. GREEN = (0, 255, 0)
  76.  
  77. # Set up the game variables
  78. player_A_territory = 50
  79. player_L_territory = 50
  80. line_x = WINDOW_WIDTH / 2
  81. line_speed = 2
  82. player_A_score = 0
  83. player_L_score = 0
  84. moving_right = True
  85. game_over = False
  86.  
  87. # Set up the game clock
  88. clock = pygame.time.Clock()
  89.  
  90. # Game loop
  91. while True:
  92. # Event handling
  93. for event in pygame.event.get():
  94. if event.type == pygame.QUIT:
  95. pygame.quit()
  96. sys.exit()
  97. elif event.type == pygame.KEYDOWN:
  98. if event.key == pygame.K_a:
  99. if not moving_right:
  100. moving_right = True
  101. line_speed = 2
  102. elif event.key == pygame.K_l:
  103. if moving_right:
  104. moving_right = False
  105. line_speed = 2
  106. elif event.type == pygame.KEYUP:
  107. line_speed = 2
  108.  
  109. # Move the line
  110. if moving_right:
  111. line_x += line_speed
  112. else:
  113. line_x -= line_speed
  114.  
  115. # Check for boundary collisions
  116. if line_x <= 0:
  117. line_x = 0
  118. elif line_x >= WINDOW_WIDTH:
  119. line_x = WINDOW_WIDTH
  120.  
  121. # Update the game state
  122. if player_A_territory <= 0 or player_L_territory <= 0:
  123. game_over = True
  124. elif player_A_territory >= 100 or player_L_territory >= 100:
  125. game_over = True
  126.  
  127. # Draw everything
  128. screen.fill(WHITE)
  129. pygame.draw.line(screen, BLACK, (line_x, 0), (line_x, WINDOW_HEIGHT), 2)
  130. pygame.draw.rect(screen, RED, (0, 0, line_x, WINDOW_HEIGHT))
  131. pygame.draw.rect(screen, GREEN, (line_x, 0, WINDOW_WIDTH - line_x, WINDOW_HEIGHT))
  132.  
  133. # Game over banner
  134. if game_over:
  135. banner_font = pygame.font.SysFont("Arial", 50)
  136. banner_text = banner_font.render("Game Over! Press R to restart.", True, BLACK)
  137. screen.blit(banner_text, (100, 100))
  138.  
  139. # Restart button
  140. restart_font = pygame.font.SysFont("Arial", 30)
  141. restart_text = restart_font.render("R", True, BLACK)
  142. screen.blit(restart_text, (100, 200))
  143.  
  144. # Dominance percentage
  145. if player_A_score + player_L_score > 0:
  146. dominance_font = pygame.font.SysFont("Arial", 20)
  147. if player_A_territory >= 100:
  148. dominance_text = dominance_font.render(f"Player A dominance: 100%", True, BLACK)
  149. else:
  150. dominance_text = dominance_font.render(f"Player A dominance: {player_A_score / (player_A_score + player_L_score) * 100:.2f}%", True, BLACK)
  151. screen.blit(dominance_text, (100, 300))
  152. if player_L_territory >= 100:
  153. dominance_text = dominance_font.render(f"Player L dominance: 100%", True, BLACK)
  154. else:
  155. dominance_text = dominance_font.render(f"Player L dominance: {player_L_score / (player_A_score + player_L_score) * 100:.2f}%", True, BLACK)
  156. screen.blit(dominance_text, (100, 350))
  157.  
  158. # Update the display
  159. pygame.display.flip()
  160.  
  161. # Cap the frame rate
  162. clock.tick(60)
  163.  
  164. # Check for restart
  165. keys = pygame.key.get_pressed()
  166. if keys[pygame.K_r] and game_over:
  167. player_A_territory = 50
  168. player_L_territory = 50
  169. line_x = WINDOW_WIDTH / 2
  170. game_over = False
  171.  
  172.  
  173.  
  174. =================================
  175.  
  176. Code generated by Claude 3 Sonnet:
  177.  
  178. =================================
  179.  
  180.  
  181.  
  182. import pygame
  183. import random
  184. import time
  185.  
  186. # Initialize Pygame
  187. pygame.init()
  188.  
  189. # Set up the game window
  190. WINDOW_WIDTH = 800
  191. WINDOW_HEIGHT = 600
  192. window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
  193. pygame.display.set_caption("Line Game")
  194.  
  195. # Define colors
  196. BLACK = (0, 0, 0)
  197. WHITE = (255, 255, 255)
  198. RED = (255, 0, 0)
  199. BLUE = (0, 0, 255)
  200.  
  201. # Game variables
  202. player1_territory = WINDOW_WIDTH // 2
  203. player2_territory = WINDOW_WIDTH // 2
  204. line_position = WINDOW_WIDTH // 2
  205. line_moving = False
  206. line_speed = 5
  207. line_direction = 0 # 0 = left, 1 = right
  208. move_interval = 3 # seconds
  209.  
  210. # Game loop
  211. running = True
  212. clock = pygame.time.Clock()
  213. last_move_time = time.time()
  214.  
  215. while running:
  216. clock.tick(60) # Limit frame rate
  217.  
  218. # Handle events
  219. for event in pygame.event.get():
  220. if event.type == pygame.QUIT:
  221. running = False
  222.  
  223. # Player input
  224. keys = pygame.key.get_pressed()
  225. if keys[pygame.K_a] and line_moving and line_direction == 1:
  226. line_moving = False
  227. if keys[pygame.K_l] and line_moving and line_direction == 0:
  228. line_moving = False
  229.  
  230. # Move the line
  231. if not line_moving:
  232. current_time = time.time()
  233. if current_time - last_move_time > move_interval:
  234. line_moving = True
  235. line_direction = random.randint(0, 1)
  236. last_move_time = current_time
  237.  
  238. if line_moving:
  239. if line_direction == 0: # Move left
  240. line_position -= line_speed
  241. else: # Move right
  242. line_position += line_speed
  243.  
  244. # Update player territories
  245. player1_territory = line_position
  246. player2_territory = WINDOW_WIDTH - line_position
  247.  
  248. # Check for game over
  249. if player1_territory <= 0:
  250. print("Player 2 wins!")
  251. running = False
  252. elif player2_territory <= 0:
  253. print("Player 1 wins!")
  254. running = False
  255.  
  256. # Clear the window
  257. window.fill(BLACK)
  258.  
  259. # Draw the line
  260. pygame.draw.line(window, WHITE, (line_position, 0), (line_position, WINDOW_HEIGHT), 2)
  261.  
  262. # Draw player territories
  263. pygame.draw.rect(window, RED, (0, 0, player1_territory, WINDOW_HEIGHT))
  264. pygame.draw.rect(window, BLUE, (player1_territory, 0, player2_territory, WINDOW_HEIGHT))
  265.  
  266. # Update the display
  267. pygame.display.flip()
  268.  
  269. # Quit Pygame
  270. pygame.quit()
Tags: decrypt
Advertisement
Comments
  • jaldpsd
    19 days (edited)
    # text 0.75 KB | 0 0
    1. Prompt:
    2.  
    3. I want to create a game.
    4. To players play against each other in the same computer. One is in control of the letter L and the other controls the letter A.
    5. We have a field divided by two with a line. Each player controls 50% of the field. The player who controls A controls the left half and the one who controls L controls the right half
    6. At a random momemnt, the line will move towards either the left or the right.
    7. The player who is losing ground must pres the button as fast as possible to prevent the line from moving anymore.
    8. When that's done, the line will stay in place and players will have to wait until the line starts to move at a random moment to a random location.
    9. The player who ends up controling 0% of the screen loses and the game ends
  • jaldpsd
    12 days
    # text 2.76 KB | 0 0
    1. Code created by Reka Core:
    2.  
    3.  
    4. import pygame
    5. import random
    6. import time
    7.  
    8. # Initialize Pygame
    9. pygame.init()
    10.  
    11. # Game window dimensions
    12. WINDOW_WIDTH = 800
    13. WINDOW_HEIGHT = 400
    14.  
    15. # Create the game window
    16. screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
    17.  
    18. # Set the window title
    19. pygame.display.set_caption("Letter Game")
    20.  
    21. # Line movement speed
    22. LINE_SPEED = 5
    23.  
    24. # Player colors
    25. PLAYER_A_COLOR = (255, 0, 0)
    26. PLAYER_L_COLOR = (0, 0, 255)
    27.  
    28. # Game field dimensions
    29. FIELD_WIDTH = WINDOW_WIDTH
    30. FIELD_HEIGHT = WINDOW_HEIGHT // 2
    31.  
    32. # Player-controlled areas
    33. player_a_area = FIELD_WIDTH // 2
    34. player_l_area = FIELD_WIDTH // 2
    35.  
    36. # Line position
    37. line_x = WINDOW_WIDTH // 2
    38. line_y = FIELD_HEIGHT
    39.  
    40. # Line direction
    41. line_direction = random.choice([-1, 1])
    42.  
    43. # Game loop
    44. running = True
    45. while running:
    46. # Handle events
    47. for event in pygame.event.get():
    48. if event.type == pygame.QUIT:
    49. running = False
    50. elif event.type == pygame.KEYDOWN:
    51. if event.key == pygame.K_a and line_x <= FIELD_WIDTH * 3 // 4:
    52. line_x = FIELD_WIDTH * 3 // 4
    53. line_direction = 1
    54. time.sleep(random.uniform(0, 5))
    55. elif event.key == pygame.K_l and line_x >= FIELD_WIDTH // 4:
    56. line_x = FIELD_WIDTH // 4
    57. line_direction = -1
    58. time.sleep(random.uniform(0, 5))
    59.  
    60. # Move the line in a specific direction
    61. line_x += line_direction * LINE_SPEED
    62.  
    63. # Check if a player is losing ground
    64. if line_x <= FIELD_WIDTH // 4:
    65. player_l_area -= LINE_SPEED
    66. line_x = FIELD_WIDTH // 2 - player_a_area
    67. elif line_x >= FIELD_WIDTH * 3 // 4:
    68. player_a_area -= LINE_SPEED
    69. line_x = FIELD_WIDTH // 2 + player_l_area
    70.  
    71. # Update player-controlled areas
    72. player_a_area = FIELD_WIDTH // 2 - line_x
    73. player_l_area = line_x - FIELD_WIDTH // 2
    74.  
    75. # Draw the game field
    76. screen.fill((255, 255, 255))
    77. pygame.draw.line(screen, (0, 0, 0), (line_x, line_y), (line_x, WINDOW_HEIGHT), 2)
    78. pygame.draw.rect(screen, PLAYER_A_COLOR, (0, 0, player_a_area, FIELD_HEIGHT))
    79. pygame.draw.rect(screen, PLAYER_L_COLOR, (player_a_area, 0, player_l_area, FIELD_HEIGHT))
    80.  
    81. # Update the display
    82. pygame.display.flip()
    83.  
    84. # Wait for the next line movement
    85. time.sleep(0.1)
    86.  
    87. # Game over screen
    88. pygame.display.set_caption("Game Over")
    89. screen.fill((255, 255, 255))
    90. if player_a_area == 0:
    91. winner = "Player L"
    92. elif player_l_area == 0:
    93. winner = "Player A"
    94. text = pygame.font.Font(None, 36).render(f"Winner: {winner}", True, (0, 0, 0))
    95. text_rect = text.get_rect(center=(WINDOW_WIDTH // 2, WINDOW_HEIGHT // 2))
    96. screen.blit(text, text_rect)
    97. pygame.display.flip()
    98. time.sleep(3)
    99.  
    100. # Quit Pygame
    101. pygame.quit()
Add Comment
Please, Sign In to add comment
Advertisement