一、前言
?
GPT-4o("o"代表"全能")具備處理各種文本、聲音和圖像資料的能力,能夠輸出多種格式的文本、聲音和圖像。
GPT-4o 的推出標志著 AI 技術的重大突破。它不再局限于單一媒介,而是首次實現了文本、語音和圖像的無縫整合。這種多媒體的即時響應能力完全突破了傳統人機交互的界限,使交流變得更加自然和流暢,引領了一場全新的交互革命。用戶無需在不同的應用間切換來適應各種輸入輸出形式,GPT-4o 可以一站式處理所有信息類型,無論是文字問題、語音命令還是圖像分析,都能迅速提供準確的反饋,大幅提升了效率和用戶體驗,開啟了交流的新時代。
在最新版本的 ChatGPT 中,這種能力得到了進一步加強,使得處理不同媒體形式的輸入輸出更加輕松自如。無論是日常對話和娛樂,還是專業領域的任務,如編程、數據分析、圖形設計或視頻編輯,GPT-4o 都能輕松勝任,成為用戶必不可少的生產力工具。
二、ChatGPT 4o 國內直接使用
介紹
ChatGPT4o功能:GPT-4o文本對話(支持聯網查詢)、Code Copilot(寫代碼、改bug、算法優化等)、DALL-E AI繪畫、AI語音對話(練習英語口語、模擬技術面試)、論文插件Consensus、專職家教(精通語數外,拍照上傳即可識別問題,給出權威回答,亦可用于模擬考試)、上傳文件、數據分析插件Data Analyst等100+GPTS插件。
網址:https://ssas.kupepoem.cn
網站優點:
支持OpenAI最新的ChatGPT4o。
同時支持PC、手機、平板。
不需要國外特殊網絡,可以直接使用,非常方便 。
系統運行非常穩定 。
?
支持官方最新推出的ChatGPT4o
支持官方最新出的GPTs,100+大模型
寫作相關的
生產力相關的
研究與分析相關的
教育相關的
編程相關的
Code Copilot AI編程大模型
探索GPT-->編程--》選擇Code Copilot
開始聊天。
進入聊天界面。
用Java編寫一個二分查找的代碼,添加中文注釋。
輸入:
用Java編寫一個二分查找的代碼,添加中文注釋。
?
給出了完整的Java代碼類,代碼中也包含了完善的注釋。并給出了很清晰的解析和進一步優化建議。把代碼拷到idea里運行。驗證下結果:
結果是正確的。
生成一個java實戰課程設計:做一個貪吃蛇游戲
輸入:
你是一位java技術專家,游戲開發高手,請用java開發一個貪吃蛇游戲,添加中文注釋,有個開始按鈕和暫停按鈕。
?
?
給了兩個類的完整代碼。還給了改進建議,我們先去idea運行看看。把代碼復制進來。
運行代碼。結果:
程序有點小問題,蛇吃不到食物。如圖。蛇跟食物會重疊一部分
讓 Code Copilot 幫我解決這個問題。直接把出問題的截圖給它。
重新生成的代碼復制到idea中。運行結果,可以正常吃到蛇了。
初步的貪吃蛇游戲就做成功了。
升級改進
?
給了改進建議思路。改~ 輸入:
再添加計分系統,顯示玩家的得分列表。
?
把生成的代碼復制到idea中運行;
玩兩把。
得分列表有了,但感覺沒啥特點。再加點需求 輸入:
得分列表按分數降序,每個得分旁邊增加一列:游戲結束時間。
?
代碼復制到idea中。運行。再玩兩把。嗯,效果可以。
提供源碼
有需要自取。ScoreManager.java - 管理分數的類
import?java.text.SimpleDateFormat;
import?java.util.ArrayList;
import?java.util.Collections;
import?java.util.Comparator;
import?java.util.Date;
import?java.util.List;public?class?ScoreManager?{private?List<ScoreEntry>?scores;public?ScoreManager()?{scores?=?new?ArrayList<>();}public?void?addScore(int?score)?{scores.add(new?ScoreEntry(score,?new?Date()));//?按分數降序排列Collections.sort(scores,?new?Comparator<ScoreEntry>()?{@Overridepublic?int?compare(ScoreEntry?s1,?ScoreEntry?s2)?{return?Integer.compare(s2.getScore(),?s1.getScore());}});}public?List<ScoreEntry>?getScores()?{return?scores;}public?static?class?ScoreEntry?{private?int?score;private?Date?date;public?ScoreEntry(int?score,?Date?date)?{this.score?=?score;this.date?=?date;}public?int?getScore()?{return?score;}public?String?getDate()?{SimpleDateFormat?sdf?=?new?SimpleDateFormat("yyyy-MM-dd?HH:mm:ss");return?sdf.format(date);}}
}
SnakeGame.java - 主類
import?javax.swing.*;
import?java.awt.*;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;public?class?SnakeGame?extends?JFrame?{private?GamePanel?gamePanel;private?JButton?startButton;private?JButton?pauseButton;private?JButton?scoreButton;private?JLabel?scoreLabel;private?ScoreManager?scoreManager;public?SnakeGame()?{setTitle("貪吃蛇游戲");setSize(600,?600);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setLocationRelativeTo(null);scoreManager?=?new?ScoreManager();gamePanel?=?new?GamePanel(scoreManager);startButton?=?new?JButton("開始");pauseButton?=?new?JButton("暫停");scoreButton?=?new?JButton("顯示得分");scoreLabel?=?new?JLabel("得分:?0");//?開始按鈕的功能:開始游戲startButton.addActionListener(new?ActionListener()?{public?void?actionPerformed(ActionEvent?e)?{gamePanel.startGame();gamePanel.requestFocusInWindow();?//?使游戲面板獲得鍵盤焦點}});//?暫停按鈕的功能:暫停游戲pauseButton.addActionListener(new?ActionListener()?{public?void?actionPerformed(ActionEvent?e)?{gamePanel.pauseGame();}});//?顯示得分按鈕的功能:顯示玩家得分列表scoreButton.addActionListener(new?ActionListener()?{public?void?actionPerformed(ActionEvent?e)?{showScoreList();}});//?控制面板包含開始、暫停按鈕和得分顯示JPanel?controlPanel?=?new?JPanel();controlPanel.add(startButton);controlPanel.add(pauseButton);controlPanel.add(scoreButton);controlPanel.add(scoreLabel);add(gamePanel,?BorderLayout.CENTER);add(controlPanel,?BorderLayout.SOUTH);//?注冊游戲面板的得分更新監聽器gamePanel.setScoreListener(new?GamePanel.ScoreListener()?{@Overridepublic?void?scoreUpdated(int?score)?{scoreLabel.setText("得分:?"?+?score);}});}//?顯示得分列表private?void?showScoreList()?{StringBuilder?scoresText?=?new?StringBuilder("玩家得分列表:\n");for?(ScoreManager.ScoreEntry?scoreEntry?:?scoreManager.getScores())?{scoresText.append("得分:?").append(scoreEntry.getScore()).append("?時間:?").append(scoreEntry.getDate()).append("\n");}JOptionPane.showMessageDialog(this,?scoresText.toString(),?"得分列表",?JOptionPane.INFORMATION_MESSAGE);}public?static?void?main(String[]?args)?{EventQueue.invokeLater(new?Runnable()?{public?void?run()?{SnakeGame?game?=?new?SnakeGame();game.setVisible(true);}});}
}
GamePanel.java - 游戲面板類
import?javax.swing.*;
import?java.awt.*;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.awt.event.KeyAdapter;
import?java.awt.event.KeyEvent;
import?java.util.Random;public?class?GamePanel?extends?JPanel?implements?ActionListener?{private?final?int?TILE_SIZE?=?20;?//?每個格子的大小private?final?int?WIDTH?=?600;????//?游戲面板的寬度private?final?int?HEIGHT?=?600;???//?游戲面板的高度private?final?int?ALL_TILES?=?(WIDTH?*?HEIGHT)?/?(TILE_SIZE?*?TILE_SIZE);?//?總格子數private?final?int[]?x?=?new?int[ALL_TILES];?//?貪吃蛇的x坐標private?final?int[]?y?=?new?int[ALL_TILES];?//?貪吃蛇的y坐標private?int?snakeLength;?//?貪吃蛇的長度private?int?foodX;???????//?食物的x坐標private?int?foodY;???????//?食物的y坐標private?int?score;???????//?玩家得分private?boolean?running?=?false;?//?游戲是否在進行中private?boolean?paused?=?false;??//?游戲是否暫停private?Timer?timer;?????//?定時器控制游戲速度private?char?direction?=?'R';?//?貪吃蛇的初始方向private?ScoreListener?scoreListener;private?ScoreManager?scoreManager;public?GamePanel(ScoreManager?scoreManager)?{this.scoreManager?=?scoreManager;setBackground(Color.BLACK);setFocusable(true);setPreferredSize(new?Dimension(WIDTH,?HEIGHT));addKeyListener(new?SnakeKeyAdapter());initGame();}public?void?setScoreListener(ScoreListener?listener)?{this.scoreListener?=?listener;}//?初始化游戲狀態private?void?initGame()?{snakeLength?=?3;for?(int?i?=?0;?i?<?snakeLength;?i++)?{x[i]?=?100?-?i?*?TILE_SIZE;y[i]?=?100;}placeFood();score?=?0;if?(scoreListener?!=?null)?{scoreListener.scoreUpdated(score);}timer?=?new?Timer(140,?this);}//?開始游戲public?void?startGame()?{if?(!running)?{running?=?true;paused?=?false;initGame();?//?重新初始化游戲狀態timer.start();}?else?if?(paused)?{paused?=?false;timer.start();}}//?暫停游戲public?void?pauseGame()?{if?(running)?{paused?=?true;timer.stop();}}//?繪制游戲內容@Overrideprotected?void?paintComponent(Graphics?g)?{super.paintComponent(g);if?(running)?{draw(g);}?else?{showGameOver(g);}}//?繪制貪吃蛇和食物private?void?draw(Graphics?g)?{g.setColor(Color.RED);g.fillRect(foodX,?foodY,?TILE_SIZE,?TILE_SIZE);for?(int?i?=?0;?i?<?snakeLength;?i++)?{if?(i?==?0)?{g.setColor(Color.GREEN);}?else?{g.setColor(Color.ORANGE);}g.fillRect(x[i],?y[i],?TILE_SIZE,?TILE_SIZE);}}//?顯示游戲結束信息private?void?showGameOver(Graphics?g)?{String?msg?=?"游戲結束。得分:?"?+?score;Font?font?=?new?Font("Helvetica",?Font.BOLD,?40);FontMetrics?metrics?=?getFontMetrics(font);g.setColor(Color.RED);g.setFont(font);g.drawString(msg,?(WIDTH?-?metrics.stringWidth(msg))?/?2,?HEIGHT?/?2);//?顯示繼續游戲的選項msg?=?"按空格鍵繼續游戲";font?=?new?Font("Helvetica",?Font.BOLD,?20);metrics?=?getFontMetrics(font);g.setFont(font);g.setColor(Color.WHITE);g.drawString(msg,?(WIDTH?-?metrics.stringWidth(msg))?/?2,?HEIGHT?/?2?+?40);//?保存當前得分到得分列表scoreManager.addScore(score);}//?檢查貪吃蛇是否吃到食物private?void?checkFoodCollision()?{if?((x[0]?==?foodX)?&&?(y[0]?==?foodY))?{snakeLength++;score++;if?(scoreListener?!=?null)?{scoreListener.scoreUpdated(score);}placeFood();}}//?移動貪吃蛇private?void?move()?{for?(int?i?=?snakeLength;?i?>?0;?i--)?{x[i]?=?x[(i?-?1)];y[i]?=?y[(i?-?1)];}switch?(direction)?{case?'U':y[0]?-=?TILE_SIZE;break;case?'D':y[0]?+=?TILE_SIZE;break;case?'L':x[0]?-=?TILE_SIZE;break;case?'R':x[0]?+=?TILE_SIZE;break;}}//?檢查貪吃蛇是否碰到自己或邊界private?void?checkCollision()?{for?(int?i?=?snakeLength;?i?>?0;?i--)?{if?((x[0]?==?x[i])?&&?(y[0]?==?y[i]))?{running?=?false;}}if?(x[0]?<?0?||?x[0]?>=?WIDTH?||?y[0]?<?0?||?y[0]?>=?HEIGHT)?{running?=?false;}if?(!running)?{timer.stop();}}//?隨機放置食物,并確保食物不與蛇重疊private?void?placeFood()?{boolean?valid;do?{valid?=?true;int?r?=?(int)?(Math.random()?*?(WIDTH?/?TILE_SIZE));foodX?=?((r?*?TILE_SIZE));r?=?(int)?(Math.random()?*?(HEIGHT?/?TILE_SIZE));foodY?=?((r?*?TILE_SIZE));for?(int?i?=?0;?i?<?snakeLength;?i++)?{if?(x[i]?==?foodX?&&?y[i]?==?foodY)?{valid?=?false;break;}}}?while?(!valid);}//?每次定時器觸發時調用@Overridepublic?void?actionPerformed(ActionEvent?e)?{if?(running?&&?!paused)?{checkFoodCollision();checkCollision();move();}repaint();}//?鍵盤事件處理,控制貪吃蛇的方向和重新開始游戲private?class?SnakeKeyAdapter?extends?KeyAdapter?{@Overridepublic?void?keyPressed(KeyEvent?e)?{int?key?=?e.getKeyCode();if?(key?==?KeyEvent.VK_SPACE?&&?!running)?{startGame();}if?((key?==?KeyEvent.VK_LEFT)?&&?(direction?!=?'R'))?{direction?=?'L';}if?((key?==?KeyEvent.VK_RIGHT)?&&?(direction?!=?'L'))?{direction?=?'R';}if?((key?==?KeyEvent.VK_UP)?&&?(direction?!=?'D'))?{direction?=?'U';}if?((key?==?KeyEvent.VK_DOWN)?&&?(direction?!=?'U'))?{direction?=?'D';}}}//?定義得分監聽器接口public?interface?ScoreListener?{void?scoreUpdated(int?score);}
}
三、感受
好用的功能太多太多,我就不在這個一一列舉了,有興趣的可以自行嘗試。
?