Git Product home page Git Product logo

minesweeper's Introduction

Minesweeper

Build Status Coverage Status

screenshot

A multiplayer online minesweeper game built with Django Channel and Vue.

Introduction

  • Vue is used for rendering the game graphics. But the priority for frontend is not high since it's much more important to guarantee bug-free backend, so webpack with live reloading is not set.

  • sqlite3 is used for prototyping. Postgres or Mysql may be used for production.

  • Websocket is used to provide a stable, low-latency, bi-directional connection. Users can play the game in their browser without noticing the game core is on the backend.

  • Django Channel is responsible for handling the requests from frontend, for example, when user clicks a tile and send the action to the server, Django Channel returns the new game data to the user. It also notifies the frontend actively when it detects data changing of game data in the database.

Run locally

  1. Create a Python 3.6 virtualenv
  2. Install dependencies
pip install -r requirements/dev.txt
bower install
  1. Create tables:
python manage.py migrate
  1. Run the dev server
python manage.py runserver

Test

Just run test

tox

You can view the coverage report with

coverage report

Deploy

Make sure you have migrated data and collected static files, the path ./static is used for storing static files.

docker-compose up

Map

Game data is composed of mainly two arrays, game_data and game_mask. Game_data is the underlying matrix that contains the 'true' data of the game, which should be hidden from users. So game_mask's responsibility is to keep track of the game's progress and reveal only the visible information to users. When we combine game_data and game_mask with some matrix operations, we can get a user_map which is passed to the frontend to be rendered by Vue.

Rendered game 1:

rendered-game

Corresponding data 2 (-1 means mine):

data

Rendered game 2:

rendered-game-2

Corresponding data 2 (viewed by user, -2 means hidden):

data

Special Tiles

  • Tile 0: tile -0

  • Tile -1: tile -1

  • Tile -2: tile -2

  • Tile -3: tile -3

  • Tile -4: tile -4

  • Tile -5: tile -5

minesweeper's People

Contributors

d8660091 avatar

Watchers

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