حاجی نیاز نبود این همه زحمت بکشی من با برنامه نویسی پایتون یه دونه chat bot از مدل چت جی پی تی شو بازی های زیادی ساختم و تو مسابقه برنامه نویسی هوش مصنوعی اول شدم ۱ هفته بعد میرم ترکیه مدالمو بگیرم.
یا اگه تو پایتون داری بهم بگو بهت کمک کنم یا کد بازی های خفن رو بدم یه مقداری از بازی ماینکرافت رو ساختم که کامل نیس ۸هزار تا سطر خط کد داره اگه خواستی بگو بدم هنوز دارم میسازمش ماینکرافت رو
ولی تا یه جایی تونستم
حالا خداروشکر آمریکا و ایران مذاکره کردن اخط تامیه مسابقه کنسل نشد .
اگه خواستی بگو راهنماییت کنم در مورد هوش مصنوعی یا طراحی سایت یا برنامه نویسی و ... کمکت کنم
و اینکه هوش مصنوعی با یه سری دیتا ها کار میکنه که بهش میگن deep learning که منظورش کار گروهیه
و قسمتی هم به mashin learning مربوط میشه که اونم به ۲ دسته تقسیم میشه یادگیری با نظارت یعنی بهش میگم اگه درست انجام بدی جایزه داری اگه نه که نداری و یادگیری بدون نظارت یعنی ما بهش یاد میدیم که کدوم خوبه ولی همه هوش مصنوعی ها منظورم ChatGPT رو با Deep Learning ساختن پس deep learning برای هوش مصنوعی خوبه.
توضیحش خیلی زیاده
حاجی بیا بهت کرد بازی پکمن و کد بازی همون که تو نوکیا هس بهش میگن snake نمیدونم چی اسمش یادم رفته
کد بازی پکمن :
import pygame
import sys
import random
# تنظیمات اولیه
pygame.init()
TILE_SIZE = 20
MAZE_WIDTH = 28
MAZE_HEIGHT = 17
WIDTH = MAZE_WIDTH * TILE_SIZE
HEIGHT = MAZE_HEIGHT * TILE_SIZE
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Pacman")
clock = pygame.time.Clock()
# رنگها
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
WHITE = (255, 255, 255)
# مراحل بازی
levels = [
[
"#############################",
"#....o..................o...#",
"#.####.#####.##.#####.####.#",
"#o####.#####.##.#####.####o#",
"#.####.#####.##.#####.####.#",
"#..........................#",
"#.####.##.########.##.####.#",
"#......##....##....##......#",
"######.##### ## #####.######",
"#..........................#",
"#.####.#####.##.#####.####.#",
"#o..##................##..o#",
"###.##.##.########.##.##.###",
"#......##....##....##......#",
"#.##########.##.##########.#",
"#..........................#",
"############################"
],
[
"############################",
"#............##............#",
"#.####.#####.##.#####.####.#",
"#.####.#####.##.#####.####.#",
"#..........................#",
"#.####.##.########.##.####.#",
"#......##....##....##......#",
"######.##### ## #####.######",
"#............##............#",
"#.####.#####.##.#####.####.#",
"#..##................##..##",
"###.##.##.########.##.##.###",
"#......##....##....##......#",
"#.##########.##.##########.#",
"#..........................#",
"#............##............#",
"############################"
],
[
"############################",
"#............##............#",
"#.####.#####.##.#####.####.#",
"#.####................####.#",
"#.####.##.########.##.####.#",
"#......##....##....##......#",
"######.##### ## #####.######",
"#............##............#",
"#.####.#####.##.#####.####.#",
"#..##................##..##",
"###.##.##.########.##.##.###",
"#......##....##....##......#",
"#.##########.##.##########.#",
"#..........................#",
"#............##............#",
"#............##............#",
"############################"
]
]
# کلاس پکمن
class Pacman:
def __init__(self):
self.x = 14
self.y = 12
self.dir_x = 0
self.dir_y = 0
def move(self, maze):
new_x = self.x + self.dir_x
new_y = self.y + self.dir_y
if 0 <= new_y < len(maze) and 0 <= new_x < len(maze[new_y]):
if maze[new_y][new_x] != "#":
self.x = new_x
self.y = new_y
def draw(self):
pygame.draw.circle(screen, YELLOW, (self.x * TILE_SIZE + TILE_SIZE // 2, self.y * TILE_SIZE + TILE_SIZE // 2), TILE_SIZE // 2)
# کلاس نقطهها
class Dot:
def __init__(self, maze):
self.dots = []
for y, row in enumerate(maze):
for x, col in enumerate(row):
if col == "." or col == "o":
self.dots.append((x, y))
def draw(self, maze):
for x, y in self.dots:
color = WHITE if maze[y][x] == "." else BLUE
pygame.draw.circle(screen, color, (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2), 3)
def eat(self, pacman):
if (pacman.x, pacman.y) in self.dots:
self.dots.remove((pacman.x, pacman.y))
# کلاس دشمنها
class Ghost:
def __init__(self, x, y, color):
self.x = x
self.y = y
self.color = color
def move(self, maze):
directions = [(-1,0), (1,0)]
random.shuffle(directions)
for dx, dy in directions:
new_x = self.x + dx
new_y = self.y + dy
if 0 <= new_y < len(maze) and 0 <= new_x < len(maze[new_y]):
if maze[new_y][new_x] != "#":
self.x = new_x
self.y = new_y
break
def draw(self):
pygame.draw.circle(screen, self.color, (self.x * TILE_SIZE + TILE_SIZE // 2, self.y * TILE_SIZE + TILE_SIZE // 2), TILE_SIZE // 2)
# تابع ساخت دشمنها
def create_ghosts():
return [
Ghost(13, 11, (255, 184, 255)), # صورتی
Ghost(14, 11, (255, 165, 0)) # نارنجی
]
# اجرای بازی
level_index = 0
maze = levels[level_index]
pacman = Pacman()
dots = Dot(maze)
ghosts = create_ghosts()
while True:
screen.fill(BLACK)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
pacman.dir_x, pacman.dir_y = -1, 0
elif event.key == pygame.K_RIGHT:
pacman.dir_x, pacman.dir_y = 1, 0
elif event.key == pygame.K_UP:
pacman.dir_x, pacman.dir_y = 0, -1
elif event.key == pygame.K_DOWN:
pacman.dir_x, pacman.dir_y = 0, 1
pacman.move(maze)
dots.eat(pacman)
# برخورد با دشمن
for ghost in ghosts:
ghost.move(maze)
ghost.draw()
if ghost.x == pacman.x and ghost.y == pacman.y:
print("باختی! 👻")
pygame.quit()
sys.exit()
# رفتن به مرحله بعد
if len(dots.dots) == 0:
level_index += 1
if level_index >= len(levels):
print("تبریک! همهی مراحل رو بردی 🎉")
pygame.quit()
sys.exit()
else:
maze = levels[level_index]
pacman = Pacman()
dots = Dot(maze)
ghosts = create_ghosts()
# رسم دیوارها
for y, row in enumerate(maze):
for x, col in enumerate(row):
if col == "#":
pygame.draw.rect(screen, BLUE, (x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE))
dots.draw(maze)
pacman.draw()
pygame.display.update()
clock.tick(10)
کد بازی snake :
import pygame
import random
import sys
pygame.init()
WIDTH, HEIGHT = 600, 400
CELL_SIZE = 20
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Snake Game")
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
font = pygame.font.SysFont("Arial", 24)
snake = [(100, 100), (90, 100), (80, 100)]
direction = "RIGHT"
food = (random.randrange(0, WIDTH // CELL_SIZE) * CELL_SIZE,
random.randrange(0, HEIGHT // CELL_SIZE) * CELL_SIZE)
score = 0
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP and direction != "DOWN":
direction = "UP"
elif event.key == pygame.K_DOWN and direction != "UP":
direction = "DOWN"
elif event.key == pygame.K_LEFT and direction != "RIGHT":
direction = "LEFT"
elif event.key == pygame.K_RIGHT and direction != "LEFT":
direction = "RIGHT"
x, y = snake[0]
if direction == "UP":
y -= CELL_SIZE
elif direction == "DOWN":
y += CELL_SIZE
elif direction == "LEFT":
x -= CELL_SIZE
elif direction == "RIGHT":
x += CELL_SIZE
x %= WIDTH
y %= HEIGHT
new_head = (x, y)
if new_head in snake:
pygame.quit()
sys.exit()
snake.insert(0, new_head)
if new_head == food:
score += 1
food = (random.randrange(0, WIDTH // CELL_SIZE) * CELL_SIZE,
random.randrange(0, HEIGHT // CELL_SIZE) * CELL_SIZE)
else:
snake.pop()
screen.fill(BLACK)
for segment in snake:
pygame.draw.rect(screen, GREEN, (*segment, CELL_SIZE, CELL_SIZE))
pygame.draw.rect(screen, RED, (*food, CELL_SIZE, CELL_SIZE))
score_text = font.render(f"امتیاز: {score}", True, WHITE)
screen.blit(score_text, (10, 10))
pygame.display.update()
clock.tick(10)
اگه خواستی بازی های دیگه ای هم میدم بهت