
deepseek写程序了 - block puzzle game
版主: verdelite, TheMatrix
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
#4 Re: deepseek写程序了 - block puzzle game
静态的差不多就是前面那样了。再加几个block。
然后是动态的。
直接给它提了一些要求:
我都不知道怎么做,但是经过一两次修改,它就给回我这个结果 - 能drag了!
黄色旁边带白色的那个block是我用鼠标从下面drag上来的,然后在拖动block的时候,它在棋盘中有相应的block,两个一起运动。这太牛了。我从来都不知道怎么拖动一个滑块。

然后是动态的。
直接给它提了一些要求:
它的能力超乎我的想象。或者说我越来越担心了。Very good. Next, I want to add some human interactions.
1, I want to be able to use a mouse to click and drag and drop a block in the preview section to anywhere inside the game area.
2, when I click a block in the preview section, it should become larger with each square the same size as the board grid in the middle section. And when I drag the block, it should stay the same size.
3, the board should have variable that remember the occupied state of each grid. Initially, it's all empty.
4, I want to be able to drop the block that I'm dragging. When I drag the block over the board, it hovers over some corresponding squares in the board, and when these squares are empty, I can drop the block inside the board, so the corresponding squares are occupied. When any of the correspoding squares is already occupied when I drop the block, the block should go back to the preview section.
我都不知道怎么做,但是经过一两次修改,它就给回我这个结果 - 能drag了!
黄色旁边带白色的那个block是我用鼠标从下面drag上来的,然后在拖动block的时候,它在棋盘中有相应的block,两个一起运动。这太牛了。我从来都不知道怎么拖动一个滑块。

