Training an AI to Conquer Double Dragon: Reinforcement Learning Demo

OpenShift
31 May 202421:31

Summary

TLDRこのビデオでは、強化学習(RL)を使用して1988年のアーケードゲーム「ダブルドラゴン」を攻略するAIのトレーニング過程が紹介されています。Red Hat Open Shift内でモデルをトレーニングし、100以上のゲームインスタンスを実行して最適化を行っています。PythonのBaseline三などのライブラリを使用してAIをトレーニングし、ゲームボーイエミュレータPi boyをヘッドレスモードで実行しています。トレーニング中には報酬システムを調整し、最適な行動を見つけるために報酬とペナルティを適用します。トレーニング結果をTensorBoardで可視化し、モデルのパフォーマンスを評価しています。この技術は自動運転車やロボティクスなど、実用的な応用にも応じています。

Takeaways

  • 🤖 このビデオでは、1988年のアーケードゲーム「ダブルドラゴン」をRed Hat Open Shift内でトレーニングしたモデルを使ってAIがゲームをクリアする方法が紹介されています。
  • 🎮 AIは強化学習(RL)という機械学習の手法を使ってゲームを学習し、さまざまなランダムなアクションを試して最適化しています。
  • 📚 トレーニングにはBaselineという機械学習ライブラリとPPOというトレーニングアルゴリズムが使用されています。
  • 🕹️ Game Boyエミュレータ「Pi boy」を使って複数のインスタンスを同時に実行し、ゲームをクリアするようにトレーニングしています。
  • 🔍 アクションの頻度やフレーム数などのパラメータを調整することで、ゲームのアクションを最適化しています。
  • 🔄 モデルはチェックポイントを使ってトレーニングの進捗を確認し、必要に応じてロールバックも可能です。
  • 🛠️ トレーニング中にモデルのパラメータを調整して、より良い結果を得ることができます。
  • 📈 結果をTensorBoardを使って可視化することで、トレーニングの効果を評価しています。
  • 🎨 AIはゲーム内のNPCに最適な攻撃パターンを見つけ出し、レベルを進める方法を学びます。
  • 🔧 モデルは報酬システムを通じて学習し、ゲーム内のスコア、位置、新しいフレームへの進展などを報酬として得ています。
  • 🚀 トレーニングを通じてAIは最適な攻撃方法を発見し、ゲームの最初のレベルをクリアするのに成功しました。

Q & A

  • ビデオではどのようなAIが紹介されていますか?

    -ビデオでは、1988年のアーケードゲーム「ダブルドラゴン」をプレイし、Red Hat Open Shift内でトレーニングされたモデルを使用してゲームをクリアするAIが紹介されています。

  • ビデオで紹介されたAIはどのようにゲームをクリアするのですか?

    -ビデオで紹介されたAIは強化学習(Reinforcement Learning, RL)という機械学習の手法を使用して、繰り返しのタスクを通してパターンと最適化を見つけ、ゲームをクリアする方法を学んでいきます。

  • ビデオの中で使用された強化学習のアルゴリズムは何ですか?

    -ビデオの中で使用された強化学習のアルゴリズムはPPO(Proximal Policy Optimization)です。

  • ビデオ内でAIがトレーニングに使用したライブラリは何ですか?

    -ビデオ内でAIがトレーニングに使用したライブラリはBaselinesとgymnasiumです。Baselinesは機械学習ライブラリで、AIをトレーニングするために使用されています。

  • ビデオ内でAIが使用したエミュレータは何ですか?

    -ビデオ内でAIが使用したエミュレータはGame BoyエミュレータのPi boyです。これはゲームをプレイするための環境を提供します。

  • ビデオでAIがトレーニングに使用したCPUの数とその理由は何ですか?

    -ビデオでAIがトレーニングに使用したCPUの数は10です。各CPUに対してGame Boyエミュレータのインスタンスが実行され、スケーラビリティを確保するために使用されています。

  • ビデオ内でAIがトレーニングに使用する際に重要なパラメーターの一つとして説明されたものは何ですか?

    -ビデオ内でAIがトレーニングに使用する際に重要なパラメーターの一つとして説明されたものはgammaです。これはモデルが多様性を持たせるか、または特定の行動に固着するのを防ぐためのパラメーターです。

  • ビデオ内でAIがゲームをクリアするのに役立った重要な報酬の1つは何でしたか?

    -ビデオ内でAIがゲームをクリアするのに役立った重要な報酬の1つは位置(POSITION)でした。新しいフレームごとに報酬が与えられることで、モデルはゲームを探索するように励まされます。

  • ビデオ内でAIがゲームから除外したアクションは何で、なぜ除外しましたか?

    -ビデオ内でAIがゲームから除外したアクションはキック(ボタンB)でした。このバージョンのダブルドラゴンではキックが最適な解決策ではないと判断し、除外することでプレイスルーを30%以上向上させました。

  • ビデオ内でAIがトレーニングに使用したTensorBoardとは何ですか?

    -ビデオ内でAIがトレーニングに使用したTensorBoardは、機械学習モデルのメトリックを可視化するためのツールです。トレーニング中のさまざまな指標をグラフィカルに表示して分析することができます。

  • ビデオ内でAIがトレーニングに使用したDockerファイルとは何ですか?

    -ビデオ内でAIがトレーニングに使用したDockerファイルは、Open Shift AI Jupiterデータサイエンスイメージを拡張し、ゲームを実行するための必要なパッケージを追加するスクリプトです。

  • ビデオ内でAIがゲームをクリアするのに使用した最適な戦術とは何ですか?

    -ビデオ内でAIがゲームをクリアするのに使用した最適な戦術は、背面からのパンチ(エルボーパンチ)を使用してレベルを進めることに気づいたことです。これは速度ランナーがレベルを迅速にクリアするために行うのと同じ戦術です。

  • ビデオ内で紹介された強化学習の応用分野には何がありますか?

    -ビデオ内で紹介された強化学習の応用分野には、無人運転車やロボティクスなどがあります。この分野の機械学習は、汎用的なAIや大きな言語モデルにも関連しています。

  • ビデオ内でポケモンRLコミュニティから感謝された人物とその貢献とは何ですか?

    -ビデオ内でポケモンRLコミュニティから感謝された人物はPeterで、彼はポケモンRedをクリアするためのPPOアルゴリズムを使用したモデルのトレーニング例をGitHubページで共有しています。

Outlines

00:00

🎮 AIがアーケードゲーム「ダブルドラゴン」を攻略

このビデオでは、Red Hat OpenShift内でトレーニングされたAIが1988年の人気アーケードゲーム「ダブルドラゴン」をクリアする様子が紹介されています。AIは100以上の「ダブルドラゴン」インスタンスをOpenShift内でプレイし、様々なランダムなアクションを試行錯誤し、ゲームをクリアするための最適な戦略を学びます。強化学習(RL)という機械学習の手法を使ってモデルをトレーニングし、繰り返しのタスクを通してパターンと最適化を見つけ出します。ビデオでは、トレーニングに用いたパラメータや設定、使用したPythonのパッケージ(Baseline、PPOアルゴリズム、gymnasiumライブラリなど)について説明し、Game BoyエミュレータPi boyをヘッドレスモードで実行し、メモリを抑えながらモデルをトレーニングする方法も紹介されています。

05:02

🔁 強化学習によるAIトレーニングの詳細

ビデオでは強化学習を用いたAIモデルのトレーニングプロセスが詳しく説明されています。モデルはゲーム内の報酬に基づいて学習し、期待通りの動作を報酬として与えることで最適化されます。トレーニングセッションを開始する際には、チェックポイントから再開するか、新しいセッションを開始するかを選択できます。トレーニング中に使用されるパラメータ(gammaなど)と、CPUでの実行についても触れられています。また、トレーニング過程でのエピソードの長さやゲーム内の死亡回数などのメトリックスをTensorBoardでログに記録し、トレーニングの進捗を監視する方法も紹介されています。

10:04

🤖 AIのゲームプレイと報酬システムの調整

AIがゲームをプレイする様子と、報酬システムを調整することでAIの学習を促進する方法が紹介されています。ビデオではAIがゲーム内のNPCに攻撃を仕掛ける際の最適なパターンを見つけ出す様子が見られます。また、AIがボス戦で苦戦する際には報酬システムを変更し、より多くのプレイスルーや特定の攻撃動作を最適化する必要があると説明されています。AIがゲームの各フレームをどのように認識しているかを示す画像も紹介され、モデルが過去の動作を考慮に入れるために3つのフレームを用いる理由も説明されています。

15:05

🏆 AIがゲームをクリアするための戦略の見直し

ビデオではAIがゲームをクリアするための戦略を調整し、最適化するプロセスが詳しく説明されています。AIは報酬を獲得する5つの重要な領域(スコア、位置、新しいレベルへの進出、ボス戦後の報酬、ライフの損失に対するペナルティ)に基づいて学習します。また、AIがゲーム内の行動をランダムに試行錯誤し、パターンを形成する様子や、最適な戦略を見つけ出すプロセスも紹介されています。トレーニング結果を評価し、報酬システムの調整や不要な行動の削除など、より効率的な戦略を見つける方法も説明されています。

20:07

🚀 強化学習の応用とコミュニティへの感謝の言葉

ビデオの最後に、強化学習がどのようにして実践的な応用に使われるかが紹介され、例えば自動運転車やロボティクスなどがあります。また、ビデオではポケモンRLコミュニティのピーターに感謝の言葉を述べており、彼のGitHubページにはポケモン赤をクリアするためのPPOアルゴリズムのトレーニング例が公開されています。ビデオではまた、ポケモンだけでなくスーパーマリオブラザーズなど他のゲームに関する議論も行われているDiscordコミュニティにも言及されています。

Mindmap

Keywords

💡強化学習(Reinforcement Learning, RL)

強化学習は、機械学習の一分野で、アルゴリズムが繰り返しのタスクを通してパターンを見つけ、トレーニングを通じて最適化を行なう方法です。このビデオでは、強化学習を使用してAIが1988年のアーケードゲーム「ダブルドラゴン」をクリアするようにトレーニングされています。ビデオでは、モデルが期待通りの動作を行った場合に報酬を与えることで学習を促進するプロセスに焦点が当てられています。

💡オープンシフト(Open Shift)

オープンシフトは、Red Hat社が提供するコンテナー化されたアプリケーションを管理するためのプラットフォームです。ビデオでは、オープンシフト内でAIがトレーニングされ、ゲームをプレイする100以上のインスタンスが生成される様子が紹介されています。オープンシフトを使用することで、大規模なトレーニングプロセスを効率的に管理することができると示されています。

💡モデル(Model)

モデルとは、機械学習においてはデータから学習し、特定のタスクを遂行するアルゴリズムのことです。このビデオでは、強化学習を用いてトレーニングされたモデルがゲームをクリアするプロセスを示しています。モデルは様々なランダムなアクションを試行錯誤し、最適な戦略を見つけ出します。

💡報酬(Reward)

報酬は強化学習において、モデルが特定の行動を起こしたときに与えられるフィードバックであり、学習プロセスを促進する役割を果たします。ビデオでは、モデルがゲーム内のNPCに打撃を与えたり、新しいフレームを探索したりした際に報酬が与えられる様子が説明されています。

💡ゲームボーイエミュレータ(Game Boy Emulator)

ゲームボーイエミュレータは、ゲームボーイのゲームを他のプラットフォームでプレイできるようにするソフトウェアです。ビデオでは、Pi boyというエミュレータを使用して「ダブルドラゴン」ゲームをプレイし、AIモデルのトレーニングを行っています。

💡アクション周波数(Action Frequency)

アクション周波数は、ゲームエミュレータがアクションを実行するたびに必要なフレーム数を指定する設定です。ビデオでは、8フレームがアクションの長さと実行頻度のバランスの良いポイントとされていると説明されています。

💡最大ステップ(Max Steps)

最大ステップは、エミュレータがゲーム内で実行するアクションの最大数を制限する設定です。ビデオでは、無限ループを防ぐためにこの設定が重要であると強調されています。

💡チェックポイント(Checkpoint)

チェックポイントは、モデルのトレーニングプロセスで特定のポイントから復元できるように記録される状態です。ビデオでは、チェックポイントを使用してトレーニングの進捗を確認し、必要に応じて変更をロールバックすることができると説明されています。

💡ハイパーパラメータ(Hyperparameter)

ハイパーパラメータは、モデルのトレーニング前に設定され、モデルの性能に影響を与えるパラメータです。ビデオでは、γ(ガンマ)というハイパーパラメータを使用してモデルが学習の多様性を見つける方法を制御していると紹介されています。

💡ニューラルネットワーク(Neural Network)

ニューラルネットワークは、人間の神経系をモデル化したアルゴリズムであり、機械学習における学習モデルの基礎となるものです。ビデオでは、ニューラルネットワークを使用してゲームの各フレームを解析し、AIがゲームをクリアする戦略を学習するプロセスが説明されています。

Highlights

AI击败1988年流行的街机游戏双截龙(Double Dragon),模型在Red Hat OpenShift中训练。

使用强化学习(Reinforcement Learning, RL)来训练AI,通过重复任务学习不同模式和优化。

展示AI如何在OpenShift中同时运行超过100个双截龙游戏实例。

使用Baseline三库和PPO训练算法来训练AI模型。

介绍Game Boy模拟器Pi boy的配置和优化设置。

设置CPU数量以并行运行多个模拟器实例。

使用回调设置检查点,以验证训练结果。

讨论gamma参数对模型训练多样性的影响。

CPU用于模型训练,GPU在此模型中提升有限。

使用TensorBoard记录和可视化训练指标。

AI在训练过程中的优化,例如通过删除不优动作提高效率。

AI学习过程中的奖励系统,包括得分、位置、新关卡和生命惩罚。

AI如何通过减少分辨率和改变像素结构来优化游戏帧的识别。

AI通过训练学会了如何有效地使用梯子和跳跃。

AI最终学会了如何击败第一个boss并进入下一关。

强化学习在自动驾驶汽车和机器人等领域的实际应用。

感谢Pokemon RL社区的Peter,提供GitHub页面和相关资源。

Transcripts

play00:00

welcome in this video we'll be showing

play00:03

an AI beating the popular

play00:05

1988 arcade game double dragon with a

play00:09

model trained within Red Hat open shift

play00:13

[Music]

play00:17

AI here we have over a 100 instances of

play00:21

Double Dragon being played within open

play00:25

shift

play00:26

AI it's running through a variety of

play00:29

different random

play00:30

actions and then optimizing on those

play00:32

actions to learn to beat the game Let's

play00:36

dive into to how we made this possible

play00:39

we're going to use a form of machine

play00:41

learning called reinforcement learning

play00:44

or

play00:45

RL this is a form of machine learning

play00:48

where we take repetitive tasks over and

play00:52

over again and find different patterns

play00:55

and

play00:56

optimizations through training the model

play00:59

this could be through different random

play01:02

events or in our case we'll have

play01:04

different rewards where we tell the

play01:07

model when it's performing the way that

play01:09

we are expecting and ways that we don't

play01:12

want it to function let me show you some

play01:14

examples of

play01:16

this let's start within our notebook and

play01:21

show a few ways that this AI model was

play01:24

trained and some of the different

play01:26

parameters and configurations that went

play01:29

into the training

play01:33

here we have a variety of different

play01:35

packages that are being pulled into

play01:37

python to train this model most

play01:41

importantly is the Baseline

play01:43

three this is the machine learning

play01:46

library that we're using to train the AI

play01:49

to ultimately beat the Double Dragon

play01:52

game through this we're bringing in a

play01:55

popular training algorithm called po

play02:00

we also use the popular gymnasium

play02:02

Library which I'll show you more here in

play02:05

another

play02:06

script now let's show the initiation of

play02:10

the Game Boy environments that will play

play02:12

concurrently and attempt to beat the

play02:15

game we have a few helper functions here

play02:18

but the primary function we're most

play02:20

interested in is this make

play02:23

environment this will create a variety

play02:26

of different instances of the Game Boy

play02:28

emulator Pi boy

play02:30

we'll also configure in this case in

play02:32

what we call a headless instance this

play02:35

way I don't need to hear the sound or

play02:37

the visuals this keeps the memory down

play02:39

allows us to have more instances to

play02:42

training the

play02:43

model we have a variety of different

play02:46

configurations here that we pass in to

play02:49

the Game Boy

play02:53

emulator the action frequency here lets

play02:56

the Game Boy emulator know how many

play02:58

frames should it have before each action

play03:01

is taken this is critical as sometimes

play03:05

you want actions to be a little bit

play03:07

longer and if certain actions are done

play03:10

too quickly it may not even be

play03:11

registered by the game in this case I

play03:15

found that the eight frames is The Sweet

play03:17

Spot between the length of the actions

play03:21

and how frequently we want actions to be

play03:25

taken to speed up the process I have

play03:29

loaded in a save file that ignores the

play03:32

first cut scene this allows the emulator

play03:35

to jump right in to where the action

play03:37

starts and helps speed up the

play03:42

process we also have here Max steps this

play03:46

correlates to the amount of actions that

play03:48

are

play03:49

taken at the point of the maximum steps

play03:52

the emulator will stop running to

play03:54

prevent an infinite loop from

play03:57

happening I have a variety of other

play04:00

configurations but those are probably

play04:02

the most important to go

play04:07

over we now set the amount of CPUs that

play04:11

will be used for this particular run in

play04:14

this case have it set to

play04:17

10 for every CPU that's set we'll have

play04:20

an instance of the Game Boy emulator

play04:22

running on that particular

play04:26

CPU in this example I just have one

play04:29

workbench that'll be running this in a

play04:31

vertical fashion for scaling but there

play04:34

are ways that we could configure this

play04:36

with tools like Cube Ray or code flare

play04:40

where we could distribute this across

play04:42

many different nodes within open shift

play04:47

AI here we'll go ahead and loop through

play04:49

and create the necessary environments we

play04:51

need and then we'll set up a call

play04:55

back this is a way that we can set

play04:58

checkpoints where we can verify if the

play05:02

results are what we're expecting this is

play05:05

a good way to keep certain records of

play05:08

instances through their training there

play05:10

may be a point that you make a change

play05:12

that you don't like you then need to be

play05:15

able to roll back to a particular

play05:17

checkpoint this is a good way of showing

play05:20

how that's possible within open shift

play05:23

AI let's go ahead and start these

play05:26

instances we'll come up here and play

play05:29

this cell

play05:41

all right our 10 instances are now ready

play05:45

and let's go ahead and start the model

play05:52

training I have two options here I can

play05:55

start from a checkpoint if I provide a

play05:59

file name or we can start a fresh

play06:01

training session here for this video

play06:04

I'll be showing a fresh training

play06:08

run you'll see here that I don't have

play06:11

very many parameters when starting a

play06:14

fresh training session I typically like

play06:17

to take my checkpoints after a few

play06:19

iterations of training and then try to

play06:22

apply different hyperparameters to my

play06:25

model let's talk about a couple of

play06:28

these here I have the gamma gamma is a

play06:33

way to let the model training know how

play06:35

much variety I want to take let's say

play06:39

that the model has found a way to go

play06:41

through uh a particular door within the

play06:45

game but let's say maybe that was the

play06:47

incorrect door maybe ultimately we

play06:50

needed to use the right door instead of

play06:52

the left

play06:53

door if we're not training the model

play06:56

appropriately and setting the right

play06:58

gamma it may get fixated on that one

play07:02

point in this case this would be the

play07:05

overtraining of that particular run by

play07:08

allowing the gamma to be a little bit

play07:10

lower we can have some variety where the

play07:14

model will try a few different

play07:16

variations throughout the training

play07:18

course ultimately this can lead to

play07:22

higher run times and more iterations but

play07:25

the quality of the output will likely be

play07:27

better eventually you may like what

play07:30

you're seeing in the output of the model

play07:33

in which case you may bring up this

play07:35

gamma a little bit more to make the

play07:37

variations less to try to refine the

play07:41

process that you currently have you'll

play07:44

also see here that we're using the CPU

play07:46

in this case for this type of model you

play07:50

only get a marginal Improvement by using

play07:52

a GPU so to keep cost down in my case

play07:56

I'm just going to leverage the CPU that

play07:58

I have but there may be some longer

play08:01

models or different types of machine

play08:03

learning training models where a GPU

play08:06

will be more beneficial so if I wanted I

play08:09

could come here and specify that I want

play08:10

to use a

play08:12

GPU I'm also logging out all of our

play08:16

metrics into a tensor board log file

play08:20

let's go ahead and start this training

play08:26

run you'll see here this the training

play08:30

has started and we specify that we're

play08:33

using the CPU device in this

play08:36

case it's going to take a few moments to

play08:39

start getting some results

play08:41

back at most we'll have

play08:46

the episode length here for the maximum

play08:50

amount of steps that are going to be

play08:51

taken within the

play08:54

game you may see some earlier instances

play08:57

though of results and and this will be

play08:59

the case where the playing character has

play09:03

died three times and has lost the

play09:07

game let's go ahead and take a closer

play09:10

look at a training

play09:11

run this is a video of me going from the

play09:15

10 instances up to over a 100 we have a

play09:19

few things that we'll take note on first

play09:22

off you'll see that most of the frames

play09:25

have certain trends that are happening

play09:28

majority of the time we'll see maybe 80

play09:30

or 90% of the instances following a very

play09:34

similar path but let's go ahead and look

play09:36

at some

play09:39

outliers first we see here that the

play09:42

playing character is eventually getting

play09:44

stuck here this is preventing it from

play09:48

moving further on in the

play09:50

game we need to find ways to penalize

play09:54

the model in this case and say getting

play09:57

stuck is a bad scenario we can do this

play10:01

in a few ways and I'll show some of

play10:04

those here

play10:05

shortly now let's move to another

play10:09

section where the playing character is

play10:12

actually progressing very quickly

play10:16

through we'll see some Trends forming

play10:19

often times the character will punch

play10:23

backwards it is found the optimal

play10:26

solution of beating the different NPCs

play10:29

in the

play10:30

game I shared this video with a

play10:32

speedrunner recently and he thought this

play10:35

was very interesting as often times the

play10:37

speedrunners will do the exact same

play10:40

thing to get through the level quickly

play10:42

the AI in this case has found the

play10:45

optimal path through the first level of

play10:47

the

play10:48

game we'll see in this particular frame

play10:51

that the character has now gotten to the

play10:53

first

play10:55

boss in this case it's going to lose

play10:58

because hasn't found the optimal pattern

play11:01

to beating the boss in this case we'll

play11:04

need to change the reward system

play11:07

slightly first off ideally we want more

play11:10

of these instances getting to the final

play11:12

boss so that it has more playthroughs at

play11:16

