Coder Social home page Coder Social logo

dominoes's Introduction

Dominoes Game

PHP implementation of classic double six dominoes game developed using test-driven approach.

Requirements

  • PHP 7.4 with Composer to run with composer play
  • Alternatively Docker to run with script/run

Implementation Approach

  • Game is non-interactive (yet):
    • Simulate 2 players playing double six dominoes game with a simplified rules
    • Play until one player hand is empty - then he wins
    • Play until stock is empty - then it's a draw and no one wins
  • Identify entities for dominoes game
    • Dominoes game set
    • Tile single tile for dominoes game
    • Player dominoes player
    • Pile contain tiles, used by Dominoes board and stock, and by Player in hand
  • Identify business logic according to requirements
    • DominoesSimulator knows how to run Dominoes game simulation
    • BasicSimulatorStrategy knows how Player can play basic dominoes according to the rules
  • Development cycle
    • Write tests for required logic
    • Write implementation until tests pass
    • Refactor, cleanup
    • Repeat

How To

  • Install dependencies with composer install
  • Run simulation with composer play or php app.php or script/run (docker)
  • Run tests with composer test
  • Check test coverage with composer coverage

Game description & Rules

Dominoes is a family of games played with rectangular tiles. Each tile is divided into two square ends. Each end is marked with a number (one to six) of spots or is blank. There are 28 tiles, one for each combination of spots and blanks.

  • The 28 tiles are shuffled face down and form the stock.
  • Each player draws seven tiles.
  • Pick a random tile to start the line of play.
  • The players alternately extend the line of play with one tile at one of its two ends;
  • A tile may only be placed next to another tile, if their respective values on the connecting ends are identical.
  • If a player is unable to place a valid tile, they must keep on pulling tiles from the stock until they can.
  • The game ends when one player wins by playing their last tile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.