上次由 TheMatrix 在 2025年 2月 11日 17:05 修改。
原因: 未提供修改原因
原因: 未提供修改原因
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
#5 Re: deepseek写程序了 - block puzzle game
我必须得把它贡献出来了。因为接下来我感觉很难了。
代码: 全选
import tkinter as tk
import random
class TetrisGame:
def __init__(self, root):
self.root = root
self.root.title("Tetris Blocks Game")
self.root.configure(bg="#1A2B3C")
# Tetris blocks configuration
self.tetris_blocks = [
# Original Tetris blocks (7)
{"shape": [(0,0), (0,1), (0,2), (0,3)], "color": "#00F0F0"}, # I (4-square)
{"shape": [(0,0), (0,1), (1,0), (1,1)], "color": "#F0F000"}, # O
{"shape": [(0,0), (1,0), (1,1), (2,0)], "color": "#A000F0"}, # T
{"shape": [(0,1), (0,2), (1,0), (1,1)], "color": "#00F000"}, # S
{"shape": [(0,0), (0,1), (1,1), (1,2)], "color": "#F00000"}, # Z
{"shape": [(0,0), (1,0), (2,0), (2,1)], "color": "#0000F0"}, # J
{"shape": [(0,1), (1,1), (2,0), (2,1)], "color": "#F0A000"}, # L
# Custom blocks
{"shape": [(0,0)], "color": "#808080"}, # 1-square
{"shape": [(0,0), (0,1)], "color": "#404040"}, # 2-square
{"shape": [(0,0), (0,1), (0,2)], "color": "#800080"}, # 3-line
{"shape": [(0,0), (0,1), (1,1)], "color": "#FFA500"}, # L-3
# 5-square blocks
{"shape": [(0,0), (0,1), (0,2), (0,3), (0,4)], "color": "#00CED1"}, # 5-line (Dark Turquoise)
{"shape": [(0,0), (0,1), (0,2), (1,2), (2,2)], "color": "#FF0000"}, # Right-angle (Red)
# 9-square block
{"shape": [(0,0), (0,1), (0,2),
(1,0), (1,1), (1,2),
(2,0), (2,1), (2,2)], "color": "#FFD700"} # 3x3 (Gold)
]
# Color scheme
self.section_color = "#1A2B3C"
self.preview_bg = "#2A3B4C"
self.outer_border_color = "#E0E0E0"
self.grid_color = "#708090"
self.cell_color = "#2A3B4C"
# Board parameters
self.base_cell_size = 60
self.grid_border = 1
self.outer_border = 4
# Set initial window size
self.root.geometry("1000x800")
# Create main container
self.main_container = tk.Frame(root, bg=self.section_color)
self.main_container.pack(padx=20, pady=20, expand=True, fill=tk.BOTH)
# Configure layout sections
self.create_sections() # This creates middle_frame
self.create_board()
self.create_compact_preview()
# Initial draw
self.root.after(100, self.initial_draw)
self.middle_frame.bind("<Configure>", self.resize_board) # Now valid
self.dragging_block = None
self.dragging_offset = (0, 0)
self.board_state = [[False for _ in range(8)] for _ in range(8)]
self.drag_ghost = None
def create_sections(self):
"""Create sections with preview height half of board height"""
self.main_container.grid_rowconfigure(0, weight=1) # Upper
self.main_container.grid_rowconfigure(1, weight=6) # Middle (main board)
self.main_container.grid_rowconfigure(2, weight=3) # Lower (preview) - half of board height
self.main_container.grid_columnconfigure(0, weight=1)
self.upper_frame = tk.Frame(self.main_container, bg=self.section_color)
self.middle_frame = tk.Frame(self.main_container, bg=self.section_color)
self.lower_frame = tk.Frame(self.main_container, bg=self.preview_bg)
self.upper_frame.grid(row=0, column=0, sticky="nsew")
self.middle_frame.grid(row=1, column=0, sticky="nsew")
self.lower_frame.grid(row=2, column=0, sticky="nsew")
def create_board(self):
"""Create main game board"""
self.board_container = tk.Frame(self.middle_frame,
bg=self.outer_border_color,
padx=self.outer_border,
pady=self.outer_border)
self.board_container.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
self.canvas = tk.Canvas(self.board_container,
bg=self.grid_color,
highlightthickness=0)
self.canvas.pack()
def create_compact_preview(self):
"""Create preview container aligned with board width"""
# Create container frame with same width as board
self.preview_container = tk.Frame(self.lower_frame,
bg=self.preview_bg,
width=self.canvas.winfo_width(),
height=100)
self.preview_container.pack_propagate(False) # Keep fixed size
self.preview_container.pack(side=tk.TOP, pady=10)
self.preview_canvas = tk.Canvas(self.preview_container,
bg=self.preview_bg,
highlightthickness=0)
self.preview_canvas.pack(expand=True, fill=tk.BOTH)
self.generate_new_blocks()
# Modify binding for preview canvas
self.preview_canvas.bind("<Button-1>", self.start_drag)
self.preview_canvas.bind("<B1-Motion>", self.drag_block)
self.preview_canvas.bind("<ButtonRelease-1>", self.drop_block)
def generate_new_blocks(self):
"""Select 3 random blocks"""
self.selected_blocks = [random.choice(self.tetris_blocks) for _ in range(3)]
self.draw_preview_blocks()
def draw_preview_blocks(self):
"""Modified to handle blocks with different cell counts"""
self.preview_canvas.delete("all")
# Get dimensions
container_width = self.preview_container.winfo_width()
container_height = self.preview_container.winfo_height()
main_cell_size = self.canvas.winfo_width() // 8
# Set preview cell size to 50% of board cells
cell_size = int(main_cell_size * 0.5)
cell_size = max(min(cell_size, 40), 15)
# Calculate horizontal margins (same as board's)
margin = self.outer_border * 2
available_width = container_width - margin * 2
# Space blocks evenly in available width
section_width = available_width // 3
start_x = margin
for i, block in enumerate(self.selected_blocks):
# Calculate block position
x_center = start_x + (section_width * i) + (section_width // 2)
y_center = container_height // 2
# Calculate block bounds (works with any number of cells)
max_x = max(dx for dx, dy in block["shape"]) if block["shape"] else 0
max_y = max(dy for dx, dy in block["shape"]) if block["shape"] else 0
block_width = (max_x + 1) * cell_size
block_height = (max_y + 1) * cell_size
# Position block
x_offset = x_center - (block_width // 2)
y_offset = y_center - (block_height // 2)
# Draw cells
for dx, dy in block["shape"]:
x1 = x_offset + dx * cell_size
y1 = y_offset + dy * cell_size
x2 = x1 + cell_size
y2 = y1 + cell_size
self.preview_canvas.create_rectangle(
x1, y1, x2, y2,
fill=block["color"],
outline=self.preview_bg,
width=1
)
def initial_draw(self):
"""Handle initial drawing"""
self.resize_board(None)
self.draw_preview_blocks()
def resize_board(self, _):
"""Handle resizing of both board and preview"""
# Resize main board
max_width = self.middle_frame.winfo_width() - self.outer_border*4
max_height = self.middle_frame.winfo_height() - self.outer_border*4
cell_size = min(max_width//8, max_height//8)
cell_size = max(cell_size, 30)
board_size = cell_size * 8
self.canvas.config(width=board_size, height=board_size)
self.draw_grid(cell_size)
# Resize preview container to match board width
self.preview_container.config(width=board_size)
self.draw_preview_blocks()
def draw_grid(self, cell_size):
"""Draw game board grid"""
self.canvas.delete("all")
for row in range(8):
for col in range(8):
x1 = col * cell_size + self.grid_border
y1 = row * cell_size + self.grid_border
x2 = (col+1) * cell_size
y2 = (row+1) * cell_size
self.canvas.create_rectangle(
x1, y1, x2, y2,
fill=self.cell_color,
outline=self.grid_color,
width=self.grid_border
)
def on_click(self, event):
"""Handle board clicks"""
if not self.canvas.winfo_exists():
return
cell_size = self.canvas.winfo_width() // 8
col = (event.x - self.grid_border) // cell_size
row = (event.y - self.grid_border) // cell_size
if 0 <= row < 8 and 0 <= col < 8:
print(f"Clicked cell: ({row}, {col})")
x1 = col * cell_size + self.grid_border
y1 = row * cell_size + self.grid_border
x2 = (col+1) * cell_size
y2 = (row+1) * cell_size
self.canvas.create_rectangle(
x1, y1, x2, y2,
fill="#3A4B5C",
outline=self.grid_color,
width=self.grid_border
)
def drag_block(self, event):
if self.dragging_block:
# Move drag ghost
x = event.x_root - self.root.winfo_x() - self.dragging_offset[0]
y = event.y_root - self.root.winfo_y() - self.dragging_offset[1]
self.drag_ghost.place(x=x, y=y)
# Show placement preview on board
self.show_placement_preview(x, y)
def show_placement_preview(self, x, y):
# Convert screen coordinates to board coordinates
board_x = x - self.board_container.winfo_x()
board_y = y - self.board_container.winfo_y()
# Calculate grid position
cell_size = self.cell_size
col = (board_x - self.outer_border) // cell_size
row = (board_y - self.outer_border) // cell_size
# Draw preview
self.canvas.delete("preview")
if 0 <= col < 8 and 0 <= row < 8:
valid = True
for (dx, dy) in self.dragging_block["shape"]:
if not (0 <= col+dx < 8 and 0 <= row+dy < 8):
valid = False
break
if self.board_state[row+dy][col+dx]:
valid = False
break
if valid:
for (dx, dy) in self.dragging_block["shape"]:
x1 = (col + dx) * cell_size + self.grid_border
y1 = (row + dy) * cell_size + self.grid_border
x2 = x1 + cell_size
y2 = y1 + cell_size
self.canvas.create_rectangle(
x1, y1, x2, y2,
fill=self.dragging_block["color"],
outline=self.grid_color,
width=self.grid_border,
tags="preview"
)
def drop_block(self, event):
if self.dragging_block:
# Remove drag ghost
self.drag_ghost.place_forget()
self.drag_ghost = None
# Calculate board position
board_x = event.x - self.board_container.winfo_x()
board_y = event.y - self.board_container.winfo_y()
cell_size = self.cell_size
col = (board_x - self.outer_border) // cell_size
row = (board_y - self.outer_border) // cell_size
# Validate placement
valid = True
occupied_cells = []
for (dx, dy) in self.dragging_block["shape"]:
target_col = col + dx
target_row = row + dy
if not (0 <= target_col < 8 and 0 <= target_row < 8):
valid = False
break
if self.board_state[target_row][target_col]:
valid = False
break
occupied_cells.append((target_row, target_col))
if valid:
# Update board state
for row_idx, col_idx in occupied_cells:
self.board_state[row_idx][col_idx] = True
# Draw permanent block
for (dx, dy) in self.dragging_block["shape"]:
x1 = (col + dx) * cell_size + self.grid_border
y1 = (row + dy) * cell_size + self.grid_border
x2 = x1 + cell_size
y2 = y1 + cell_size
self.canvas.create_rectangle(
x1, y1, x2, y2,
fill=self.dragging_block["color"],
outline=self.grid_color,
width=self.grid_border
)
else:
# Return block to preview
self.generate_new_blocks()
self.dragging_block = None
self.canvas.delete("preview")
def calculate_preview_cell_size(self):
main_cell_size = self.canvas.winfo_width() // 8
return int(main_cell_size * 0.3)
def start_drag(self, event):
# Get current board cell size
self.cell_size = self.canvas.winfo_width() // 8 if self.canvas.winfo_width() else 60
# Find which block was clicked
preview_cell_size = self.calculate_preview_cell_size()
container_width = self.preview_container.winfo_width()
section_width = container_width // 3
col = event.x // section_width
if 0 <= col < len(self.selected_blocks):
block = self.selected_blocks[col]
# Convert preview click position to block grid coordinates
block_x = (event.x - (col * section_width)) // preview_cell_size
block_y = (event.y - (self.preview_container.winfo_height()//2)) // preview_cell_size
# Calculate offset in board cell sizes
self.dragging_offset = (
block_x * self.cell_size,
block_y * self.cell_size
)
# Create drag ghost at board cell size
self.dragging_block = {
"shape": block["shape"],
"color": block["color"],
"cell_size": self.cell_size
}
# Create ghost canvas
self.drag_ghost = tk.Canvas(self.root,
width=(max(x for x,y in block["shape"])+1)*self.cell_size,
height=(max(y for x,y in block["shape"])+1)*self.cell_size,
highlightthickness=0)
self.draw_ghost_block()
# Position ghost at click location
ghost_x = event.x_root - self.root.winfo_x() - self.dragging_offset[0]
ghost_y = event.y_root - self.root.winfo_y() - self.dragging_offset[1]
self.drag_ghost.place(x=ghost_x, y=ghost_y)
def draw_ghost_block(self):
self.drag_ghost.delete("all")
cs = self.dragging_block["cell_size"]
for (dx, dy) in self.dragging_block["shape"]:
x1 = dx * cs
y1 = dy * cs
x2 = x1 + cs
y2 = y1 + cs
self.drag_ghost.create_rectangle(
x1, y1, x2, y2,
fill=self.dragging_block["color"],
outline=self.grid_color,
width=self.grid_border
)
def main():
root = tk.Tk()
game = TetrisGame(root)
game.canvas.bind("<Button-1>", game.on_click)
root.mainloop()
if __name__ == "__main__":
main()
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
#6 Re: deepseek写程序了 - block puzzle game
程序有400行了。我自己一行没写。
我没法写,因为我改一行的话,我都不知道怎么跟它说。我要告诉它我改了一个地方,否则它接不上。但是我怎么告诉它我改了一个地方呢?我把整个程序post上去?或者只post我改的那个函数?如果我改了多个函数呢?或者我用语言描述我改了什么?
我如果坚持全让它写的话,接下来的描述也越来越难了。
而且对话越来越长,我怕它写了后面忘了前面的,它能都记住吗?不过到目前为止,还没有发生写了后面忘了前面的事情。
上次由 TheMatrix 在 2025年 2月 11日 17:19 修改。
原因: 未提供修改原因
原因: 未提供修改原因
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
#9 Re: deepseek写程序了 - block puzzle game
程序猿要失业了,尤其是游戏编程!
此网站Yesterday 写了: ↑
(得了癌症)复发也可以治,治愈本来就不应该是目标。
得了癌症治疗的目标本来就是不应该治愈,那是啥?还复发也可以治?什么鬼?别说复发,就说第一次被诊断出xxCa.,多少人当场崩溃?还复发可以治?我几个亲戚都是复发了人完了,怎么不治了?推诿回家等S呢?
(得了癌症)复发也可以治,治愈本来就不应该是目标。
得了癌症治疗的目标本来就是不应该治愈,那是啥?还复发也可以治?什么鬼?别说复发,就说第一次被诊断出xxCa.,多少人当场崩溃?还复发可以治?我几个亲戚都是复发了人完了,怎么不治了?推诿回家等S呢?
#10 Re: deepseek写程序了 - block puzzle game
当然是吵得,这是蒸馏牛b得地方
If printing money would end poverty, printing diplomas would end stupidity.
-
- 论坛支柱
2024年度优秀版主
TheMatrix 的博客 - 帖子互动: 271
- 帖子: 13544
- 注册时间: 2022年 7月 26日 00:35
#14 Re: deepseek写程序了 - block puzzle game
没写完。
可能写不完了。
感觉400行可能是它的极限的。或者说是这种工作模式的极限。
我看了你写过的与AI协同工作的模式,你说先和它讨论设计,讨论架构,然后是逐步完善细节?
这两天我也在想如何与AI协同工作。也许只能是你说的这种模式。
其实想想也对。你就算是和一个人协同,首先的首先,这个程序到底是谁写?假定是我写,另一个人是辅助。那么他就要懂我写的程序,才能提出修改意见。或者假定是他写,我来辅助。那我也要懂他的程序,才能提出修改意见。除非,是全交给他,我不管了。
AI的情况,全交给它可能写不了大的,400行顶天了。我现在就是这个情况。我一行没写,也没有仔细看它写的。完全是看运行结果,然后提要求。但是每个来回不是这不对就是那不对。最后一次我跟它说把全部的code再给回我一次,因为我这边乱套了。结果它给回我的不是400行了,变成300行了。
我不是用cursor的,我直接在deepseek网站上对话的。
目前我感觉,AI编程取代不了人。
#15 Re: deepseek写程序了 - block puzzle game
这就是HCI说的落不了地。 开始一个事情容易,但是能把起了头的事情干完是一种能力。这种能力就是人也不是个个都有的。靠AI没戏,还是得有人掌控全局。人掌控全局就不能让A。我看好的也仅仅是人+AI能落地。
你这个400行,就是我上次说的碎片化。其实400行都多。 如果每个文件不超过40行,或者每次定位要改的部分在40行之内,那改起来就容易了。怎么碎片化我还没搞定。
我下一步还不是用agent写程序。我打算先让agent做literature survey。
你这个400行,就是我上次说的碎片化。其实400行都多。 如果每个文件不超过40行,或者每次定位要改的部分在40行之内,那改起来就容易了。怎么碎片化我还没搞定。
我下一步还不是用agent写程序。我打算先让agent做literature survey。
TheMatrix 写了: 2025年 2月 12日 17:46 没写完。
可能写不完了。
感觉400行可能是它的极限的。或者说是这种工作模式的极限。
我看了你写过的与AI协同工作的模式,你说先和它讨论设计,讨论架构,然后是逐步完善细节?
这两天我也在想如何与AI协同工作。也许只能是你说的这种模式。
其实想想也对。你就算是和一个人协同,首先的首先,这个程序到底是谁写?假定是我写,另一个人是辅助。那么他就要懂我写的程序,才能提出修改意见。或者假定是他写,我来辅助。那我也要懂他的程序,才能提出修改意见。除非,是全交给他,我不管了。
AI的情况,全交给它可能写不了大的,400行顶天了。我现在就是这个情况。我一行没写,也没有仔细看它写的。完全是看运行结果,然后提要求。但是每个来回不是这不对就是那不对。最后一次我跟它说把全部的code再给回我一次,因为我这边乱套了。结果它给回我的不是400行了,变成300行了。
我不是用cursor的,我直接在deepseek网站上对话的。
目前我感觉,AI编程取代不了人。
-
- 论坛元老
Caravel 的博客 - 帖子互动: 669
- 帖子: 26774
- 注册时间: 2022年 7月 24日 17:21
#16 Re: deepseek写程序了 - block puzzle game
目前的AI还做不了特别复杂的codewdong 写了: 2025年 2月 12日 20:47 这就是HCI说的落不了地。 开始一个事情容易,但是能把起了头的事情干完是一种能力。这种能力就是人也不是个个都有的。靠AI没戏,还是得有人掌控全局。人掌控全局就不能让A。我看好的也仅仅是人+AI能落地。
你这个400行,就是我上次说的碎片化。其实400行都多。 如果每个文件不超过40行,或者每次定位要改的部分在40行之内,那改起来就容易了。怎么碎片化我还没搞定。
我下一步还不是用agent写程序。我打算先让agent做literature survey。
这应该还是目前的训练没有到位
但是从推理模型做数学题就可以看出来它们可以做很复杂的过程,但是需要学习基本的推理步骤。
还有一种可能是ai必须跟编译器结合起来,一边写,一边verify。
-
- 论坛元老
Caravel 的博客 - 帖子互动: 669
- 帖子: 26774
- 注册时间: 2022年 7月 24日 17:21
#17 Re: deepseek写程序了 - block puzzle game
他们可以ioi拿金牌,说明只要套路训练好了就可以TheMatrix 写了: 2025年 2月 12日 17:46 没写完。
可能写不完了。
感觉400行可能是它的极限的。或者说是这种工作模式的极限。
我看了你写过的与AI协同工作的模式,你说先和它讨论设计,讨论架构,然后是逐步完善细节?
这两天我也在想如何与AI协同工作。也许只能是你说的这种模式。
其实想想也对。你就算是和一个人协同,首先的首先,这个程序到底是谁写?假定是我写,另一个人是辅助。那么他就要懂我写的程序,才能提出修改意见。或者假定是他写,我来辅助。那我也要懂他的程序,才能提出修改意见。除非,是全交给他,我不管了。
AI的情况,全交给它可能写不了大的,400行顶天了。我现在就是这个情况。我一行没写,也没有仔细看它写的。完全是看运行结果,然后提要求。但是每个来回不是这不对就是那不对。最后一次我跟它说把全部的code再给回我一次,因为我这边乱套了。结果它给回我的不是400行了,变成300行了。
我不是用cursor的,我直接在deepseek网站上对话的。
目前我感觉,AI编程取代不了人。
目前推理模型跟coding结合时间还不长,
x1

-
- 论坛元老
Caravel 的博客 - 帖子互动: 669
- 帖子: 26774
- 注册时间: 2022年 7月 24日 17:21
-
- 论坛元老
Caravel 的博客 - 帖子互动: 669
- 帖子: 26774
- 注册时间: 2022年 7月 24日 17:21
#20 Re: deepseek写程序了 - block puzzle game
incremental的训练非常重要
应该从一个原始的github开始,人是怎么计划的,写一个prompt,然后加一部分code
然后再进来一个ticket,加一段code
用这种history 记录训练模型
每一个单步难度远不如ioi