A Python-based implementation of a connect-four style game featuring both console and GUI interfaces, allowing play against another human or an AI opponent. It leverages object-oriented programming principles, showcasing polymorphism, inheritance, and composition to create a well-structured and extensible codebase.
Game's Graphical User Interface
main.py
: The entry point of the application. Initializes and starts the game engine.engine.py
: Manages the game's main loop and switches between different interfaces (console or GUI). Demonstrates the use of composition by managing different components of the game.board.py
: Contains theBoard
class which handles the game's logic, including grid management and win conditions.player.py
: Abstract base class for players, providing a framework forHumanPlayer
andAIPlayer
. This is a clear example of polymorphism, allowing the use of different player types interchangeably.human_player.py
: Implements the human player functionality, handling user inputs. Inherits fromPlayer
.ai_player.py
: Implements AI behavior, making decisions randomly within the game constraints. Inherits fromPlayer
.ui.py
: Abstract base class for user interfaces, exemplifying the use of polymorphism through different user interface implementations.console_interface.py
: Console-based interface for the game, displaying the board state in the terminal. Inherits fromUI
.gui.py
: Graphical user interface using Tkinter to provide a visual game experience. Inherits fromUI
and demonstrates advanced polymorphism and composition.
Run the game by executing main.py
. You'll be prompted to choose between the console and GUI interface and select the type of opponent (human or AI).