This is an attempt at training an agent with DDQN to play Connect 4. The agent is trained using a neural network, a replay buffer and a target network.
Main python script to train the agent.
Contains the ReplayBuffer class to store the agent's experiences.
Contains the MDP class to represent the Connect 4 game.
A utility script to watch the training loss.
A bunch of neural networks to try out.
A few basic algorithm for the environment's response to the agent's actions.
To estimate the agent's performance against a few opponents.
Simple network with 1 layer with fixed weights : counts the sums of all alignments of 4 cells (diagonally, horizontally and vertically).
Result : approximately 75% win against dumb opponent (looks for an easy win otherwise plays randomly).
Trained on 50,000 episodes. Training further won't help.
Same network but with Heaviside activation function after the new cells : looks where four aligned cells have a sum of +3 or -3.
Same results as my_DDQN (Grogu).
Huber loss instead of MSE. 92% win against dumb opponent.
Huber loss again 96% win against dumb opponent.
Took 1,000,000 episodes to get a 75% winning rate against smartdumb opponent :
- Half of the time it looks for an easy win and if it can't, it plays randomly
- Half of the time it looks for an easy win, then an immediate threat, then plays randomly.