Space Invaders are Here
AI generated image, any similarity to actual persons, living or dead, is purely coincidental
Do you know the Code? Simple yet multifaceted question can mean many things depending on the context.
“The Code” could refer to the secret code to unlock your phone, an organized set of legal norms like the Tax Code, a dress code for work, cultural or moral guidelines like the Ten Commandments. For computer enthusiasts, it often means binary or source code of a computer program. But it may well also be genetic code that defines how life works. Broadly speaking, the code is something used or applied to make stuff work, whether it’s your phone, a functioning government or society, a computer, or life itself. Crazy, right?
Last week, I was playing with a new LLM that was making waves – Grok 3. I was impressed by its responses. It was the first LLM I’ve tried that, on the first attempt, produced the code that actually worked and did exactly what I expected. Sure, I didn’t ask difficult questions. But often to me the very simple things done perfectly feel much better than complex ones done half-baked.
I tested other LLMs, and the results were mediocre. Below is the Grok 3 computer code in response to my prompt: “Help me write a computer classical arcade game Space Invaders in Python using pygame without the use of images, please use only text blocks or simple graphics”. Please feel free to try out this prompt for yourself and let me know your results.
My real “aha” moment with Grok 3 was yesterday, 28 February 2025. I turned on DeepSearch and asked it about the events at the White House that happened just a few hours before. And the response was simply AMAZING 😉
What is your experience with Grok 3? Do you like it or do you prefer other LLMs?
This article was written for fun, please do not judge. Instead, please share your comments in a constructive and respectful manner. The author and AI remain innocent until proven guilty.
Abbreviations: LLMs refer to both large language models and large thinking (reasoning) models.
# generated by Grok 3 on 21 February 2025 import pygame import random import sys # Initialize Pygame pygame.init() # Set up the display WIDTH = 800 HEIGHT = 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Space Invaders - Text Edition") # Colors WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) # Player properties player_size = 40 player_x = WIDTH // 2 - player_size // 2 player_y = HEIGHT - 60 player_speed = 5 # Bullet properties bullet_size = 10 bullet_speed = 7 bullets = [] # Enemy properties enemy_size = 30 enemy_speed = 1 enemy_rows = 4 enemy_cols = 10 enemies = [] # Create enemies def create_enemies(): for row in range(enemy_rows): for col in range(enemy_cols): enemy = { 'x': 100 + col * (enemy_size + 20), 'y': 50 + row * (enemy_size + 20), 'direction': 1 } enemies.append(enemy) # Game variables score = 0 clock = pygame.time.Clock() font = pygame.font.Font(None, 36) def draw_player(x, y): # Draw player as a triangle pygame.draw.polygon(screen, GREEN, [ (x + player_size // 2, y), (x, y + player_size), (x + player_size, y + player_size) ]) def draw_bullet(x, y): # Draw bullet as a small rectangle pygame.draw.rect(screen, WHITE, (x, y, bullet_size, bullet_size * 2)) def draw_enemy(x, y): # Draw enemy as a square with antenna pygame.draw.rect(screen, RED, (x, y, enemy_size, enemy_size)) pygame.draw.line(screen, RED, (x + enemy_size // 4, y), (x + enemy_size // 4, y - 10), 2) pygame.draw.line(screen, RED, (x + 3 * enemy_size // 4, y), (x + 3 * enemy_size // 4, y - 10), 2) def main(): global player_x, score create_enemies() game_over = False while not game_over: 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 len(bullets) < 3: bullets.append({ 'x': player_x + player_size // 2 - bullet_size // 2, 'y': player_y }) # Player movement keys = pygame.key.get_pressed() if keys[pygame.K_LEFT] and player_x > 0: player_x -= player_speed if keys[pygame.K_RIGHT] and player_x < WIDTH - player_size: player_x += player_speed # Update bullets for bullet in bullets[:]: bullet['y'] -= bullet_speed if bullet['y'] < 0: bullets.remove(bullet) # Update enemies move_down = False for enemy in enemies[:]: enemy['x'] += enemy_speed * enemy['direction'] if enemy['x'] <= 0 or enemy['x'] >= WIDTH - enemy_size: move_down = True if move_down: for enemy in enemies: enemy['y'] += enemy_size enemy['direction'] *= -1 if enemy['y'] > HEIGHT - enemy_size: game_over = True # Check collisions for bullet in bullets[:]: for enemy in enemies[:]: if (bullet['x'] >= enemy['x'] and bullet['x'] <= enemy['x'] + enemy_size and bullet['y'] >= enemy['y'] and bullet['y'] <= enemy['y'] + enemy_size): bullets.remove(bullet) enemies.remove(enemy) score += 10 break # Draw everything screen.fill((0, 0, 0)) # Black background draw_player(player_x, player_y) for bullet in bullets: draw_bullet(bullet['x'], bullet['y']) for enemy in enemies: draw_enemy(enemy['x'], enemy['y']) # Draw score score_text = font.render(f"Score: {score}", True, WHITE) screen.blit(score_text, (10, 10)) # Check win condition if not enemies: win_text = font.render("YOU WIN!", True, BLUE) screen.blit(win_text, (WIDTH//2 - 50, HEIGHT//2)) game_over = True pygame.display.flip() clock.tick(60) # Game over screen while game_over: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() pygame.display.flip() if __name__ == "__main__": main()