Russian Minesweeper — multiplayer version of the game "Minesweeper"

image

Hello, dear readers. I sincerely hope that among the readers of Habra there are fans of such wonderful games as "Super".

If remember correctly, the first time this game appeared on the operating system Windows 3.1 in the distant 1994 year. At the time this game was positioned as a means for learning to use a computer mouse and, in General, the graphical interface of the OS. She looked like this:

image

the principle of the game according to Wikipedia
Flat or three-dimensional game field is divided into adjacent cells (squares, hexagons, cubes, etc.), some of which are "mined"; the number of mined cells is known. The aim of the game is to uncover all cells that are not containing mines.
The player opens the cell, trying not to open the box with mine. Opening the cell with a mine, he loses. The mines are placed after the first move, so to lose at the first move is impossible. If by open cell mines not, it appears the number of cells adjacent to the newly opened, "bomb" (in each version of the game the neighborhood is defined differently); using these numbers, the player tries to calculate the location of mines, but sometimes even in the middle and at the end of the game some cells still have to open at random. If adjacent cells also there are no mines, it opens some "not contaminated" area to the cells that have numbers. "Mined" cell, the player may mark, so you don't accidentally open them. Open all "not mined" cell, the player wins.

However, time goes by, the popularity of minesweeper is falling, and I want to make a new life and colors in this game. So was born the multiplayer version of the game, named as "Russian Minesweeper", which is a browser-based online game. Interested please under cat.

the

game Features


Of course, a certain number of players were able to play this game, the rules will have any way to modernize and even transform. However, the main rule — the significant principle left as in the original.br>
Thus, in fact, was developed a set of rules to allow multiple players to simultaneously play on the same field.

The basic rules are as follows:

    the Aim of the game is to mark all mines with flags. the

  1. each player has their (local) flags.
  2. the
  3. players Have the same (global) field with mines.
  4. the
  5. Players take turns (however, currently, we are developing a "parallel" mode).
  6. the
  7. If the player clicks on a mine, he loses and his opponent wins, respectively.
  8. the
  9. the Time on the player is limited (~25 sec.) — Ontario regional Council must as soon as possible.
  10. the
  11. If a player will miss the turn three times in succession, he loses and his opponent wins, respectively.
  12. the
  13. If a player misses six moves during the game, he loses and his opponent wins, respectively.
  14. the
  15. a Draw is impossible. One of the players in any case, set the flags correctly faster than the other.
  16. the First move goes to a random player. the

  17. the Player may surrender at any point in the game.

Also developed a number of characteristics of a minefield for the game:

    Undermining at the opening of the first cell in the beginning of the game impossible.

    the Mines are uniformly distributed on the playing field. the

  1. Properties of "emptiness" to be opened after the first click:
      the
    1. Size from A to B, empty cells (0 mines around).
    2. the Void must not be a line of open cells only at one side of the orientation.

      mine the Percentage of cells (controller type — material) and the size field adjusted in the app settings.



    Thus, in the current configuration, the first click opens the "void" from 3 12 "zero" cells and the size field 32x20.

    Sorry for the huge number of lists, however, can not fail to mention that the game in addition has the following functionality:

    the
      the
    • chord — open more than one cell per turn. This is possible in case of a click (LMB) on the figure in the cell on the playing field, and the number of flags around the four adjacent cells equals the required number.
    • the
    • Help the opponent — middle mouse button or [click the nick of the opponent from the top+click on the desired cell]. Appears green:
      image
    • the
    • Chat between players in real-time.
      image
    • the
    • in-game Nickname.
    • the
    • Sound in the game.

    the

    Technology


    Full list of technologies used in product development, the following:

    the

      C# .NET + ASP .NET – the basis for web servers.

      HTML5 / CSS3 – to develop the interface of the client part.

      JavaScript – dynamic client side.

      JSON – for serializing/deserialization packages client-server.

      WebSocket Protocol is used as communication method to the client server.

      HTML Canvas is a technique for rendering a minefield.

      jQuery – effective and rapid interaction between HTML and JS.

      JSON Newton a library for easy work with JSON.

      Adobe Photoshop – for rendering graphical user interface elements.

      GitHub – as a convenient platform for version control of the project.

      Microsoft Azure – to embed a web server on the Internet.

      Yandex.Metric – statistics and analysis of player behavior.

      CloudFlare – as a CDN-proxy / SSL / Anti DDoS.

      Microsoft Visual Studio – as the primary development environment.

      Sublime Text – as a tool of development under JavaScript.

      Microsoft IIS – to expand the ASP. NET


    image

    By the problem areas in the project were the following:

    the
      the
    • Synchronize players with each other

      the

        Problem: how to notify players about changes in the field?
        Options: long polling; websockets; cyclic polling; etc

        Solution: to use WebSocket


    • the
    • Rendering minefields and other elements of the game

      the

        Problem - which tools are most appropriate?
        Options: HTML table/div; SVG; HTML5 Canvas; etc

        Solution: HTML5 Canvas + JavaScript


    the

    Interesting facts


    the

      23 man in less as participated in testing.

      183 298 clicks made on the field during testing. the

    • With 119tries minefield has been passed through.
    • the
    • Box size 32x20 is optimal for the game (empirical observation).
    • the
    • From 3 12 "zero" cells it is best to open when first clicked (theempirical observation).

    And attach a map of clicks from Yandex.Metrics, it is possible to make a number of interesting conclusions. For example, it is obvious that the main area of the "battle" is the center of the field, and chat popular.

    image

    the

    future Plans


    In the future I want to finish the following functionality:

    the
      the
    • to Implement the room for N players.
    • the
    • Possibility of creating a "friendly room" (a game with a friend via the link) and single mode.
    • the
    • Registration of players and leaderboards.
    • "Balance skill" (so that players play with equal experience). the

    • Optimizing applications for mobile devices.
    • the
    • to move to more powerful servers to implement the application to the masses.
    • the
    • create a bug-tracker.
    • the
    • easy Implementation of feedback from players.
    • More detailed usage statistics.
      the

      Conclusion


      image
      In conclusion I want to say — please be careful with your game server :)
      He received a free subscription from Microsoft Azure, and its capacity is extremely modest.
      I sincerely hope that after this article we will be able to enjoy this game.
      I remind you that it is available at https://rmsweeper.com and also have community in "Vkontakte".

      Thank you for your attention,
      You was Peter.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

ODBC Firebird, Postgresql, executing queries in Powershell

Installation LivestreetCMS on MODX Revolution package 10 clicks

The Ministry of communications wants to ban phones without GLONASS