# 猜拳游戲

使用機器學習，我們可以訓練電腦與我們玩游戲。本案例使用了KNN模型演算法，訓練機械人與我們玩猜拳的遊戲。

![](https://kittenbothk.readthedocs.io/en/latest/_images/ex9.png)

### 搭建說明書與參考程式資源包:

[資源包下載](http://bit.ly/AIOTKit_SH_ResourcsePack)

### 參考接線:

![](https://kittenbothk.readthedocs.io/en/latest/_images/game_wire.png)

### 加入插件:

視訊偵測:

![](https://kittenbothk.readthedocs.io/en/latest/_images/video1.png)

Machine Learning:

![](https://kittenbothk.readthedocs.io/en/latest/_images/ml.png)

### 參考訓練程式:

![](https://kittenbothk.readthedocs.io/en/latest/_images/game_train_code_1.87.png)

### 參考程式:

![](https://kittenbothk.readthedocs.io/en/latest/_images/game_code_1.87.png)

### 程式流程

1. 使用訓練程式，訓練辨認剪刀、石頭、布的模型。
2. 使用主程式，載入訓練好的模型。
3. 將Micro:bit連接到Kittenblock。**不需要將程式上載到Micro:bit。**
4. 按下空白鍵開始與機械人猜拳。
5. 機械人會必勝地作出動作。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sharinghub.kittenbot.hk/kits/aiot/info/game.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
