This project implements the Connect Four game in Python, utilizing the resources available in the language.
Connect Four is a classic game in which two players take turns trying to form a line of four consecutive pieces of the same color, whether horizontally, vertically, or diagonally. The board consists of seven columns and six rows, and players choose in which column to place their piece.
To play:
- Execute the file
Main.py
. - Follow the instructions to configure the number of players.
- During the game, players will take turns, and each will make their move by choosing the desired column.
The UML diagram presents the structure of the project's classes, highlighting the relationship between them.
-
Virtual Environment: If you intend to run the game with Pygame, it is recommended to create a virtual environment. To do this, execute:
python -m venv venv
1.a. Then, activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On Linux/Mac:
source venv/bin/activate
-
-
Install requirements.txt: Don't forget to install the requirements listed in the
requirements.txt
file.pip install -r requirements.txt
-
Run the project: After setting up the environment and installing the necessary dependencies, execute this command to start the project.
python pygameMain.py
-
Execution without Pygame: If you are not using Pygame, you can run the project normally without the need for a virtual environment.
python Main.py
Contributions are welcome! If you find bugs, issues, or have suggestions to improve the game, feel free to open an issue or submit a pull request. Below are some ways you can contribute:
- Fork the project by clicking on the "Fork" button at the top right of this page. This will create a copy of the repository in your account.
- Clone the repository to your local machine:
git clone https://github.com/your-username/your-repository.git
- Navigate to the project directory:
cd your-repository
- Create a new branch to work on:
git checkout -b my-contribution
- Make desired changes in the code.
- Commit your changes:
git commit -am 'Adding a new feature'
- Push your changes to GitHub:
git push origin my-contribution
- Navigate to your fork's page on GitHub.
- Click on the "New Pull Request" button.
- Describe your changes and click "Create Pull Request".
Once your Pull Request is reviewed, it can be merged into the main project.
Thank you for contributing!
I'm still learning about testing, so this section is deprecated. I will fix it in the future.
If you prefer to run the project with the interface, and have installed the project dependencies, you can execute the tests with the commands below.
To run the tests, use the following command:
python -m pytest -v tests/
or
python -m pytest tests/
Otherwise, if you haven't installed any dependencies, you can run the tests as follows:
If you want to test file by file, use the command below:
# Example
python test_math_operations.py
Or if you want to test all at once, use the command below:
python -m unittest discover
- Implement Pygame features for a more interactive experience.
- Improve code organization and add more comments.
- Add automated tests.
Perhaps, on Ubuntu it may be necessary to run the commands with
python3
. Don't forget to execute commands such as creating the virtual environment and running the project within the project directory.
This project is licensed under the MIT License, which means you have complete freedom to use it as you prefer. Enjoy playing and contributing!