2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[PowerApps]オセロゲームでAIBuilderを使ってみた(碁石をひっくり返す)

Posted at

背景

PowerAppsのキャンバスアプリでオセロゲームの碁石がひっくり返すロジックを開発してみたところ、コード量が多かったため、AIさんなんとかやってくれないかと考えました。

ゴール

PowerAppsで連携しやすいAIBuilderを活用して、作成したプロンプトに打つ前の盤面の状態、打った碁石の盤面を渡し、碁石を打った後の盤面を応答してもらおうと考えております。

プロンプトを作成する画面

PowerAppsにログインし、以下メニューボタンを押下します。
image.png

プロンプト設定

image.png

作成したプロンプト

プロンプト
# 前提条件
あなたは、オセロ(リバーシとも呼ばれる)のプロゲーマーです。
# ゴールの定義
打つ前の盤面、打った盤面から打った後の盤面を応答してください。
# 盤面のデータ定義
縦8行、横8列の盤面とする。
rowは1を始まりとする縦行数です。
colは1を始まりとする横列数です。
statusは0が空の碁石、1が黒の碁石、2が白の碁石です。
# 盤面のデータ例
縦1行、横1列目の空の碁石
{"row":1,"col":1,"status":0}
縦2行、横1列目の黒の碁石
{"row":2,"col":1,"status":1}
縦2行、横2列目の白の碁石
{"row":2,"col":2,"status":2}
# 打つ前の盤面の定義
$beforeBoard$
# 打った盤面の定義
$placeBoard$
# 応答の定義
打った後の盤面の配列を返してください。

入力設定

beforeBoard

サンプルデータ
[
    {"row":1,"col":1,"status":0},
    {"row":1,"col":2,"status":0},
    {"row":1,"col":3,"status":0},
    {"row":1,"col":4,"status":0},
    {"row":1,"col":5,"status":0},
    {"row":1,"col":6,"status":0},
    {"row":1,"col":7,"status":0},
    {"row":1,"col":8,"status":0},
    {"row":2,"col":1,"status":0},
    {"row":2,"col":2,"status":0},
    {"row":2,"col":3,"status":0},
    {"row":2,"col":4,"status":0},
    {"row":2,"col":5,"status":0},
    {"row":2,"col":6,"status":0},
    {"row":2,"col":7,"status":0},
    {"row":2,"col":8,"status":0},
    {"row":3,"col":1,"status":0},
    {"row":3,"col":2,"status":0},
    {"row":3,"col":3,"status":0},
    {"row":3,"col":4,"status":0},
    {"row":3,"col":5,"status":0},
    {"row":3,"col":6,"status":0},
    {"row":3,"col":7,"status":0},
    {"row":3,"col":8,"status":0},
    {"row":4,"col":1,"status":0},
    {"row":4,"col":2,"status":0},
    {"row":4,"col":3,"status":0},
    {"row":4,"col":4,"status":2},
    {"row":4,"col":5,"status":1},
    {"row":4,"col":6,"status":0},
    {"row":4,"col":7,"status":0},
    {"row":4,"col":8,"status":0},
    {"row":5,"col":1,"status":0},
    {"row":5,"col":2,"status":0},
    {"row":5,"col":3,"status":0},
    {"row":5,"col":4,"status":1},
    {"row":5,"col":5,"status":2},
    {"row":5,"col":6,"status":0},
    {"row":5,"col":7,"status":0},
    {"row":5,"col":8,"status":0},
    {"row":6,"col":1,"status":0},
    {"row":6,"col":2,"status":0},
    {"row":6,"col":3,"status":0},
    {"row":6,"col":4,"status":0},
    {"row":6,"col":5,"status":0},
    {"row":6,"col":6,"status":0},
    {"row":6,"col":7,"status":0},
    {"row":6,"col":8,"status":0},
    {"row":7,"col":1,"status":0},
    {"row":7,"col":2,"status":0},
    {"row":7,"col":3,"status":0},
    {"row":7,"col":4,"status":0},
    {"row":7,"col":5,"status":0},
    {"row":7,"col":6,"status":0},
    {"row":7,"col":7,"status":0},
    {"row":7,"col":8,"status":0},
    {"row":8,"col":1,"status":0},
    {"row":8,"col":2,"status":0},
    {"row":8,"col":3,"status":0},
    {"row":8,"col":4,"status":0},
    {"row":8,"col":5,"status":0},
    {"row":8,"col":6,"status":0},
    {"row":8,"col":7,"status":0},
    {"row":8,"col":8,"status":0}
]

placeBoard

サンプルデータ
{"row":3,"col":4,"status":1}

image.png

出力設定

