You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using deepseek-coder with ollama.
I can see in the output that the llm returns reasonable code, but somehow devica can not use it.
Any idea?
24.05.16 16:37:52: root: DEBUG : Response from the model: ```md
# Snake Game using Python and Pygame
## Files
File: `main.py`:
```python
import pygame
import random
class SnakeGame:
def __init__(self):
self.window = pygame.display.set_mode((800, 600))
self.snake = [(100, 100), (90, 100), (80, 100)]
self.food = None
self.score = 0
self.direction = 'right'
def draw_objects(self):
# Draw snake
for pixel in self.snake:
pygame.draw.rect(self.window, (0, 255, 0), (*pixel, 10, 10))
# Draw food
if self.food is not None:
pygame.draw.rect(self.window, (255, 0, 0), (*self.food, 10, 10))
def move_snake(self):
# Move snake based on direction
if self.direction == 'right':
new_head = (self.snake[0][0] + 10, self.snake[0][1])
elif self.direction == 'left':
new_head = (self.snake[0][0] - 10, self.snake[0][1])
elif self.direction == 'up':
new_head = (self.snake[0][0], self.snake[0][1] - 10)
elif self.direction == 'down':
new_head = (self.snake[0][0], self.snake[0][1] + 10)
# Add new head to snake and remove last element if food is not eaten
self.snake.insert(0, new_head)
if self.food is None or self.food != new_head:
self.snake.pop()
def eat_food(self):
# Check if snake head collides with food
if self.food == self.snake[0]:
self.score += 1
self.food = None
def place_food(self):
# Place new food at random position that is not occupied by the snake
while True:
x = random.randint(0, 800) // 10 * 10
y = random.randint(0, 600) // 10 * 10
food_position = (x, y)
if food_position not in self.snake:
self.food = food_position
break
def game_over(self):
# Check for collision with window border or snake body
if (self.snake[0][0] < 0 or self.snake[0][0] >= 800 or
self.snake[0][1] < 0 or self.snake[0][1] >= 600 or
self.snake[0] in self.snake[1:]):
return True
return False
def update(self):
# Update game state
self.move_snake()
self.eat_food()
if not self.food:
self.place_food()
def handle_events(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
return True
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT and self.direction != 'left':
self.direction = 'right'
elif event.key == pygame.K_LEFT and self.direction != 'right':
self.direction = 'left'
elif event.key == pygame.K_UP and self.direction != 'down':
self.direction = 'up'
elif event.key == pygame.K_DOWN and self.direction != 'up':
self.direction = 'down'
return False
def run(self):
# Main game loop
clock = pygame.time.Clock()
while True:
if self.handle_events():
break
self.window.fill((0, 0, 0))
self.update()
self.draw_objects()
pygame.display.flip()
clock.tick(10)
if self.game_over():
break
pygame.quit()
```
File: `requirements.txt`:
```text
pygame==2.1.2
```
## Instructions
To run the game, you need to have Python and Pygame installed on your system. You can install Pygame using pip:
```bash
pip install pygame
```
Then, you can run the game by executing `main.py` in a terminal or command prompt:
```bash
python main.py
```
Use arrow keys to control the snake and eat as much food as possible without colliding with the window border or the snake body. The score is displayed at the top of the screen.
Invalid response from the model, I'm trying again...
24.05.16 16:37:52: root: INFO : SOCKET info MESSAGE: {'type': 'warning', 'message': 'Invalid response from the model, trying again...'}
Maximum 5 attempts reached. try other models
24.05.16 16:37:54: root: INFO : SOCKET info MESSAGE: {'type': 'error', 'message': 'Maximum attempts reached. model keeps failing.'}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using deepseek-coder with ollama.
I can see in the output that the llm returns reasonable code, but somehow devica can not use it.
Any idea?
24.05.16 16:37:52: root: DEBUG : Response from the model: ```md
# Snake Game using Python and Pygame
Beta Was this translation helpful? Give feedback.
All reactions