Comment

Comment by sgslo

I ran the 'create a snake' game example using the paper's source at https://github.com/geekan/MetaGPT

The creation process used 11,940 tokens on input and 2,993 tokens on output, which cost $0.35 and $0.18, respectively.

The game it generated consisted of four python classes in four separate files: Main, Game, Snake, and Food.

The game executed without error on the first try, but the snake wasn't able to 'eat' the food. Here's the relevant code for 'eating' food:

    # Check if the snake ate the food
    if self.snake.body[0] == self.food.position:
        self.score += 1
        self.snake.grow()
        self.food.generate()
The issue was that the snake's body was represented as a list of lists, whereas the food position was stored in a tuple. After changing the food position to a list, the game worked correctly.
parent sgslo 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton