remove scripts
Browse files- scripts/snake-gpt-3.5.py +0 -139
- scripts/snake-llama-2-13b.py +0 -65
scripts/snake-gpt-3.5.py
DELETED
@@ -1,139 +0,0 @@
|
|
1 |
-
import pygame
|
2 |
-
import time
|
3 |
-
import random
|
4 |
-
|
5 |
-
pygame.init()
|
6 |
-
|
7 |
-
# Screen dimensions
|
8 |
-
screen_width = 800
|
9 |
-
screen_height = 600
|
10 |
-
|
11 |
-
# Colors
|
12 |
-
white = (255, 255, 255)
|
13 |
-
red = (213, 50, 80)
|
14 |
-
green = (0, 255, 0)
|
15 |
-
black = (0, 0, 0)
|
16 |
-
|
17 |
-
# Snake block size and speed
|
18 |
-
block_size = 20
|
19 |
-
snake_speed = 15
|
20 |
-
|
21 |
-
# Create the display
|
22 |
-
dis = pygame.display.set_mode((screen_width, screen_height))
|
23 |
-
pygame.display.set_caption("Snake Game")
|
24 |
-
|
25 |
-
|
26 |
-
# Snake function to draw the snake
|
27 |
-
def our_snake(block_size, snake_list):
|
28 |
-
for x in snake_list:
|
29 |
-
pygame.draw.rect(dis, green, [x[0], x[1], block_size, block_size])
|
30 |
-
|
31 |
-
|
32 |
-
# Game loop
|
33 |
-
def game_loop():
|
34 |
-
game_over = False
|
35 |
-
game_close = False
|
36 |
-
|
37 |
-
# Initial position of the snake
|
38 |
-
snake_x = screen_width / 2
|
39 |
-
snake_y = screen_height / 2
|
40 |
-
|
41 |
-
# Initial speed of the snake
|
42 |
-
snake_x_change = 0
|
43 |
-
snake_y_change = 0
|
44 |
-
|
45 |
-
# Snake body (a list of coordinates)
|
46 |
-
snake_list = []
|
47 |
-
length_of_snake = 1
|
48 |
-
|
49 |
-
# Initial position of the food
|
50 |
-
food_x = (
|
51 |
-
round(random.randrange(0, screen_width - block_size) / block_size) * block_size
|
52 |
-
)
|
53 |
-
food_y = (
|
54 |
-
round(random.randrange(0, screen_height - block_size) / block_size) * block_size
|
55 |
-
)
|
56 |
-
|
57 |
-
while not game_over:
|
58 |
-
while game_close == True:
|
59 |
-
dis.fill(white)
|
60 |
-
font_style = pygame.font.SysFont(None, 50)
|
61 |
-
message = font_style.render(
|
62 |
-
"You Lost! Press Q-Quit or C-Play Again", True, black
|
63 |
-
)
|
64 |
-
dis.blit(message, [screen_width / 6, screen_height / 3])
|
65 |
-
|
66 |
-
pygame.display.update()
|
67 |
-
|
68 |
-
for event in pygame.event.get():
|
69 |
-
if event.type == pygame.KEYDOWN:
|
70 |
-
if event.key == pygame.K_q:
|
71 |
-
game_over = True
|
72 |
-
game_close = False
|
73 |
-
if event.key == pygame.K_c:
|
74 |
-
game_loop()
|
75 |
-
|
76 |
-
for event in pygame.event.get():
|
77 |
-
if event.type == pygame.QUIT:
|
78 |
-
game_over = True
|
79 |
-
if event.type == pygame.KEYDOWN:
|
80 |
-
if event.key == pygame.K_LEFT:
|
81 |
-
snake_x_change = -block_size
|
82 |
-
snake_y_change = 0
|
83 |
-
elif event.key == pygame.K_RIGHT:
|
84 |
-
snake_x_change = block_size
|
85 |
-
snake_y_change = 0
|
86 |
-
elif event.key == pygame.K_UP:
|
87 |
-
snake_y_change = -block_size
|
88 |
-
snake_x_change = 0
|
89 |
-
elif event.key == pygame.K_DOWN:
|
90 |
-
snake_y_change = block_size
|
91 |
-
snake_x_change = 0
|
92 |
-
|
93 |
-
if (
|
94 |
-
snake_x >= screen_width
|
95 |
-
or snake_x < 0
|
96 |
-
or snake_y >= screen_height
|
97 |
-
or snake_y < 0
|
98 |
-
):
|
99 |
-
game_close = True
|
100 |
-
|
101 |
-
snake_x += snake_x_change
|
102 |
-
snake_y += snake_y_change
|
103 |
-
dis.fill(white)
|
104 |
-
|
105 |
-
pygame.draw.rect(dis, red, [food_x, food_y, block_size, block_size])
|
106 |
-
snake_head = []
|
107 |
-
snake_head.append(snake_x)
|
108 |
-
snake_head.append(snake_y)
|
109 |
-
snake_list.append(snake_head)
|
110 |
-
if len(snake_list) > length_of_snake:
|
111 |
-
del snake_list[0]
|
112 |
-
|
113 |
-
for x in snake_list[:-1]:
|
114 |
-
if x == snake_head:
|
115 |
-
game_close = True
|
116 |
-
|
117 |
-
our_snake(block_size, snake_list)
|
118 |
-
pygame.display.update()
|
119 |
-
|
120 |
-
if snake_x == food_x and snake_y == food_y:
|
121 |
-
food_x = (
|
122 |
-
round(random.randrange(0, screen_width - block_size) / block_size)
|
123 |
-
* block_size
|
124 |
-
)
|
125 |
-
food_y = (
|
126 |
-
round(random.randrange(0, screen_height - block_size) / block_size)
|
127 |
-
* block_size
|
128 |
-
)
|
129 |
-
length_of_snake += 1
|
130 |
-
|
131 |
-
pygame.display.update()
|
132 |
-
|
133 |
-
pygame.time.Clock().tick(snake_speed)
|
134 |
-
|
135 |
-
pygame.quit()
|
136 |
-
quit()
|
137 |
-
|
138 |
-
|
139 |
-
game_loop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/snake-llama-2-13b.py
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
# Define the grid size and the snake's starting position
|
2 |
-
grid_size = 10
|
3 |
-
snake_start_x = 5
|
4 |
-
snake_start_y = 3
|
5 |
-
|
6 |
-
# Define the snake's direction and length
|
7 |
-
snake_direction = 'right'
|
8 |
-
snake_length = 3
|
9 |
-
|
10 |
-
# Create an empty list to store the grid values
|
11 |
-
grid = [None] * (grid_size * grid_size)
|
12 |
-
|
13 |
-
# Initialize the grid with walls
|
14 |
-
for y in range(grid_size):
|
15 |
-
for x in range(grid_size):
|
16 |
-
if x == snake_start_x and y == snake_start_y:
|
17 |
-
grid[y * grid_size + x] = 1
|
18 |
-
else:
|
19 |
-
grid[y * grid_size + x] = 0
|
20 |
-
|
21 |
-
# Define the game loop
|
22 |
-
while True:
|
23 |
-
# Get the user's input
|
24 |
-
input_direction = input("Enter a direction (left, right, up, or down): ")
|
25 |
-
|
26 |
-
# Check if the user has entered a valid direction
|
27 |
-
if input_direction not in ['left', 'right', 'up', 'down']:
|
28 |
-
print("Invalid direction. Please enter a valid direction.")
|
29 |
-
continue
|
30 |
-
|
31 |
-
# Update the snake's direction
|
32 |
-
snake_direction = input_direction
|
33 |
-
|
34 |
-
# Move the snake
|
35 |
-
for _ in if snake_direction == 'right':
|
36 |
-
grid[(grid_size - 1) * grid_size + snake_start_x] = 2
|
37 |
-
grid[grid_size * snake_start_x + snake_start_y] = 2
|
38 |
-
elif snake_direction == 'left':
|
39 |
-
grid[grid_size * snake_start_x + snake_start_y] = 2
|
40 |
-
grid[(grid_size - 1) * grid_size + snake_start_x] = 2
|
41 |
-
elif snake_direction == 'up':
|
42 |
-
grid[grid_size * snake_start_x + snake_start_y - 1] = 2
|
43 |
-
grid[(grid_size - 1) * grid_size + snake_start_x] = 2
|
44 |
-
elif snake_direction == 'down':
|
45 |
-
grid[grid_size * snake_start_x + snake_start_y + 1] = 2
|
46 |
-
grid[(grid_size - 1) * grid_size + snake_start_x] = 2
|
47 |
-
|
48 |
-
# Check for collisions with the wall or the snake's tail
|
49 |
-
if grid[grid_size * snake_start_x + snake_start_y] == 2:
|
50 |
-
print("Game over! You have crashed into the wall.")
|
51 |
-
break
|
52 |
-
elif grid[(grid_size - 1) * grid_size + snake_start_x] == 2:
|
53 |
-
print("Game over! You have crashed into your own tail.")
|
54 |
-
break
|
55 |
-
|
56 |
-
# Print the updated grid
|
57 |
-
for y in range(grid_size):
|
58 |
-
for x in range(grid_size):
|
59 |
-
print(grid[y * grid_size + x], end=' ')
|
60 |
-
print()
|
61 |
-
|
62 |
-
# Ask the user if they want to play again
|
63 |
-
ask_again = input("Do you want to play again? (yes/no): ")
|
64 |
-
if ask_again.lower() != 'yes':
|
65 |
-
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|