This project demonstrates how a Python script can control multiple entities in a virtual environment and set up an advanced communication protocol to build a structured civilization with responsibilities and hierarchy to win a survival game. The game is designed as a board game where entities have limited visibility and interaction range, requiring them to communicate and strategize.
To build the project, you need to compile both the engine (C/C++) and the model (Python) components. The Makefile automates this process.
# Build the entire project
make all
After building, you will have three main executables:
-
Server (
./engine_server
): This is the main game server.- Usage:
./engine_server -p <port> -x <width> -y <height> -n <name1> <name2> ... -c <clientNb> -f <freq>
- Replace placeholders with:
<port>
: Port number for server communication.<width>
and<height>
: Size of the board.<name1> <name2> ...
: Names of the teams.<clientNb>
: Number of clients (players).<freq>
: Game frequency.
- Usage:
-
Model (
./civilization
): This is the AI component controlling the entities.- Usage:
./civilization -p <port> -n <team_name> -h <host>
- Replace placeholders with:
<port>
: Port number (must match the server).<team_name>
: The name of your team.<host>
: Hostname or IP of the server (default is "localhost").
- Usage:
-
GUI (
./engine_gui_<your architecture>
): This provides a visual representation of the game.- Usage:
You have to run GUI executables from the
engine/gui
directory. As the GUI is architecture-dependent, you need to select the appropriate executable based on your system.
You'll need libsfml version 2.5.x installed on your system to run the GUI.
./engine_gui -p <port> -h <machine>
- Replace placeholders with:
<port>
: Port number (must match the server).<machine>
: Hostname of the server.
- Usage:
You have to run GUI executables from the
To clean up the built files and reset the environment:
# Clean temporary files
make clean
# Fully clean and reset
make fclean
This project is composed of two main parts:
- Engine: Written in C/C++, the engine is a server with a GUI that allows the Python model to connect and control entities.
- Model: Written in Python, the model handles the civilization system, including secure server connections and role management.
The civilization is guided by a Leader, who has the primary role of orchestrating the game:
- Assigns roles to entities.
- Sets strategic steps for the civilization.
- Does not physically move on the board, relying on other entities to supply food and resources.
The civilization progresses through distinct phases based on the number of entities and their positioning on the map.
-
Regroupement:
- The first entity on the map becomes the Leader and broadcasts its location, prompting other entities to join and establish a base.
-
Growth:
- Focus on foundational growth:
- Poule: Continuously forks (creates new entities).
- Marthyr: Sacrifices itself, dropping all food to build a solid base.
- Focus on foundational growth:
-
Exploration:
- Resource gathering intensifies with various roles assigned to find resources and avoid death.
-
Leveling Up:
- A strict focus on resource accumulation and leveling up the civilization.
Roles evolve as the civilization advances, ensuring a dynamic approach to growth and survival.
Phase One Roles:
- Poule: Creates new entities until death.
- Marthyr: Sacrifices itself, providing essential resources.
Phase Two Roles:
- Gatherer: Gathers resources, focusing on survival.
- Court: Stay in the base, helps in forking and make the team level up when enough ressources are in the base.
- Concubine: Forks to increase population without succumbing to starvation.
- Marthyr: Continues to support by sacrificing itself.
- Snail: Use a snail shape pattern to cross all the map and pick up food and ressources.
Phase Three Roles:
- Gatherer: Advanced resource collection with specialized movement patterns.
- Court: Level up as much as possible to reach the maximum level.
- Concubine: Focuses on increasing the entity count without dying.
- Marthyr: Plays a critical support role, sacrificing itself when needed.
- Snail: Continues targeted resource collection.
- Assigns the base location.
- Guides other entities (trantors).
- Assigns roles based on civilization needs.
- Defines and manages encryption keys for secure communication.
Entities communicate using a strict protocol to maintain security and organization:
- "B:": The leader provides an XOR encryption key for secure communication.
- "C:": Indicates that the message is ciphered using the provided key, with content encoded in Base64.
- "R:": A request broadcast from a new entity asking for a role.
- "A::": The leader’s response assigning a role, where
<id>
matches the requesting entity's UUID.
This project is licensed under the MIT License.