サンプルデータ
[
  {
    "row": 1,
    "col": 1,
    "status": 0
  },
  {
    "row": 1,
    "col": 2,
    "status": 0
  },
  {
    "row": 1,
    "col": 3,
    "status": 0
  },
  {
    "row": 1,
    "col": 4,
    "status": 0
  },
  {
    "row": 1,
    "col": 5,
    "status": 0
  },
  {
    "row": 1,
    "col": 6,
    "status": 0
  },
  {
    "row": 1,
    "col": 7,
    "status": 0
  },
  {
    "row": 1,
    "col": 8,
    "status": 0
  },
  {
    "row": 2,
    "col": 1,
    "status": 0
  },
  {
    "row": 2,
    "col": 2,
    "status": 0
  },
  {
    "row": 2,
    "col": 3,
    "status": 0
  },
  {
    "row": 2,
    "col": 4,
    "status": 0
  },
  {
    "row": 2,
    "col": 5,
    "status": 0
  },
  {
    "row": 2,
    "col": 6,
    "status": 0
  },
  {
    "row": 2,
    "col": 7,
    "status": 0
  },
  {
    "row": 2,
    "col": 8,
    "status": 0
  },
  {
    "row": 3,
    "col": 1,
    "status": 0
  },
  {
    "row": 3,
    "col": 2,
    "status": 0
  },
  {
    "row": 3,
    "col": 3,
    "status": 0
  },
  {
    "row": 3,
    "col": 4,
    "status": 1
  },
  {
    "row": 3,
    "col": 5,
    "status": 0
  },
  {
    "row": 3,
    "col": 6,
    "status": 0
  },
  {
    "row": 3,
    "col": 7,
    "status": 0
  },
  {
    "row": 3,
    "col": 8,
    "status": 0
  },
  {
    "row": 4,
    "col": 1,
    "status": 0
  },
  {
    "row": 4,
    "col": 2,
    "status": 0
  },
  {
    "row": 4,
    "col": 3,
    "status": 0
  },
  {
    "row": 4,
    "col": 4,
    "status": 1
  },
  {
    "row": 4,
    "col": 5,
    "status": 1
  },
  {
    "row": 4,
    "col": 6,
    "status": 0
  },
  {
    "row": 4,
    "col": 7,
    "status": 0
  },
  {
    "row": 4,
    "col": 8,
    "status": 0
  },
  {
    "row": 5,
    "col": 1,
    "status": 0
  },
  {
    "row": 5,
    "col": 2,
    "status": 0
  },
  {
    "row": 5,
    "col": 3,
    "status": 0
  },
  {
    "row": 5,
    "col": 4,
    "status": 1
  },
  {
    "row": 5,
    "col": 5,
    "status": 2
  },
  {
    "row": 5,
    "col": 6,
    "status": 0
  },
  {
    "row": 5,
    "col": 7,
    "status": 0
  },
  {
    "row": 5,
    "col": 8,
    "status": 0
  },
  {
    "row": 6,
    "col": 1,
    "status": 0
  },
  {
    "row": 6,
    "col": 2,
    "status": 0
  },
  {
    "row": 6,
    "col": 3,
    "status": 0
  },
  {
    "row": 6,
    "col": 4,
    "status": 0
  },
  {
    "row": 6,
    "col": 5,
    "status": 0
  },
  {
    "row": 6,
    "col": 6,
    "status": 0
  },
  {
    "row": 6,
    "col": 7,
    "status": 0
  },
  {
    "row": 6,
    "col": 8,
    "status": 0
  },
  {
    "row": 7,
    "col": 1,
    "status": 0
  },
  {
    "row": 7,
    "col": 2,
    "status": 0
  },
  {
    "row": 7,
    "col": 3,
    "status": 0
  },
  {
    "row": 7,
    "col": 4,
    "status": 0
  },
  {
    "row": 7,
    "col": 5,
    "status": 0
  },
  {
    "row": 7,
    "col": 6,
    "status": 0
  },
  {
    "row": 7,
    "col": 7,
    "status": 0
  },
  {
    "row": 7,
    "col": 8,
    "status": 0
  },
  {
    "row": 8,
    "col": 1,
    "status": 0
  },
  {
    "row": 8,
    "col": 2,
    "status": 0
  },
  {
    "row": 8,
    "col": 3,
    "status": 0
  },
  {
    "row": 8,
    "col": 4,
    "status": 0
  },
  {
    "row": 8,
    "col": 5,
    "status": 0
  },
  {
    "row": 8,
    "col": 6,
    "status": 0
  },
  {
    "row": 8,
    "col": 7,
    "status": 0
  },
  {
    "row": 8,
    "col": 8,
    "status": 0
  }
]

image.png

プロンプトの応答

1手目の碁石をひっくり返すところは、正常な応答を返してくれました。

