Closed antonkulaga closed 10 months ago
Hi @antonkulaga ,
Thanks for the link. We'll evaluate those cases with our chat version models and reply back later.
Hi, @antonkulaga
We have already released our chat model, try it out! -> https://huggingface.co/01-ai/Yi-34B-Chat
Here is the math & code tests in the video, responsed from our chat model. The math result is correct and the code result pass the compiler(but not work properly)
Let's solve the equation step by step:
25 - 4 * 2 + 3
First, we need to perform the multiplication:
4 * 2 = 8
Now, we substitute the result back into the equation:
25 - 8 + 3
Next, we perform the subtraction:
25 - 8 = 17
Finally, we add the last number:
17 + 3 = 20
So, the result is 20.
Creating a simple text-based version of the classic Snake game in Python is straightforward. The following is an example of how you can implement Snake using Python's built-in tkinter
module for the GUI.
First, you'll need to install tkinter
if you haven't already. You can install it using pip
:
pip install tk
Here's a simple implementation of Snake:
import tkinter as tk
import random
# Constants
GRID_SIZE = 20 # Size of each cell in the grid
GAME_WIDTH = 20 # Number of cells wide
GAME_HEIGHT = 20 # Number of cells high
# Colors
BG_COLOR = "white"
GRID_COLOR = "gray"
SNAKE_COLOR = "black"
FOOD_COLOR = "red"
# Initialize the window and the canvas
root = tk.Tk()
root.title("Snake Game")
root.resizable(False, False)
canvas = tk.Canvas(root, width=GRID_SIZE * GAME_WIDTH, height=GRID_SIZE * GAME_HEIGHT, bg=BG_COLOR)
canvas.pack()
# Create the snake
snake = [
[GAME_WIDTH // 2, GAME_HEIGHT // 2] # Head
]
direction = "right" # Direction the snake is facing
# Generate food
food_x, food_y = generate_food()
# Game loop
running = True
while running:
# Get input
key = get_key()
if key == "left":
direction = "left"
elif key == "right":
direction = "right"
elif key == "up":
direction = "up"
elif key == "down":
direction = "down"
# Move the snake
snake_head = snake[-1]
new_x = snake_head[0]
new_y = snake_head[1]
if direction == "left":
new_x -= 1
elif direction == "right":
new_x += 1
elif direction == "up":
new_y -= 1
elif direction == "down":
new_y += 1
# Check if the snake head hits the wall or itself
if new_x < 0 or new_x >= GAME_WIDTH or new_y < 0 or new_y >= GAME_HEIGHT:
running = False
break
elif new_x in [s[0] for s in snake] and new_y in [s[1] for s in snake] and new_x != snake_head[0] and new_y != snake_head[1]:
running = False
break
# Move the snake
snake.append([new_x, new_y])
snake.pop(0) # Remove the tail
# Draw the grid and the snake
canvas.delete("all")
draw_grid()
draw_snake(snake)
# Check if the snake ate the food
if snake_head[0] == food_x and snake_head[1] == food_y:
# Generate new food
food_x, food_y = generate_food()
# Grow the snake
snake.append([snake_head[0], snake_head[1]])
# Draw the food
canvas.create_oval(food_x * GRID_SIZE, food_y * GRID_SIZE, (food_x + 1) * GRID_SIZE, (food_y + 1) * GRID_SIZE, fill=FOOD_COLOR)
# Update the window
canvas.update()
root.update()
root.update_idletasks()
root.after(100, update_screen) # Call the update function every 100 ms
# Game over
root.destroy()
print("Game Over!")
And here are the helper functions:
def draw_grid():
for x in range(GAME_WIDTH):
for y in range(GAME_HEIGHT):
canvas.create_line(x * GRID_SIZE, y * GRID_SIZE, (x + 1) * GRID_SIZE, y * GRID_SIZE, fill=GRID_COLOR, width=1)
canvas.create_line(x * GRID_SIZE, y * GRID_SIZE, x * GRID_SIZE, (y + 1) * GRID_SIZE, fill=GRID_COLOR, width=1)
def draw_snake(snake):
for segment in snake:
canvas.create_rectangle(segment[0] * GRID_SIZE, segment[1] * GRID_SIZE, (segment[0] + 1) * GRID_SIZE, (segment[1] + 1) * GRID_SIZE, fill=SNAKE_COLOR)
def generate_food():
while True:
food_x = random.randint(0, GAME_WIDTH - 1)
food_y = random.randint(0, GAME_HEIGHT - 1)
if not (food_x in [s[0] for s in snake] and food_y in [s[1] for s in snake]):
return food_x, food_y
def get_key():
key = ""
while key not in ["left", "right", "up", "down"]:
key = input("Press left, right, up, or down: ")
return key
def update_screen():
global running
if not running:
return
root.update()
root.update_idletasks()
root.after(100, update_screen)
This code will create a window with a simple grid where the snake will move around. The snake will grow when it eats the food, and the game will end when the snake hits the wall or itself.
Please note that this is a very basic implementation and does not include all the features of a full-fledged Snake game, such as different game modes, scores, or power-ups. You can extend this code to add these features if you like.
Looks like it fails easy tasks on coding and math https://www.youtube.com/watch?v=On3Zuv27V3k suggest fixing it