国内智能编程助手简易对比:文心一言、通义千问、智谱AI、讯飞星火、Kimi

国内智能编程助手简易对比:文心一言、通义千问、智谱AI、讯飞星火、Kimi

最近想给IDE选择一个智能编程助手插件,但鉴于国内百花齐放的现状,一时也不好选择用哪个。挑了几个主流的的平台,分别输入“用python实现雪花纷飞的场景”的简单需求,看看效果对比。备注:因国外插件使用成本远高于国内的原因,暂时放弃目前的头牌Copilot。

简单粗暴地甄选,来吧。

1.文心一言

( IDE插件名称:Baidu Comate)

生成代码:

import pygame

import random

import math

# 初始化pygame

pygame.init()

# 设置窗口大小

WIDTH, HEIGHT = 800, 600

screen = pygame.display.set_mode((WIDTH, HEIGHT))

pygame.display.set_caption("雪花纷飞")

# 定义雪花类

class Snowflake:

def __init__(self):

self.x = random.randint(0, WIDTH)

self.y = random.randint(0, HEIGHT)

self.size = random.randint(1, 5)

self.speed = random.randint(1, 3)

self.direction = random.randint(0, 360) / 180 * math.pi

def move(self):

self.x += self.speed * math.cos(self.direction)

self.y += self.speed * math.sin(self.direction)

# 如果雪花移出屏幕,则重新初始化位置

if self.x < 0 or self.x > WIDTH or self.y < 0 or self.y > HEIGHT:

self.__init__()

def draw(self):

pygame.draw.circle(screen, (255, 255, 255), (int(self.x), int(self.y)), self.size)

# 创建雪花列表

snowflakes = [Snowflake() for _ in range(100)]

# 游戏主循环

running = True

while running:

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

screen.fill((0, 0, 0)) # 清屏

for snowflake in snowflakes:

snowflake.move() # 移动雪花

snowflake.draw() # 绘制雪花

pygame.display.flip() # 更新屏幕显示

pygame.time.wait(10) # 控制帧率,使动画更流畅

pygame.quit()

#上述代码为修正后的结果,错误的原文代码就不贴了(报错:AttributeError: module 'pygame.math' has no attribute 'pi')。

效果:

备注:百度是唯一一个报了语法问题的,用了智谱AI修正后的效果

2.通义千问

( IDE插件名称:TONGYI Lingma)

生成代码:

import pygame

import random

# 初始化pygame

pygame.init()

# 设置窗口大小

screen = pygame.display.set_mode((800, 600))

# 雪花类

class Snowflake:

def __init__(self):

self.x = random.randint(0, 800)

self.y = random.randint(0, 100)

self.size = random.randint(5, 20)

self.speed = random.randint(1, 3)

def fall(self):

self.y += self.speed

if self.y > 600:

self.y = 0

def draw(self):

pygame.draw.circle(screen, (255, 255, 255), (int(self.x), int(self.y)), self.size)

# 创建雪花列表

snowflakes = [Snowflake() for _ in range(100)]

# 游戏主循环

running = True

while running:

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

# 填充背景色

screen.fill((0, 0, 128))

# 让雪花下落并绘制

for snowflake in snowflakes:

snowflake.fall()

snowflake.draw()

# 更新屏幕

pygame.display.flip()

# 控制帧率

pygame.time.Clock().tick(60)

# 退出pygame

pygame.quit()

生成效果:

3.智谱AI

( IDE插件名称:CodeGeeX)

生成代码:

import pygame

import random

# 初始化pygame

pygame.init()

# 设置窗口大小

screen = pygame.display.set_mode((800, 600))

# 雪花类

class Snowflake:

def __init__(self):

self.x = random.randint(0, 800)

self.y = random.randint(0, 100)

self.size = random.randint(5, 20)

self.speed = random.randint(1, 3)

def fall(self):

self.y += self.speed

if self.y > 600:

self.y = 0

def draw(self):

pygame.draw.circle(screen, (255, 255, 255), (int(self.x), int(self.y)), self.size)

# 创建雪花列表

snowflakes = [Snowflake() for _ in range(100)]

# 游戏主循环

running = True

while running:

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

# 填充背景色

screen.fill((0, 0, 128))

# 让雪花下落并绘制

for snowflake in snowflakes:

snowflake.fall()

snowflake.draw()

# 更新屏幕

pygame.display.flip()

# 控制帧率

pygame.time.Clock().tick(60)

# 退出pygame

pygame.quit()

生成效果:(你没看错,居然和通义千问生成的一模一样)

4.讯飞星火

( IDE插件名称:iFlyCode)

生成代码:

import pygame

import random

# 初始化pygame

pygame.init()

# 设置屏幕大小

screen_width = 800

screen_height = 600

screen = pygame.display.set_mode((screen_width, screen_height))

# 设置标题

pygame.display.set_caption("雪花纷飞")

# 定义雪花类

class Snowflake:

def __init__(self, x, y):

self.x = x

self.y = y

self.speed = random.randint(1, 3)

def move(self):

self.y += self.speed

if self.y > screen_height:

self.y = -10

self.x = random.randint(0, screen_width)

def draw(self, screen):

pygame.draw.circle(screen, (255, 255, 255), (self.x, self.y), 2)

# 创建雪花列表

snowflakes = [Snowflake(random.randint(0, screen_width), random.randint(0, screen_height)) for _ in range(200)]

# 游戏主循环

running = True

while running:

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

screen.fill((0, 0, 0))

for snowflake in snowflakes:

snowflake.move()

snowflake.draw(screen)

pygame.display.flip()

pygame.quit()

生成效果:

5.Kimi

( IDE插件名称:目前还未推出)

生成代码:

import pygame

import random

# 初始化pygame

pygame.init()

# 设置窗口大小

screen_width = 800

screen_height = 600

screen = pygame.display.set_mode((screen_width, screen_height))

# 设置标题和帧率

pygame.display.set_caption("Snowfall")

clock = pygame.time.Clock()

frame_rate = 60

# 雪花类

class Snowflake:

def __init__(self, x, y, size, speed):

self.x = x

self.y = y

self.size = size

self.speed = speed

def draw(self, surface):

pygame.draw.circle(surface, (255, 255, 255), (self.x, self.y), self.size)

def update(self):

# 雪花下落

self.y += self.speed

# 如果雪花飞出屏幕,重新生成在屏幕顶部

if self.y > screen_height:

self.y = random.randint(-50, -20)

self.x = random.randint(0, screen_width)

# 创建雪花列表

snowflakes = []

for i in range(200):

x = random.randint(0, screen_width)

y = random.randint(-50, -20)

size = random.randint(1, 4)

speed = random.randint(1, 3)

snowflake = Snowflake(x, y, size, speed)

snowflakes.append(snowflake)

# 游戏主循环

running = True

while running:

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

# 填充背景色

screen.fill((0, 0, 0))

# 绘制并更新雪花

for snowflake in snowflakes:

snowflake.draw(screen)

snowflake.update()

# 更新显示

pygame.display.flip()

# 控制帧率

clock.tick(frame_rate)

# 退出pygame

pygame.quit()

生成效果:

通过可选范围内的简单对比,我个人还是喜欢Kimi的“雪花纷飞”的风格,无奈Kimi暂时还没有推出IDE插件,遗憾用不了。那就暂时还是先用zhipuAI吧(之前安装试用过一小段时间)。

这个大模型对比其实并不全面也不客观,仅为个人的选择。如果大家有推荐更好的,欢迎留言,谢谢。

风雨相关