Giter Site home page Giter Site logo

cpp_tdd_2048_game's Introduction

Build Status Sonar Coverage Sonar Maintainability Docker Image

2048 Game

Game description in https://en.wikipedia.org/wiki/2048_(video_game)#Gameplay

Test Specs

Business rules

  1. There is a board:

    • board is a set of positions organized in rows and columns (e.g. 16 positions in a 4 rows and 4 columns);
    • a board can not have less than 2 positins, less than 2 rows and less than 2 columns;
    • player can make a slide in one direction {left,right,up,down}:
      • a slide is applied to all the numbers in the board, starting from the nearest to the destination of the slide;
      • a sliding number will stop when encounter a board edge or a number that cannot be merged;
      • if a sliding number encounters a number that can be merged, it will be merged in the number and the sliding number will be removed from the board;
      • if a sliding number encounter a number that was already merged, it must stop;
    • a number can be placed randomly in a board empty position.
  2. There are numbers:

    • a number has a value;
    • a value must be greater than or equal to 2;
    • a value must be power of two;
    • a number A can merge in another number B with the same value:
      • the B number will became merged and will have the double of its original value;
      • the A number will be removed from its original place.
  3. There are positions:

    • a position can have a number placed on itself;
    • a position can have adiacent positions {left,right,up,down}.
  4. There is a player:

    • a player is queried for a valid direction to slide.
  5. There is a game:

    • at every turn, a random number (with value of 2 or 4) is placed in a random empty spot of the board;
    • at every turn, a valid slide direction is requested to the player;
    • game ends when player win (when obtain a 2048 number) or lose (when can not slide due to end of spaces and mergeable slides in the board).
  6. There is an observer:

    • an observer is notified about game events (start, number placed, player slided, end).

Use cases

  1. A player starts a new game:

    • the player defines the end score and the board size;
    • the game validates the board size;
    • the game notifies the start with winning score and board size;
    • the game places a number;
    • the game notifies the number value and position.
  2. The playar make a slide:

cpp_tdd_2048_game's People

Contributors

campisano avatar

Watchers

 avatar  avatar

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.