概要
wsl(wsl2じゃない)で、elixirやってみた。
四目並べの学習済みmodelを見つけたので、LIVEBOOKで対戦してみた。
参考にしたページ
環境
windows11
wsl1
ubuntu22.04
elixir1.16.1-opt-26
setup
Mix.install(
[
{:axon, "~> 0.2.0"},
{:exla, "~> 0.3.0"},
{:nx, "~> 0.3.0"},
{:kino, "~> 0.10.0"}
],
config: [
nx: [default_backend: EXLA.Backend]
]
)
自分のターン
gomoku =
gomoku
|> Gomoku.put!({2, 1})
|> tap(fn x ->
Gomoku.render(x)
|> IO.puts()
end)
AIのターン
pos = Dqn.get_action(gomoku, q_net)
IO.inspect(pos, label: "next action")
gomoku =
gomoku
|> Gomoku.put!(pos)
|> tap(fn x ->
Gomoku.render(x)
|> IO.puts()
end)
実行結果
01234
0: -----
1: -00--
2: --*--
3: -----
4: -----
next action: {1, 3}
01234
0: -----
1: -00*-
2: --*--
3: -----
4: -----
01234
0: -----
1: -00*-
2: -0*--
3: -----
4: -----
next action: {3, 1}
01234
0: -----
1: -00*-
2: -0*--
3: -*---
4: -----
以上。