This is a Dominoes game that allows bots to play against each other.
- Clone the project
- Install dependencies
$ composer install
- Execute the app (requires PHP 8)
If your machine doesn't have PHP 8, you can use Docker.
$ php ./public/index.php
$ docker-compose up
- Only depends on PHP PSR standards.
- This is a modular project in which the Dominoes module is 100% covered with unit tests.
- No frameworks were used (besides PHPUnit).
- Only one external library:
- php-di/php-di: For dependency injection.
- If you want to read and understand the code, you should start from the \Console\Application class.
- The whole game is managed by the GameMediator which provides all functionalities you would expect from a Dominoes game.
- The LineOfPlay holds all the placed tiles in the correct order and knows all the available connection spots for new tiles.
- The RoundManager decides who is the next to play.
- The Bot is any algorithm that can decide the next move a player should perform based on the current game situation.
- Execute all tests.
$ composer run test
- Generate the test coverage report in the directory
./test-coverage
.$ composer run test-coverage
- Tile: The individual piece of a domino deck. It's divided in two sides, each side is called a pip.
- Pip: One of the two sides of a tile.
- Line of play: The array of tiles on the table upon which plays in the game are made.
- Round: Cycle of play in which each player must place a tile on the line of play, draws, or pass its turn.
- Deck: The complete batch of tiles, each one occurring exactly once, that is used to play Dominoes games.
- Draw: To transfer a tile from the boneyard to the player's hand.
- Boneyard: Set of tiles from which players draw.
There are many types of Dominoes games. This game I implemented here is more close to the Draw Domino Game. Find below the list of rules I followed for the game in this project.
- The players alternate turns to place a tile.
- A tile can only be placed next to another tile that has the same pip.
- If the player doesn't have a tile with a matching pip, he must draw a new tile until it finds one that matches.
- If there are no more tiles to draw, the player passes its turn.
- The first player to empty his hand is the winner.
- If no player can place another tile and there are no more tiles to draw, the game is considered tied.