基于Matter.js + TensorFlow.js用DQN玩落球躲避游戏Demo

基于Matter.js + TensorFlow.js用DQN玩落球躲避游戏Demo

Python 游戏开发

访问GitHub主页

共53Star

详细介绍

Falling Balls + DQN

gif

A demo of a DQN agent that learns to dodge falling balls, inspired by an old iPhone game.

The game utilizes Matter.js while the neural network is built with TensorFlow.js.

Every frame, the agent senses the environment through raycasting. Actions are LEFT, STAY, and RIGHT. It receives a reward of +1 for living and -1 for dying.

On the webpage, hyperparameters can be edited at the bottom.

Notes:

  • Resetting and restarting the agent seems to cause a small memory leak. Refreshing the page is recommended if this causes any problems.
  • Training will pause if the browser tab loses focus (depends on setTimeout).
  • On default settings, the agent usually starts performing better at around 100 episodes.
  • May not work correctly on some platforms/browsers. For example, for some reason, I have seen it not work with Chrome on Ubuntu 16.04, while it did with Firefox.

Webpage