Git Product home page Git Product logo

meru-tech-test's Introduction

Minesweeper

Live version

MeruTechnicalTest

What to build

Develop the classic game of Minesweeper

The following is a list of items (prioritized from most important to least important) we wish to see:

  • Design and implement a documented RESTful API for the game (think of a mobile app for your API)
  • When a cell with no adjacent mines is revealed, all adjacent squares will be revealed (and repeat)
  • Ability to 'flag' a cell with a question mark or red flag
  • Detect when game is over
  • Persistence
  • Ability to start a new game and preserve/resume the old ones
  • Ability to select the game parameters: number of rows, columns, and mines
  • Write specs (unit testing)

Decisions

First batch

  • I started working on the base game
  • The attributes of the game are:
    • rows
    • columns
    • mines
    • status (to check if the game is new, incomplete or completed)
    • board (which is going to hold the mines and data)
  • I started with rspec and TDD, first the test, then the functionality
  • The update and delete methods on games were not considered to not alter the games on the game REST inteface, it will be modified on another interface (such as moves or cells or something like that)

Second batch

  • Give up on the TDD (for now ๐Ÿ˜…)
  • Add a class to represent a cell with the following attributes
    • mark: to represent a question mark or a flag
    • value: the number of mines adjacent
    • mine: to represent if the cell is a mine or not
    • open: to represent if the cell has been revealed
  • add two services to build the board randomly with the params passed

Third batch

  • I started working on the cells update.
  • at the moment the user could flag, mark or open the cell.
  • I'm thinking of making a service to handle all the logic of the update.

Fourth batch

  • add the logic to reveal multiple cells, got an error with a recursive function but it was caused by the lifetime of the objects.

  • Still thinking on the logic for the win condition and the guard to not modify finished games.

Fifth batch

  • add the logic to check the win of a game
  • add a new route to check the unfinished games
  • add a new route to check the finished games
  • add a constraint to the resource of game to match the new routes of finished and unfinished

API

Games

Show all games

GET /games

Show a single game

GET /games/:id

Create a new game

POST /games

params

  • rows: number of rows that the board will have
  • cols: number of columns that the board will have
  • mines: number of mines in the board

Show all the unfinished games

GET /games/in-progress

Show all finished games

GET /games/finished

'Click' a cell

PUT/PATCH /games/:id/cells/:row/:col

'Mark' a cell

PUT/PATCH /games/:id/cells/:row/:col

params

  • mark: the mark on the cell (flag, question)

meru-tech-test's People

Contributors

darckjack 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.