I have upgraded the source code with the following changes:
- added agent with logic using the python agentpy module;
- I increased the grid to 16 x 16;
- I kept the win condition at 8 pieces aligned in any direction;
- I added conditions for displaying the equality message;
The game is hard to win, you can try on my pagure account.