# オリジナルCOMの追加

### オリジナルCOMを考える

最後にオリジナルCOMを考えて今まで作ってきたRandomComPlayerやOrderlyComPlayerに勝利してみましょう。

COMの挙動は色々考えられますね。

* 真ん中を優先的に打ちにいく
* リーチがかかっていたら揃えにいく
* 可能性がないマスに置きに行かない

どのようなCOMが強そうでしょうか。

{% hint style="info" %}
**課題コーナー**

RandomComPlayerとOrderlyComPlayerに２連勝できるオリジナルCOMを考える

必要があれば他クラスを拡張しても良い
{% endhint %}

### 絶対に負けないCOM

少し実装が難しくなってしまいますがminimaxというゲーム木を使ったアルゴリズムを適用すれば

負けることは無くなります。

チャレンジしてみたい人は是非やってみてください！

参考にminimaxアルゴリズムを適用させたコードを以下に記載しておきます。

{% embed url="<https://github.com/Kashiwara0205/ruby-tic-tac-toe/tree/master/ch-minimax/code>" %}

以上でRubyで実装するフルスクラッチ三目並べは完了です。

お疲れ様でした！


---

# 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://kashiwara.gitbook.io/rubydesurufurusukuratchibe/zui-zhong-zhang-ji-neng-zhui-jia/orijinarucomno.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.
