import * as fs from "fs";
const gameCode = `
import random
import sys
def create_board(width, height):
return [['.' for _ in range(width)] for _ in range(height)]
def print_board(board, snake, food, score):
display = [row[:] for row in board]
for x, y in snake:
if 0 <= x < len(display[0]) and 0 <= y < len(display):
display[y][x] = 'O'
hx, hy = snake[0]
if 0 <= hx < len(display[0]) and 0 <= hy < len(display):
display[hy][hx] = '@'
fx, fy = food
if 0 <= fx < len(display[0]) and 0 <= fy < len(display):
display[fy][fx] = '*'
print(f'Score: {score}')
for row in display:
print(' '.join(row))
print()
def run_game():
width, height = 20, 10
snake = [(5, 5), (4, 5), (3, 5)]
food = (12, 5)
score = 0
moves = [(1,0),(1,0),(1,0),(1,0),(1,0),(1,0),(1,0),(0,1),(0,1),(1,0),(1,0),(0,-1),(0,-1),(1,0)]
print('=== Snake Dash ===')
print('@ = snake head, O = snake body, * = food')
print()
for move in moves:
direction = move
head = (snake[0][0] + direction[0], snake[0][1] + direction[1])
if head[0] < 0 or head[0] >= width or head[1] < 0 or head[1] >= height:
print(f'Game Over! Hit a wall! Final Score: {score}')
return
if head in snake[1:]:
print(f'Game Over! Hit yourself! Final Score: {score}')
return
snake.insert(0, head)
if head == food:
score += 10
food = (random.randint(0, width-1), random.randint(0, height-1))
print(f'Nom! Score is now {score}')
else:
snake.pop()
board = create_board(width, height)
print_board(board, snake, food, score)
print(f'Demo complete! Final Score: {score}')
run_game()
`;
fs.writeFileSync('snake_dash.py', gameCode);
console.log('snake_dash.py written successfully.');
Game Concept
Title: Snake Dash
Genre: Arcade
A classic Snake game where the player navigates a growing snake to eat food while avoiding walls and self-collision. The snake grows longer with each food item consumed, increasing difficulty over time.
Final Attempt Status
Attempts
Attempt 1
Final Generated Rig Program
View program source (TypeScript)
Final Generated Game:
snake_dash.pyView game code (Python)
✅ Passed on attempt 1/3