IT박스

시각적 입력을 사용하여 디아블로 2를 재생하도록 인공 신경망을 훈련시키는 방법은 무엇입니까?

itboxs 2020. 7. 1. 08:18
반응형

시각적 입력을 사용하여 디아블로 2를 재생하도록 인공 신경망을 훈련시키는 방법은 무엇입니까?


현재 ANN에서 비디오 게임을하려고하는데 멋진 커뮤니티의 도움을 받기를 원했습니다.

나는 디아블로 2에 정착했다. 게임 플레이는 실시간으로 그리고 아이소 메트릭 관점에서 볼 때, 플레이어는 카메라가 중앙에있는 단일 아바타를 제어한다.

일을 구체적으로 만들기 위해, 임무는 몬스터를 죽이면 체력이 0으로 떨어지지 않고 캐릭터 x 경험치를 얻는 것입니다. 게임 플레이의 예는 다음과 같습니다.

여기

이제는 화면의 픽셀에서 얻은 정보를 기반으로 네트가 작동하기를 원하기 때문에 효율적으로 재생하려면 매우 풍부한 표현을 배워야합니다. 게임 세계를 사물로 나누고 상호 작용하는 방법.

그리고이 모든 정보는 어떻게 든 인터넷에 가르쳐야합니다. 나는 내 인생을 위해이 일을 훈련하는 방법을 생각할 수 없습니다. 내 유일한 아이디어는 게임에서 시각적으로 좋은 / 나쁜 것을 시각적으로 추출하는 별도의 프로그램 (예 : 건강, 금, 경험)을 강화 학습 절차에서 사용하는 것입니다. 나는 그것이 답의 일부 가 될 것이라고 생각 하지만, 그것이 충분하다고는 생각하지 않습니다. 생생한 시각적 입력에서 목표 지향적 행동에 이르기까지 너무 많은 추상화 수준이 생겨서 제한된 피드백으로 내 인생에서 그물을 훈련시킵니다.

내 질문 :이 작업의 적어도 일부를 수행하기 위해 그물을 훈련시키는 다른 방법은 무엇입니까? 바람직하게 수천 개의 레이블이 붙은 예를 만들지 않고 ...

조금 더 지시하면 :이 설정에서 유용한 정보를 추출하기위한 다른 강화 학습 소스 및 / 또는 감독되지 않은 방법을 찾고 있습니다. 또는 레이블링 된 데이터를 수동으로 레이블링하지 않고 게임 세계에서 가져 오는 방법을 생각할 수있는 경우 감독 알고리즘.

업데이트 (04/27/12) :

이상하게도, 나는 여전히이 일을하고 있으며 진전을 보이고있는 것 같습니다. ANN 컨트롤러가 작동하게하는 가장 큰 비밀은 작업에 적합한 최첨단 ANN 아키텍처를 사용하는 것입니다. 따라서 나는 시간적 차이 역 전파 (즉, 표준을 통한 강화 학습 )로 미세 조정하기 전에 내가 감독하지 않은 방식으로 훈련 한 팩터링 된 조건부 제한 Boltzmann 기계 로 구성된 깊은 신념 그물을 사용했습니다 (게임을하는 비디오에서) 피드 포워드 ANN).

그래도 더 실시간으로 액션 선택 문제와 ANN 처리를 위해 컬러 이미지를 인코딩하는 방법에 대한 귀중한 입력을 찾고 있습니다 :-)

업데이트 (10/21/15) :

방금 전이 질문을했던 것을 기억하고, 이것이 더 이상 미친 아이디어가 아니라는 것을 언급해야한다고 생각했습니다. 마지막 업데이트 이후 DeepMind는 신경망이 시각 입력으로 atari 게임을하도록하는 데 관한 자연 논문을 발표했습니다 . 실제로, Diablo 2의 제한된 하위 세트 인 아키텍처를 사용하여 플레이하지 못하게하는 유일한 것은 기본 게임 엔진에 대한 액세스가 부족하다는 것입니다. 화면으로 렌더링 한 다음 네트워크로 리디렉션하는 것은 너무 느리게 진행되어 합당한 시간 내에 훈련 할 수 없습니다. 따라서 우리는 아마도 이런 종류의 봇이 곧 Diablo 2를 재생하는 것을 볼 수는 없지만 오픈 소스 또는 렌더링 대상에 대한 API 액세스로 무언가를 재생하기 때문입니다. (아마도 지진?)


ANN 교육 방법에 대해 걱정하고 있음을 알 수 있지만 이 프로젝트는 알지 못하는 복잡성숨 깁니다 . 이미지 처리를 통한 컴퓨터 게임의 객체 / 캐릭터 인식 은 매우 어려운 작업입니다 ( FPS 및 RPG 게임에는 열광 하지 않습니다 ). 나는 당신의 기술을 의심하지 않으며 그것을 할 수 없다고 말하지는 않지만 ANN 자체를 구현하는 것보다 물건을 인식하는 데 10 배 더 많은 시간을 할애 할 수 있습니다 (이미 디지털 이미지 처리 기술에 대한 경험이 있다고 가정합니다) ).

나는 당신의 생각이 매우 흥미롭고 또한 야심적 이라고 생각합니다 . 이 시점에서 다시 고려할 수 있습니다. 나는이 프로젝트가 당신이 대학을 위해 계획하고있는 것이라 생각합니다. 만약 작품의 초점이 정말로 ANN이라면 다른 게임을 선택해야 할 것입니다. 더 간단한 것입니다.

다른 사람이 얼마 전에는 다르지만 비슷한 프로젝트 에 대한 팁을 찾았다는 것을 기억합니다 . 확인해 볼 가치가 있습니다.

반면에, 제안을 받아들이는 경우 게임 내 오브젝트를 식별하는 더 좋고 쉬운 방법이있을 수 있습니다. 그러나 먼저,이 프로젝트를 스마트 봇 이라고 부르십시오 .

봇을 구현하는 한 가지 방법 은 게임 클라이언트의 메모리에 액세스 하여 화면에서 캐릭터의 위치 및 건강과 같은 관련 정보를 찾습니다. 컴퓨터 메모리를 읽는 것은 쉽지 않지만, 메모리에서 찾을 위치를 정확히 파악하는 것은 쉽지 않습니다. Cheat Engine 과 같은 메모리 스캐너 가이 기능에 매우 유용 할 수 있습니다.

게임에서 작동하는 또 다른 방법 은 렌더링 정보 조작과 관련이 있습니다. 게임의 모든 오브젝트는 화면에 렌더링되어야합니다. 즉, 모든 3D 객체의 위치가 처리를 위해 비디오 카드로 전송됩니다. 심각한 디버깅을 준비하십시오.

이 답변에서는 이미지 처리를 통해 원하는 것을 달성하는 두 가지 방법을 간략하게 설명했습니다. 당신이 그들에 관심이 있다면 당신은 주제에 대한 훌륭한 책인 온라인 게임 이용 (제 6 장)에서 그들에 대해 더 많은 것을 찾을 수 있습니다 .


업데이트 2018-07-26 : 끝났 습니다! 우리는 이제 이런 종류의 게임을 해결할 수있는 시점에 접근하고 있습니다! 팀은 OpenAI를 사용하고 게임 DotA 2를 기반으로 5v5 게임에서 반 전문 게이머를 이길 수있는 AI를 만들 수 있습니다 . DotA 2를 아는 경우이 게임이 역학 측면에서 디아블로와 유사한 게임과 유사하다는 것을 알고 있지만 팀 플레이로 인해 더 복잡하다고 주장 할 수 있습니다.

예상대로, 이것은 딥 러닝을 통한 강화 학습의 최신 발전과 OpenAI와 같은 공개 게임 프레임 워크를 사용하여 깔끔한 API를 얻음으로써 AI의 개발을 용이하게하고 게임을 가속화 할 수 있기 때문에 달성되었습니다 (AI가 재생 됨) 180 년의 게임 플레이가 매일 그 자체와 대등합니다!).

2018 년 8 월 5 일 (10 일만에) ,이 AI를 최고의 DotA 2 게이머에게 맞설 계획입니다. 이것이 해결된다면, Go 게임의 해결만큼 중대 화되지는 않았지만 큰 혁명을 예상 할지라도 AI 게임에는 큰 이정표가 될 것입니다!

2017-01 업데이트 : AlphaGo의 성공 이후이 분야는 매우 빠르게 발전하고 있으며 거의 ​​매월 게임에서 기계 학습 알고리즘을 쉽게 개발할 수있는 새로운 프레임 워크가 있습니다. 내가 찾은 최신 목록은 다음과 같습니다.

  • OpenAI 's Universe : 기계 학습을 사용하여 거의 모든 게임플레이 있는 플랫폼 . API는 Python으로되어 있으며 VNC 원격 데스크톱 환경에서 게임을 실행하므로 모든 게임의 이미지를 캡처 할 수 있습니다! 머신 러닝 알고리즘을 통해 Universe를 사용하여 Diablo II를 재생할 수 있습니다!
  • OpenAI 's Gym : Universe와 비슷하지만 강화 학습 알고리즘을 구체적으로 타겟팅합니다 (따라서 AlphaGo가 사용하는 프레임 워크의 일반화이지만 더 많은 게임에 적용됩니다). Udemy 에는 OpenAI Gym을 사용하는 브레이크 아웃 또는 Doom과 같은 게임에 기계 학습을 적용 하는 과정 이 있습니다 .
  • TorchCraft : Torch (기계 학습 프레임 워크)와 StarCraft : Brood War 사이의 다리 .
  • pyGTA5 : 화면 캡처 만 사용하여 GTA5에서 자율 주행 자동차를 제작하는 프로젝트 ( 온라인 으로 많은 비디오 사용 ).

매우 흥미로운 시간!

IMPORTANT UPDATE (2016-06): As noted by OP, this problem of training artificial networks to play games using only visual inputs is now being tackled by several serious institutions, with quite promising results, such as DeepMind Deep-Qlearning-Network (DQN).

And now, if you want to get to take on the next level challenge, you can use one of the various AI vision game development platforms such as ViZDoom, a highly optimized platform (7000 fps) to train networks to play Doom using only visual inputs:

ViZDoom allows developing AI bots that play Doom using only the visual information (the screen buffer). It is primarily intended for research in machine visual learning, and deep reinforcement learning, in particular. ViZDoom is based on ZDoom to provide the game mechanics.

And the results are quite amazing, see the videos on their webpage and the nice tutorial (in Python) here!

There is also a similar project for Quake 3 Arena, called Quagents, which also provides easy API access to underlying game data, but you can scrap it and just use screenshots and the API only to control your agent.

Why is such a platform useful if we only use screenshots? Even if you don't access underlying game data, such a platform provide:

  • high performance implementation of games (you can generate more data/plays/learning generations with less time so that your learning algorithms can converge faster!).
  • a simple and responsive API to control your agents (ie, if you try to use human inputs to control a game, some of your commands may be lost, so you'd also deal with unreliability of your outputs...).
  • easy setup of custom scenarios.
  • customizable rendering (can be useful to "simplify" the images you get to ease processing)
  • synchronized ("turn-by-turn") play (so you don't need your algorithm to work in realtime at first, that's a huge complexity reduction).
  • additional convenience features such as crossplatform compatibility, retrocompatibility (you don't risk your bot not working with the game anymore when there is a new game update), etc.

To summarize, the great thing about these platforms is that they alleviate much of the previous technical issues you had to deal with (how to manipulate game inputs, how to setup scenarios, etc.) so that you just have to deal with the learning algorithm itself.

So now, get to work and make us the best AI visual bot ever ;)


Old post describing the technical issues of developping an AI relying only on visual inputs:

Contrary to some of my colleagues above, I do not think this problem is intractable. But it surely is a hella hard one!

The first problem as pointed out above is that of the representation of the state of the game: you can't represent the full state with just a single image, you need to maintain some kind of memorization (health but also objects equipped and items available to use, quests and goals, etc.). To fetch such informations you have two ways: either by directly accessing the game data, which is the most reliable and easy; or either you can create an abstract representation of these informations by implementing some simple procedures (open inventory, take a screenshot, extract the data). Of course, extracting data from a screenshot will either have you to put in some supervised procedure (that you define completely) or unsupervised (via a machine learning algorithm, but then it'll scale up a lot the complexity...). For unsupervised machine learning, you will need to use a quite recent kind of algorithms called structural learning algorithms (which learn the structure of data rather than how to classify them or predict a value). One such algorithm is the Recursive Neural Network (not to confuse with Recurrent Neural Network) by Richard Socher: http://techtalks.tv/talks/54422/

Then, another problem is that even when you have fetched all the data you need, the game is only partially observable. Thus you need to inject an abstract model of the world and feed it with processed information from the game, for example the location of your avatar, but also the location of quest items, goals and enemies outside the screen. You may maybe look into Mixture Particle Filters by Vermaak 2003 for this.

Also, you need to have an autonomous agent, with goals dynamically generated. A well-known architecture you can try is BDI agent, but you will probably have to tweak it for this architecture to work in your practical case. As an alternative, there is also the Recursive Petri Net, which you can probably combine with all kinds of variations of the petri nets to achieve what you want since it is a very well studied and flexible framework, with great formalization and proofs procedures.

And at last, even if you do all the above, you will need to find a way to emulate the game in accelerated speed (using a video may be nice, but the problem is that your algorithm will only spectate without control, and being able to try for itself is very important for learning). Indeed, it is well-known that current state-of-the-art algorithm takes a lot more time to learn the same thing a human can learn (even more so with reinforcement learning), thus if can't speed up the process (ie, if you can't speed up the game time), your algorithm won't even converge in a single lifetime...

To conclude, what you want to achieve here is at the limit (and maybe a bit beyond) of current state-of-the-art algorithms. I think it may be possible, but even if it is, you are going to spend a hella lot of time, because this is not a theoretical problem but a practical problem you are approaching here, and thus you need to implement and combine a lot of different AI approaches in order to solve it.

Several decades of research with a whole team working on it would may not suffice, so if you are alone and working on it in part-time (as you probably have a job for a living) you may spend a whole lifetime without reaching anywhere near a working solution.

So my most important advice here would be that you lower down your expectations, and try to reduce the complexity of your problem by using all the information you can, and avoid as much as possible relying on screenshots (ie, try to hook directly into the game, look for DLL injection), and simplify some problems by implementing supervised procedures, do not let your algorithm learn everything (ie, drop image processing for now as much as possible and rely on internal game informations, later on if your algorithm works well, you can replace some parts of your AI program with image processing, thus gruadually attaining your full goal, for example if you can get something to work quite well, you can try to complexify your problem and replace supervised procedures and memory game data by unsupervised machine learning algorithms on screenshots).

Good luck, and if it works, make sure to publish an article, you can surely get renowned for solving such a hard practical problem!


The problem you are pursuing is intractable in the way you have defined it. It is usually a mistake to think that a neural network would "magically" learn a rich reprsentation of a problem. A good fact to keep in mind when deciding whether ANN is the right tool for a task is that it is an interpolation method. Think, whether you can frame your problem as finding an approximation of a function, where you have many points from this function and lots of time for designing the network and training it.

The problem you propose does not pass this test. Game control is not a function of the image on the screen. There is a lot of information the player has to keep in memory. For a simple example, it is often true that every time you enter a shop in a game, the screen looks the same. However, what you buy depends on the circumstances. No matter how complicated the network, if the screen pixels are its input, it would always perform the same action upon entering the store.

