Simple Connect 4 game made in Python 3 with a Tkinter GUI. This was a personal project to learn how to program user interfaces in Python.
The game code itself was written by me in Python2 for my PHYS1201 Programming and Data Analysis module during my Physics Undergraduate degree. I modified it for Python3 and added the GUI after the module was complete.
Just run the gamegui.py in whichever way you normally run python files
- Coin toss function to determine who will go first
- Basic AI so computer will actively try to win and block player's winning moves
- Game board is displayed using matplotlib plot
- Python 3
- Matplotlib and Numpy modules
This project was mainly to teach me how to use tkinter and make a GUI in Python. I already had a command line Connect 4 Game that plotted the graphs in Matplotlib so I decided to adapt this code to work in a GUI environment. It probably isn't the best way of making a game interface, but it was fine for my purposes.
I didn't want to spend too long rewriting my actual game so some of the implementation of it might not be the most elegant or pythonic. Sorry about that!
I now feel confident making simple Python apps with multiple frame GUIs, and using basic GUI interface tools like buttons. I can also display matplotlib graphs in the Tkinter frame.
This project is licensed under the terms of the MIT license. Do whatever you want with it!
- A fantastic tutorial series that helped me get started: https://www.youtube.com/playlist?list=PLQVvvaa0QuDclKx-QpC9wntnURXVJqLyk