that point in the level we can also

play11:18

change the rewards on how it optimizes

play11:21

certain moves like the back punch to

play11:24

beat this particular

play11:25

boss let's dive into that more before we

play11:29

going back to our Jupiter notebook I

play11:32

want to show this particular

play11:34

image it doesn't look like much is going

play11:37

on here it's kind of a blurry image and

play11:41

there's not much that we can make out

play11:43

with our human eyes at least but this is

play11:46

actually what the model sees on each

play11:50

frame of the

play11:51

game we have reduced the

play11:54

resolution and changed some of the pixel

play11:58

structure to optimize the training

play12:02

within the

play12:03

model A lot of times high resolution

play12:06

images are actually a detriment they

play12:09

take too much information it's too

play12:12

complex for the model to figure

play12:14

out this is a process where we've

play12:16

normalized the data into a way that's

play12:19

optimal for this particular algorithm

play12:22

and the training of this

play12:26

model you will also see that there are

play12:28

three images here this helps the model

play12:33

have some context of its previous moves

play12:37

the top frame is what's happening now

play12:40

and then the previous two on the bottom

play12:43

are going to be frames from what had

play12:45

happened just before this allows the

play12:49

model some flexibility especially when

play12:51

jumping over a object in the game or

play12:56

having to use a ladder or interact with

play12:58

an NPC

play13:02

this is a way that we can add memory to

play13:05

the

play13:06

model now let's go ahead and look more

play13:09

at the reward system I provide rewards

play13:12

for five critical areas in the game we

play13:16

have score so this is what happens when

play13:19

our playing character either punches or

play13:21

kicks a NPC in the game there's a

play13:24

certain amount of score that's assigned

play13:26

for kicks and punches and then as the

play13:31

game progresses those will increase in

play13:34

magnitude we then have position or in

play13:37

this case I have it labeled as

play13:40

POS this turns out to actually be the

play13:43

most critical of all of the reward

play13:46

metrics that we're tracking in the

play13:49

game by having reward for each new frame

play13:53

that we have in the game it encourages

play13:56

our model to explore it's turns out in

play14:00

these types of reinforcement learning

play14:03

models exploration is the most critical

play14:06

aspect sometimes you can even ignore

play14:08

things like score all together every

play14:11

time that the playing character goes

play14:14

into a new level so the boss or after

play14:18

it's beaten the boss I also reward it on

play14:22

top of the positioning this makes it so

play14:26

that the AI model knows how I want it to

play14:30

progress through the level and not get

play14:32

stuck in bizarre

play14:35

scenarios lastly I penalize the AI for

play14:39

losing lives this makes sure that it

play14:42

tries to conserve its Health throughout

play14:44

the level and finds optimal ways of

play14:48

beating the

play14:51

NPCs another way I've optimize the game

play14:54

is by removing some unneeded

play14:57

actions you'll see see here a list of

play14:59

the actions that are available to the

play15:02

model these are the actions that it

play15:05

starts off doing randomly and then

play15:07

eventually forms patterns on as it

play15:10

progresses what's most important here is

play15:13

that you'll see that I have removed this

play15:16

button B in this case that's the

play15:20

kick in this version of Double Dragon

play15:24

the kick is not an optimal solution for

play15:27

getting through the level by removing

play15:30

this particular line I optimize the

play15:33

playthrough by over

play15:36

30% now let's go back and look at our

play15:38

model training you'll see here we're

play15:41

starting to get some results back let me

play15:43

unpack this a little

play15:45

bit here we have a variety of different

play15:48

instances and the

play15:50

score score is probably not the most

play15:53

important metric here but it gives me an

play15:55

idea of how the playing character is

play15:58

interacting in the game what's most

play16:01

important to me though is the final

play16:03

level that it got to during this

play16:07

playthrough you'll see here that we're

play16:09

starting at

play16:11

one but then here we actually have a

play16:14

level

play16:15