Besides, there is the problem of scale. The task you propose is simply too complicated to learn in any reasonable amount of time. You should see aigamedev.com for how game AI works. Artitificial Neural Networks have been used successfully in some games, but in very limited manner. Game AI is difficult and often expensive to develop. If there was a general approach of constructing functional neural networks, the industry would have most likely seized on it. I recommend that you begin with much, much simpler examples, like tic-tac-toe.


Seems like the heart of this project is exploring what is possible with an ANN, so I would suggest picking a game where you don't have to deal with image processing (which from other's answers on here, seems like a really difficult task in a real-time game). You could use the Starcraft API to build your bot, they give you access to all relevant game state.

http://code.google.com/p/bwapi/


Well assuming at any time you could generate a set of 'outcomes' (might involve probabilities) from a set of all possible 'moves', and that there is some notion of consistency in the game (eg you can play level X over and over again), you could start with N neural networks with random weights, and have each of them play the game in the following way:

1) For every possible 'move', generate a list of possible 'outcomes' (with associated probabilities) 2) For each outcome, use your neural network to determine an associated 'worth' (score) of the 'outcome' (eg a number between -1 and 1, 1 being the best possible outcome, -1 being the worst) 3) Choose the 'move' leading to the highest prob * score 4) If the move led to a 'win' or 'lose', stop, otherwise go back to step 1.

After a certain amount of time (or a 'win'/'lose'), evaluate how close the neural network was to the 'goal' (this will probably involve some domain knowledge). Then throw out the 50% (or some other percentage) of NNs that were farthest away from the goal, do crossover/mutation of the top 50%, and run the new set of NNs again. Continue running until a satisfactory NN comes out.


As a first step you might look at the difference of consecutive frames. You have to distinguish between background and actual monster sprites. I guess the world may also contain animations. In order to find those I would have the character move around and collect everything that moves with the world into a big background image/animation.

You could detect and and identify enemies with correlation (using FFT). However if the animations repeat pixel-exact it will be faster to just look at a few pixel values. Your main task will be to write a robust system that will identify when a new object appears on the screen and will gradually all the frames of the sprite frame to a database. Probably you have to build models for weapon effects as well. Those can should be subtracted so that they don't clutter your opponent database.


I think your best bet would be a complex architecture involving a few/may networks: i.e. one recognizing and responding to items, one for the shop, one for combat (maybe here you would need one for enemy recognition, one for attacks), etc.

Then try to think of the simplest possible Diablo II gameplay, probably a Barbarian. Then keep it simple at first, like Act I, first area only.

Then I guess valuable 'goals' would be disappearance of enemy objects, and diminution of health bar (scored inversely).

Once you have these separate, 'simpler' tasks taken care of, you can use a 'master' ANN to decide which sub-ANN to activate.

As for training, I see only three options: you could use the evolutionary method described above, but then you need to manually select the 'winners', unless you code a whole separate program for that. You could have the networks 'watch' someone play. Here they will learn to emulate a player or group of player's style. The network tries to predict the player's next action, gets reinforced for a correct guess, etc. If you actually get the ANN you want this could be done with video gameplay, no need for actual live gameplay. Finally you could let the network play the game, having enemy deaths, level ups, regained health, etc. as positive reinforcement and player deaths, lost health, etc. as negative reinforcement. But seeing how even a simple network requires thousands of concrete training steps to learn even simple tasks, you would need a lot of patience for this one.

모든 프로젝트에서 매우 야심 찬 일입니다. 그러나 충분한 시간이 주어지면 '이론적으로'이루어질 수 있다고 생각합니다.

도움이 되길 바랍니다.

참고 URL : https://stackoverflow.com/questions/6542274/how-to-train-an-artificial-neural-network-to-play-diablo-2-using-visual-input

반응형