応答
[
  {
    "row": 1,
    "col": 1,
    "status": 0
  },
  {
    "row": 1,
    "col": 2,
    "status": 0
  },
  {
    "row": 1,
    "col": 3,
    "status": 0
  },
  {
    "row": 1,
    "col": 4,
    "status": 0
  },
  {
    "row": 1,
    "col": 5,
    "status": 0
  },
  {
    "row": 1,
    "col": 6,
    "status": 0
  },
  {
    "row": 1,
    "col": 7,
    "status": 0
  },
  {
    "row": 1,
    "col": 8,
    "status": 0
  },
  {
    "row": 2,
    "col": 1,
    "status": 0
  },
  {
    "row": 2,
    "col": 2,
    "status": 0
  },
  {
    "row": 2,
    "col": 3,
    "status": 0
  },
  {
    "row": 2,
    "col": 4,
    "status": 0
  },
  {
    "row": 2,
    "col": 5,
    "status": 0
  },
  {
    "row": 2,
    "col": 6,
    "status": 0
  },
  {
    "row": 2,
    "col": 7,
    "status": 0
  },
  {
    "row": 2,
    "col": 8,
    "status": 0
  },
  {
    "row": 3,
    "col": 1,
    "status": 0
  },
  {
    "row": 3,
    "col": 2,
    "status": 0
  },
  {
    "row": 3,
    "col": 3,
    "status": 0
  },
  {
    "row": 3,
    "col": 4,
    "status": 1
  },
  {
    "row": 3,
    "col": 5,
    "status": 0
  },
  {
    "row": 3,
    "col": 6,
    "status": 0
  },
  {
    "row": 3,
    "col": 7,
    "status": 0
  },
  {
    "row": 3,
    "col": 8,
    "status": 0
  },
  {
    "row": 4,
    "col": 1,
    "status": 0
  },
  {
    "row": 4,
    "col": 2,
    "status": 0
  },
  {
    "row": 4,
    "col": 3,
    "status": 0
  },
  {
    "row": 4,
    "col": 4,
    "status": 1
  },
  {
    "row": 4,
    "col": 5,
    "status": 1
  },
  {
    "row": 4,
    "col": 6,
    "status": 0
  },
  {
    "row": 4,
    "col": 7,
    "status": 0
  },
  {
    "row": 4,
    "col": 8,
    "status": 0
  },
  {
    "row": 5,
    "col": 1,
    "status": 0
  },
  {
    "row": 5,
    "col": 2,
    "status": 0
  },
  {
    "row": 5,
    "col": 3,
    "status": 0
  },
  {
    "row": 5,
    "col": 4,
    "status": 1
  },
  {
    "row": 5,
    "col": 5,
    "status": 2
  },
  {
    "row": 5,
    "col": 6,
    "status": 0
  },
  {
    "row": 5,
    "col": 7,
    "status": 0
  },
  {
    "row": 5,
    "col": 8,
    "status": 0
  },
  {
    "row": 6,
    "col": 1,
    "status": 0
  },
  {
    "row": 6,
    "col": 2,
    "status": 0
  },
  {
    "row": 6,
    "col": 3,
    "status": 0
  },
  {
    "row": 6,
    "col": 4,
    "status": 0
  },
  {
    "row": 6,
    "col": 5,
    "status": 0
  },
  {
    "row": 6,
    "col": 6,
    "status": 0
  },
  {
    "row": 6,
    "col": 7,
    "status": 0
  },
  {
    "row": 6,
    "col": 8,
    "status": 0
  },
  {
    "row": 7,
    "col": 1,
    "status": 0
  },
  {
    "row": 7,
    "col": 2,
    "status": 0
  },
  {
    "row": 7,
    "col": 3,
    "status": 0
  },
  {
    "row": 7,
    "col": 4,
    "status": 0
  },
  {
    "row": 7,
    "col": 5,
    "status": 0
  },
  {
    "row": 7,
    "col": 6,
    "status": 0
  },
  {
    "row": 7,
    "col": 7,
    "status": 0
  },
  {
    "row": 7,
    "col": 8,
    "status": 0
  },
  {
    "row": 8,
    "col": 1,
    "status": 0
  },
  {
    "row": 8,
    "col": 2,
    "status": 0
  },
  {
    "row": 8,
    "col": 3,
    "status": 0
  },
  {
    "row": 8,
    "col": 4,
    "status": 0
  },
  {
    "row": 8,
    "col": 5,
    "status": 0
  },
  {
    "row": 8,
    "col": 6,
    "status": 0
  },
  {
    "row": 8,
    "col": 7,
    "status": 0
  },
  {
    "row": 8,
    "col": 8,
    "status": 0
  }
]

まとめ

1手目は正常な応答が返してくれましたが、2手目の応答の盤面データが正しくありませんでした。
これはプロンプトの定型文の問題なのか。または、AIモデルの精度の問題なのか。それともプロンプトの設定の問題なのか切り分けが難しいと感じました。
いろいろ試行錯誤してみようと考えております。
この記事が皆さんの役に立てば幸いです!
また、解決策があるという方おられましたら、コメントいただけると幸いです。
記事をご覧いただきありがとうございます。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?