作者: javacomhk 時間: 2025-3-16 03:41 標題: 用 LM Studio 測試 Gemma 3 27B Q8
本帖最後由 javacomhk 於 2025-3-15 20:52 編輯
Software : LM Studio 0.3.13
安裝教學參考
https://www.hkepc.com/forum/redi ... 42&pid=42509055
Model : Gemma 3 27B Q8 GGUF 29.57GB
State-of-the-art image + text input models from Google, built from the same research and tech used to create the Gemini models
Hardware used : MacBook Pro M2 Max 64GB 38 GPU Cores
呢個 local model 嘅 image input mode 就無謂試啦,我建議大家直接去用手機版 Google Gemini 好的。手機上裝 Google Gemini 方法參考看這篇。
測試 Programming task
Prompt:
Create a game that is a mixture of two classic games. Make it in pygame with sound effects and make it look pretty.
Reply:
- import pygame
- import random
- # Initialize Pygame
- pygame.init()
- # Screen dimensions
- screen_width = 800
- screen_height = 600
- screen = pygame.display.set_mode((screen_width, screen_height))
- pygame.display.set_caption("Space Invaders meets Breakout")
- # Colors
- white = (255, 255, 255)
- black = (0, 0, 0)
- red = (255, 0, 0)
- green = (0, 255, 0)
- blue = (0, 0, 255)
- purple = (128, 0, 128)
- # Paddle properties (Breakout influence)
- paddle_width = 100
- paddle_height = 10
- paddle_x = screen_width // 2 - paddle_width // 2
- paddle_speed = 5
- # Ball properties (Breakout influence)
- ball_size = 15
- ball_x = screen_width // 2
- ball_y = screen_height - 30 # Start above the paddle
- ball_x_speed = 4
- ball_y_speed = -4
- # Invader properties (Space Invaders influence)
- invader_width = 30
- invader_height = 25
- invaders = []
- num_invaders = 10
- invader_speed = 1
- invader_drop = 0 # How much the invaders drop each time they hit a wall
- for row in range(3):
- for col in range(num_invaders // 3 + (1 if col < num_invaders % 3 else 0)): # Distribute evenly
- x = col * (invader_width + 40) + 50
- y = row * (invader_height + 30) + 50
- invaders.append(pygame.Rect(x, y, invader_width, invader_height))
- # Brick properties (Breakout influence - for a shield)
- brick_width = 60
- brick_height = 20
- bricks = []
- for row in range(3):
- for col in range(10):
- x = col * (brick_width + 5) + 50
- y = row * (brick_height + 5) + 50
- bricks.append(pygame.Rect(x, y, brick_width, brick_height))
- # Score
- score = 0
- font = pygame.font.Font(None, 36)
- # Game over flag
- game_over = False
- # Load sound effects
- try:
- brick_break_sound = pygame.mixer.Sound("brick_break.wav") # Replace with your sound file
- paddle_hit_sound = pygame.mixer.Sound("paddle_hit.wav") # Replace with your sound file
- invader_shot_sound = pygame.mixer.Sound("laser.wav") # Replace with your sound file
- invader_destroyed_sound = pygame.mixer.Sound("explosion.wav") # Replace with your sound file
- except pygame.error as e:
- print(f"Error loading sounds: {e}. Sounds will be disabled.")
- brick_break_sound = None
- paddle_hit_sound = None
- invader_shot_sound = None
- invader_destroyed_sound = None
- # Game loop
- running = True
- clock = pygame.time.Clock()
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- if not game_over:
- # Paddle movement (Breakout)
- keys = pygame.key.get_pressed()
- if keys[pygame.K_LEFT] and paddle_x > 0:
- paddle_x -= paddle_speed
- if keys[pygame.K_RIGHT] and paddle_x < screen_width - paddle_width:
- paddle_x += paddle_speed
- # Ball movement (Breakout)
- ball_x += ball_x_speed
- ball_y += ball_y_speed
- # Ball collision with walls (Breakout)
- if ball_x <= 0 or ball_x >= screen_width - ball_size:
- ball_x_speed *= -1
- if ball_y <= 0:
- ball_y_speed *= -1
- # Ball collision with paddle (Breakout)
- if (
- paddle_x < ball_x < paddle_x + paddle_width
- and paddle_y < ball_y < paddle_y + paddle_height
- ):
- ball_y_speed *= -1
- if paddle_hit_sound:
- paddle_hit_sound.play()
- # Ball collision with bricks (Breakout)
- for brick in bricks[:]: # Iterate over a copy to allow removal
- if ball_x > brick.left and ball_x < brick.right and ball_y > brick.top and ball_y < brick.bottom:
- bricks.remove(brick)
- score += 10
- ball_y_speed *= -1
- if brick_break_sound:
- brick_break_sound.play()
- # Invader movement (Space Invaders)
- for invader in invaders:
- invader.x += invader_speed
- # Invader collision with walls (Space Invaders)
- if invaders and (invaders[0].right > screen_width or invaders[0].left < 0):
- invader_speed *= -1
- invader_drop += 20 # Drop the invaders down a bit
- for invader in invaders:
- invader.y += invader_drop
- # Ball collision with Invaders (Hybrid)
- for invader in invaders[:]: # Iterate over copy for removal
- if ball_x > invader.left and ball_x < invader.right and ball_y > invader.top and ball_y < invader.bottom:
- invaders.remove(invader)
- score += 50
- ball_y_speed *= -1 # Bounce the ball
- if invader_destroyed_sound:
- invader_destroyed_sound.play()
- # Invader shooting (Space Invaders) - simplified for demonstration
- if random.random() < 0.01: # 1% chance per frame
- invader = random.choice(invaders)
- shot_x = invader.centerx
- shot_y = invader.bottom
- # Simulate a shot (just draw a line for now - could be improved with actual projectiles)
- pygame.draw.line(screen, red, (shot_x, shot_y), (shot_x, screen_height), 2) # Red laser beam
- if invader_shot_sound:
- invader_shot_sound.play()
- # Game Over condition
- if ball_y > screen_height or not invaders: # Ball falls off bottom OR all invaders destroyed
- game_over = True
- # Drawing (Pretty visuals)
- screen.fill(black) # Background
- # Draw Bricks (Breakout shield)
- for brick in bricks:
- pygame.draw.rect(screen, green, brick)
- # Draw Invaders (Space Invaders)
- for invader in invaders:
- pygame.draw.rect(screen, purple, invader)
- # Draw Paddle (Breakout)
- pygame.draw.rect(screen, white, (paddle_x, paddle_y, paddle_width, paddle_height))
- # Draw Ball (Breakout)
- pygame.draw.ellipse(screen, blue, (ball_x, ball_y, ball_size, ball_size))
- # Draw Score
- score_text = font.render("Score: " + str(score), True, white)
- screen.blit(score_text, (10, 10))
- if game_over:
- game_over_text = font.render("Game Over! Score: " + str(score), True, red)
- screen.blit(game_over_text, (screen_width // 2 - 200, screen_height // 2))
- pygame.display.flip()
- clock.tick(60) # Limit frame rate to 60 FPS
- pygame.quit()
