Board logo

標題: [測試] 用 LM Studio 測試 Gemma 3 27B Q8 [打印本頁]

作者: 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:
  1. import pygame
  2. import random

  3. # Initialize Pygame
  4. pygame.init()

  5. # Screen dimensions
  6. screen_width = 800
  7. screen_height = 600
  8. screen = pygame.display.set_mode((screen_width, screen_height))
  9. pygame.display.set_caption("Space Invaders meets Breakout")

  10. # Colors
  11. white = (255, 255, 255)
  12. black = (0, 0, 0)
  13. red = (255, 0, 0)
  14. green = (0, 255, 0)
  15. blue = (0, 0, 255)
  16. purple = (128, 0, 128)

  17. # Paddle properties (Breakout influence)
  18. paddle_width = 100
  19. paddle_height = 10
  20. paddle_x = screen_width // 2 - paddle_width // 2
  21. paddle_speed = 5

  22. # Ball properties (Breakout influence)
  23. ball_size = 15
  24. ball_x = screen_width // 2
  25. ball_y = screen_height - 30  # Start above the paddle
  26. ball_x_speed = 4
  27. ball_y_speed = -4

  28. # Invader properties (Space Invaders influence)
  29. invader_width = 30
  30. invader_height = 25
  31. invaders = []
  32. num_invaders = 10
  33. invader_speed = 1
  34. invader_drop = 0  # How much the invaders drop each time they hit a wall

  35. for row in range(3):
  36.     for col in range(num_invaders // 3 + (1 if col < num_invaders % 3 else 0)): # Distribute evenly
  37.         x = col * (invader_width + 40) + 50
  38.         y = row * (invader_height + 30) + 50
  39.         invaders.append(pygame.Rect(x, y, invader_width, invader_height))

  40. # Brick properties (Breakout influence - for a shield)
  41. brick_width = 60
  42. brick_height = 20
  43. bricks = []
  44. for row in range(3):
  45.     for col in range(10):
  46.         x = col * (brick_width + 5) + 50
  47.         y = row * (brick_height + 5) + 50
  48.         bricks.append(pygame.Rect(x, y, brick_width, brick_height))

  49. # Score
  50. score = 0
  51. font = pygame.font.Font(None, 36)

  52. # Game over flag
  53. game_over = False

  54. # Load sound effects
  55. try:
  56.     brick_break_sound = pygame.mixer.Sound("brick_break.wav")  # Replace with your sound file
  57.     paddle_hit_sound = pygame.mixer.Sound("paddle_hit.wav") # Replace with your sound file
  58.     invader_shot_sound = pygame.mixer.Sound("laser.wav")      # Replace with your sound file
  59.     invader_destroyed_sound = pygame.mixer.Sound("explosion.wav")  # Replace with your sound file
  60. except pygame.error as e:
  61.     print(f"Error loading sounds: {e}. Sounds will be disabled.")
  62.     brick_break_sound = None
  63.     paddle_hit_sound = None
  64.     invader_shot_sound = None
  65.     invader_destroyed_sound = None

  66. # Game loop
  67. running = True
  68. clock = pygame.time.Clock()

  69. while running:
  70.     for event in pygame.event.get():
  71.         if event.type == pygame.QUIT:
  72.             running = False

  73.     if not game_over:
  74.         # Paddle movement (Breakout)
  75.         keys = pygame.key.get_pressed()
  76.         if keys[pygame.K_LEFT] and paddle_x > 0:
  77.             paddle_x -= paddle_speed
  78.         if keys[pygame.K_RIGHT] and paddle_x < screen_width - paddle_width:
  79.             paddle_x += paddle_speed

  80.         # Ball movement (Breakout)
  81.         ball_x += ball_x_speed
  82.         ball_y += ball_y_speed

  83.         # Ball collision with walls (Breakout)
  84.         if ball_x <= 0 or ball_x >= screen_width - ball_size:
  85.             ball_x_speed *= -1
  86.         if ball_y <= 0:
  87.             ball_y_speed *= -1

  88.         # Ball collision with paddle (Breakout)
  89.         if (
  90.             paddle_x < ball_x < paddle_x + paddle_width
  91.             and paddle_y < ball_y < paddle_y + paddle_height
  92.         ):
  93.             ball_y_speed *= -1
  94.             if paddle_hit_sound:
  95.                 paddle_hit_sound.play()

  96.         # Ball collision with bricks (Breakout)
  97.         for brick in bricks[:]:  # Iterate over a copy to allow removal
  98.             if ball_x > brick.left and ball_x < brick.right and ball_y > brick.top and ball_y < brick.bottom:
  99.                 bricks.remove(brick)
  100.                 score += 10
  101.                 ball_y_speed *= -1
  102.                 if brick_break_sound:
  103.                     brick_break_sound.play()

  104.         # Invader movement (Space Invaders)
  105.         for invader in invaders:
  106.             invader.x += invader_speed

  107.         # Invader collision with walls (Space Invaders)
  108.         if invaders and (invaders[0].right > screen_width or invaders[0].left < 0):
  109.             invader_speed *= -1
  110.             invader_drop += 20  # Drop the invaders down a bit
  111.             for invader in invaders:
  112.                 invader.y += invader_drop

  113.         # Ball collision with Invaders (Hybrid)
  114.         for invader in invaders[:]: # Iterate over copy for removal
  115.             if ball_x > invader.left and ball_x < invader.right and ball_y > invader.top and ball_y < invader.bottom:
  116.                 invaders.remove(invader)
  117.                 score += 50
  118.                 ball_y_speed *= -1  # Bounce the ball
  119.                 if invader_destroyed_sound:
  120.                     invader_destroyed_sound.play()

  121.         # Invader shooting (Space Invaders) - simplified for demonstration
  122.         if random.random() < 0.01: # 1% chance per frame
  123.             invader = random.choice(invaders)
  124.             shot_x = invader.centerx
  125.             shot_y = invader.bottom
  126.             # Simulate a shot (just draw a line for now - could be improved with actual projectiles)
  127.             pygame.draw.line(screen, red, (shot_x, shot_y), (shot_x, screen_height), 2)  # Red laser beam
  128.             if invader_shot_sound:
  129.                 invader_shot_sound.play()

  130.         # Game Over condition
  131.         if ball_y > screen_height or not invaders: # Ball falls off bottom OR all invaders destroyed
  132.             game_over = True


  133.     # Drawing (Pretty visuals)
  134.     screen.fill(black)  # Background

  135.     # Draw Bricks (Breakout shield)
  136.     for brick in bricks:
  137.         pygame.draw.rect(screen, green, brick)

  138.     # Draw Invaders (Space Invaders)
  139.     for invader in invaders:
  140.         pygame.draw.rect(screen, purple, invader)

  141.     # Draw Paddle (Breakout)
  142.     pygame.draw.rect(screen, white, (paddle_x, paddle_y, paddle_width, paddle_height))

  143.     # Draw Ball (Breakout)
  144.     pygame.draw.ellipse(screen, blue, (ball_x, ball_y, ball_size, ball_size))

  145.     # Draw Score
  146.     score_text = font.render("Score: " + str(score), True, white)
  147.     screen.blit(score_text, (10, 10))

  148.     if game_over:
  149.         game_over_text = font.render("Game Over! Score: " + str(score), True, red)
  150.         screen.blit(game_over_text, (screen_width // 2 - 200, screen_height // 2))

  151.     pygame.display.flip()
  152.     clock.tick(60)  # Limit frame rate to 60 FPS

  153. pygame.quit()
複製代碼
Comparing it with Grok 3 code at https://x.ai/news/grok-3





歡迎光臨 電腦領域 HKEPC Hardware (https://www.hkepc.com/forum/) Powered by Discuz! 7.2