1
$\begingroup$

In a project for college I created a simple turn based game, with up to 4 players that can either move or attack the opponents. The players are playing over the network, meaning the clients are supposed to be programmed AIs. The client itself is fully functional, meaning it has all the game logic and can simulate complete games.

Now my task is to create a RL-Agent with a Deeq-Q-Network that learns to play the game. However, I don't really find any source to how that should be done. I was able to create an Agent with a DQN for the CartPole environment of OpenAI gym with PyTorch. Now my guess would be to create my own environment with the gym framework, but since the game itself is already implemented I was thinking if it was possible to feed data in the DQN without having to create the gym environment. As a state it would get the gamestate (which is a 2d grid, with information about the players and their remaining hitpoints) and all the possible moves in the current state as the action space. And since the game is network based, it would save the network after each game and reload it when the next starts during the training. For the training I would start the games over and over with a script and let it train for a while.

As I'm quite new to Machine Learning it seems really blurry as of how to tackle this problem and was hoping to get led in some direction on how to start.

$\endgroup$

1 Answer 1

1
$\begingroup$

Most OpenAI gym environments are thin wrappers around existing games and libraries. You could do the same with your game. See e.g. https://towardsdatascience.com/beginners-guide-to-custom-environments-in-openai-s-gym-989371673952 for a tutorial. There are many others, you can search "open ai gym custom environment" for more

$\endgroup$
2
  • $\begingroup$ Thanks for the reply! I've read it and tried creating my environment but I'm still stuck when it comes to how to model the custom environment as it is somewhat complex. Would it be possible to use my PyTorch DQN and prepare the data it needs on my own and calculate a reward? And not use the Gym Framework at all? Since my code already does simulate games. $\endgroup$ Jul 29, 2021 at 12:34
  • $\begingroup$ You don't have to use the provided wrappers, or follow Gym's API exactly, but you take more risks with incompatibility or making a mistake. If you know what you are doing, it's fine to connect your environment direct to the DQN agent though. $\endgroup$ Jul 29, 2021 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .