Update README.md
Browse files
README.md
CHANGED
@@ -112,6 +112,97 @@ Using Gemma as the base model, Athene CodeGemma 2 7B pretrained variants are fur
|
|
112 |
### Example: Athene CodeGemma 2 7B v1.1
|
113 |
Athene CodeGemma 2 7B v1.1 successfully created snake game without errors compare to original codegemma-7b-it
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
# Uploaded model
|
116 |
|
117 |
- **Developed by:** EpistemeAI
|
|
|
112 |
### Example: Athene CodeGemma 2 7B v1.1
|
113 |
Athene CodeGemma 2 7B v1.1 successfully created snake game without errors compare to original codegemma-7b-it
|
114 |
|
115 |
+
|
116 |
+
```py
|
117 |
+
import pygame
|
118 |
+
import sys
|
119 |
+
import time
|
120 |
+
import random
|
121 |
+
|
122 |
+
# Initialize Pygame
|
123 |
+
pygame.init()
|
124 |
+
|
125 |
+
# Set up some constants
|
126 |
+
WIDTH = 800
|
127 |
+
HEIGHT = 600
|
128 |
+
BLOCK_SIZE = 20
|
129 |
+
|
130 |
+
# Create the game screen
|
131 |
+
screen = pygame.display.set_mode((WIDTH, HEIGHT))
|
132 |
+
|
133 |
+
# Set up the colors
|
134 |
+
BLACK = (0, 0, 0)
|
135 |
+
WHITE = (255, 255, 255)
|
136 |
+
RED = (255, 0, 0)
|
137 |
+
GREEN = (0, 255, 0)
|
138 |
+
|
139 |
+
# Set up the font
|
140 |
+
font = pygame.font.Font(None, 36)
|
141 |
+
|
142 |
+
# Set up the snake and food
|
143 |
+
snake = [(200, 200), (220, 200), (240, 200)]
|
144 |
+
food = (400, 300)
|
145 |
+
|
146 |
+
# Set up the direction
|
147 |
+
direction = 'RIGHT'
|
148 |
+
|
149 |
+
# Game loop
|
150 |
+
while True:
|
151 |
+
for event in pygame.event.get():
|
152 |
+
if event.type == pygame.QUIT:
|
153 |
+
pygame.quit()
|
154 |
+
sys.exit()
|
155 |
+
elif event.type == pygame.KEYDOWN:
|
156 |
+
if event.key == pygame.K_UP and direction!= 'DOWN':
|
157 |
+
direction = 'UP'
|
158 |
+
elif event.key == pygame.K_DOWN and direction!= 'UP':
|
159 |
+
direction = 'DOWN'
|
160 |
+
elif event.key == pygame.K_LEFT and direction!= 'RIGHT':
|
161 |
+
direction = 'LEFT'
|
162 |
+
elif event.key == pygame.K_RIGHT and direction!= 'LEFT':
|
163 |
+
direction = 'RIGHT'
|
164 |
+
|
165 |
+
# Move the snake
|
166 |
+
head = snake[-1]
|
167 |
+
if direction == 'UP':
|
168 |
+
new_head = (head[0], head[1] - BLOCK_SIZE)
|
169 |
+
elif direction == 'DOWN':
|
170 |
+
new_head = (head[0], head[1] + BLOCK_SIZE)
|
171 |
+
elif direction == 'LEFT':
|
172 |
+
new_head = (head[0] - BLOCK_SIZE, head[1])
|
173 |
+
elif direction == 'RIGHT':
|
174 |
+
new_head = (head[0] + BLOCK_SIZE, head[1])
|
175 |
+
snake.append(new_head)
|
176 |
+
|
177 |
+
# Check if the snake has eaten the food
|
178 |
+
if snake[-1] == food:
|
179 |
+
food = (random.randint(0, WIDTH - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE,
|
180 |
+
random.randint(0, HEIGHT - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE)
|
181 |
+
else:
|
182 |
+
snake.pop(0)
|
183 |
+
|
184 |
+
# Check if the snake has collided with the edge or itself
|
185 |
+
if (snake[-1][0] < 0 or snake[-1][0] >= WIDTH or
|
186 |
+
snake[-1][1] < 0 or snake[-1][1] >= HEIGHT or
|
187 |
+
snake[-1] in snake[:-1]):
|
188 |
+
print("Game Over!")
|
189 |
+
time.sleep(2)
|
190 |
+
break
|
191 |
+
|
192 |
+
# Draw the game screen
|
193 |
+
screen.fill(BLACK)
|
194 |
+
for pos in snake:
|
195 |
+
pygame.draw.rect(screen, GREEN, (pos[0], pos[1], BLOCK_SIZE, BLOCK_SIZE))
|
196 |
+
pygame.draw.rect(screen, RED, (food[0], food[1], BLOCK_SIZE, BLOCK_SIZE))
|
197 |
+
text = font.render(f'Score: {len(snake) - 3}', True, WHITE)
|
198 |
+
screen.blit(text, (10, 10))
|
199 |
+
pygame.display.flip()
|
200 |
+
|
201 |
+
# Cap the frame rate
|
202 |
+
pygame.time.Clock().tick(10)
|
203 |
+
|
204 |
+
```
|
205 |
+
|
206 |
# Uploaded model
|
207 |
|
208 |
- **Developed by:** EpistemeAI
|