Coder Social home page Coder Social logo

dqn_hollowknight's Introduction

Readme

I am keeping upgrading this, so the code may change everyday.

Environment

  • windows 10 (We use win32 API to operate the little knight and get screenshots)
  • python 3.8.8
  • python liberary: find in requirments.txt
  • Hollow Knight
  • HP Bar mod for Hollow Knight (In order to get the boss hp to calculate the reward, please find the mod in ./hollow_knight_Data/, and then copy the mod file to the game folder)
  • CUDA and cudnn for tensorflow

Usage

  • Now I only write train.py but not test.py (the file is just test some base functions not for model), you can write it by yourself if you get a good model.
  • I upload a saving file, if you never played this game, please move /save_file/user3.dat into save folder (usually C:\user\_username_\AppData\LocalLow\Team Cherry\Hollow Knight)
  • Adjust the game resolution to 1920*1017
  • Run train.py
  • Keep the game window at the forefront (Since I cannot send keyboard event in the background, I tried PossMassage() in win32 API, but it did not work well. If you have any idea about sending keyboard event in the background, please let me know)
  • Let the little knight stand in front of the statue of the boss in the godhome
  • Press F1 to start trainning. (Also you can use F1 to stop trainning)

Code structure

  • Most training configuration is in train.py

  • Agent.py gets output actions from our model

  • DQN.py is the learning algorithm

  • Model.py defines the model we use

  • ReplayMemory.py defines the experience pool for learning

  • test.py is useless, I use it to test basic functions and fix bugs

  • Files in ./Tool are for other functions we may use

  • Actions defines actions for little knight and restart game script

  • GetHp help us get our hp, boss hp, soul and location(it may have some bugs, you can fix it by yourself)

  • SendKey is the API we use to send keyboard event to windows system.

  • UserInput is an useless file, which I used it to train my model manually.

  • WindowsAPI is used to get screenshot of the game, and key_check() is used to check which key is pressed.

  • Helper defines [Reward Jugment] fucntion, and other functions we may use

Changes

  • Add delay reward of an action

  • Make the mdoel output an action sequence

  • Use two models to output actions. One is for moving and the other is for attack/jump/skill

  • Apply RESNET

  • Add LSTM layers

  • Merge a part of action model and move model

  • Remvoe LSTM layers

  • No more Q value, reward is enough, Q value is too complex to learn.

  • Use kernel32 to read player Hp and hornet Hp.

  • Use different criteria to evaluate move and actions.

  • Do not use skill without souls

  • Use more precise scoring standards

dqn_hollowknight's People

Contributors

ailec0623 avatar infcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dqn_hollowknight's Issues

pywintypes.error: (87, 'OpenProcess', '参数错误。')

UP主您好,想请教一个问题,我在运行train.py的时候,在GetHP这个脚本中,实例化Hp_getter()这个类的时候遇到了问题,

File "D:\python_workspace\git\DQN_HollowKnight-main\Tool\GetHP.py", line 30, in init
self.process_handle = win32api.OpenProcess(0x1F0FFF, False, pid)

pywintypes.error: (87, 'OpenProcess', '参数错误。')

我打印了hd = win32gui.FindWindow(None, "Hollow Knight")
pid = win32process.GetWindowThreadProcessId(hd)[1] 这两行代码的输出,发现pid获取出来是负数(如:-1499715320),我的系统是64位的win10,请问您是否遇到过类似的问题,有无解决方案呢,谢谢

The game saving is missing.

It is said that there is a saving for those who do not play HollowKnight in the README file but it seems that there are actually no such file (/save_file/user3.dat) in this repository. Is it missing or moved to another place? Thanks for any help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.