You can build and run the image using the following command:
docker build -t ex4-6-colors .
docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm ex4-6-colorsThis is a strategic game where two players (user vs CPU or two users) compete to claim the majority of a board by changing the color of connected shapes.
-
Efficient Board Creation: The board is generated in
$O(n)$ time. - Game Modes: Choose between single-player (vs CPU) or multiplayer modes.
- Customizable: Players can resize the map.
- Player 1 starts at the bottom-left, and Player 2 (user or CPU) starts at the top-right. Both start colored black.
- On each turn, a player picks a color from 6 options. All adjacent shapes of that color are claimed and recolored.
- The game continues until a player controls 50% of the board.
- Players cannot choose colors already in use by themselves or the opponent.
- Manages a shape and its neighboring connections.
- Can merge with adjacent shapes of the same color.
- Randomly splits into triangles if it’s a square.
- Holds the
ShapeCellvector and manages the board layout. - Efficiently constructed in O(n) time.
- Manages gameplay, player turns, and board rendering.
- Tracks board control percentage and declares the winner.
- Handles game settings, including board resizing and mode changes.
- Base class for players, managing their claimed shapes and chosen color.
- Uses a recursive algorithm to make optimal color choices based on neighboring cells.
- Accepts color choices from the user via the toolbar.
- Displays color options for players to choose from.
- Provides user input for turns and settings.
- Singleton class for loading and accessing game images.
- In multiplayer mode, the starting cell is not shaded correctly.