three this is where it takes on the

play16:19

first boss we showed an example of this

play16:22

in the previous View where we had many

play16:25

different iterations of the game

play16:27

playing this is where I've had to tweak

play16:30

the reward systems as I mentioned to get

play16:32

more of these getting to level

play16:36

three now that we've done a few

play16:38

runthrough of the game let's go ahead

play16:41

and look at some metrics we can use the

play16:44

popular tensor board to visually see

play16:46

these metrics within our Jupiter

play16:51

notebook we'll go ahead and start a

play16:54

session if you come in here into our

play16:57

scaler section we can see some more

play17:00

graphs we'll things see things like

play17:05

FPS the

play17:09

KL different clip

play17:13

fractions are inpr

play17:16

loss some variance

play17:19

functions and the different loss

play17:22

functions here from the metrics that are

play17:25

collected this is a good way for people

play17:29

who are doing model training to see how

play17:31

effective their model is in their

play17:35

different training

play17:37

Cycles I want to quickly show the docker

play17:41

file that we use to make this workbench

play17:44

possible here I take our open shift AI

play17:50

Jupiter data

play17:57

science here I take take our open shift

play18:00

AI Jupiter data science image and then I

play18:04

go ahead and add some things to it let

play18:07

me show you the requirements

play18:11

file most importantly here I'm adding in

play18:14

the

play18:15

pboy package this is the emulator we use

play18:19

to run through the different

play18:21

iterations of the game but this is an

play18:24

example of how we can take a base image

play18:27

within open shift a I and add the

play18:29

necessary packages we need to run our

play18:32

experiments and our model

play18:36

training after making some adjustments

play18:39

specifically removing the kick and also

play18:44

increasing our positional rewards and

play18:47

decreasing our scoring rewards I was

play18:49

eventually able to beat the first level

play18:53

of this game as mentioned before

play18:57

eventually the AI learned that punching

play19:00

from behind so using its elbow was the

play19:04

most effective way to go through the

play19:07

level it goes through very quickly by

play19:10

finding a corner and then letting NPCs

play19:13

come to it with his elbow move

play19:17

eventually he'll make his way into the

play19:20

boss battle where he'll do this very

play19:23

same move but make sure to position

play19:25

himself in the corner

play19:29

and you can see here he finally beats

play19:31

the boss and moves on to the next

play19:34

mission now here I've had to train it in

play19:39

a variety of ways to use these ladders

play19:42

this is where vertical positioning was

play19:44

critical and making sure that it knew

play19:46

how to jump effectively between

play19:50

platforms that's for another video

play19:53

that's it for this demo we've shown how

play19:56

reinforcement learning can be run on

play19:59

open shift

play20:00

AI now this is a cool and and fun

play20:04

example but what are some practical

play20:06

applications of this well this same type

play20:09

of model is used to train things like

play20:12

driverless cars and

play20:15

Robotics there are a lot of applications

play20:18

for this particular field of machine

play20:20

learning and also how it relates back to

play20:22

things like gener of AI and large

play20:25

language

play20:27

models I'd like to give a special thanks

play20:29

to Peter from the Pokemon RL

play20:34

Community here is a GitHub page of a

play20:38

Pokemon version of what I did here

play20:41

today Peter has examples of a PPO

play20:45

algorithm training a model to beat

play20:48

Pokemon

play20:50

Red few things I want to call out

play20:53

here is that he has an amazing video on

play20:57

YouTube that outlines the process and

play21:00

gives you great visuals of how the model

play21:04

played through the

play21:07

game lastly there's also a Discord

play21:11

Community where we discuss things like

play21:14

Pokemon but also a variety of other

play21:17

games like Super Mario

play21:19

Brothers do check them out thank you

play21:26

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
強化学習AIトレーニングオープンシフトゲーム攻略ダブルドラゴン機械学習アルゴリズムエミュレータポケモンRLディープラーニング
Do you need a summary in English?