Git Product home page Git Product logo

data-structures-game's Introduction

The Data Structures Game

The Data Structures Game is a competitive online game. The goal of this game is to help reinforce data structures concepts to students. Players will be able to take turns and test their data structures prowess as they try to free the golden node. Correctly maneuvering your way through the AVL tree will reward you with points. Test yourself against your friends, both in the lobby and on the leaderboards!

Developer Installation

  1. Install Anaconda
  2. Create a minimal-empty Python environment:
  • conda create --name dsg python=3.8.5
  • source activate dsg (or conda activate dsg). Note that dsg is just a name. You may choose differently. The rest of the documentation assumes you named the environment dsg.
  1. Install NodeJS for React (make sure you are in dsg):
  • conda install nodejs
  1. Add the local environment variables to your path. The environment variables include the secret keys needed to run the software. Contact the development team
  • Mac
    • nano ~/.bash_profile and add the variables at the bottom. Close, and save.
    • source ~/.bash_profile to use the changed bash profile.
    • source activate dsg to change it back to the virtual environment (or conda activate dsg).
    • env to check the variables. It should print them on the console.
  • Windows
  1. Clone the repository:
  • git clone https://github.com/MaksimEkin/data-structures-game.git
  1. Install the libraries needed by the project using the requirements.txt located at the root directory of the project file you cloned (make sure you are on dsg):
  • pip install -r requirements.txt
  1. Install the NodeJS libraries used by React:
  • npm install
  1. Front-end makes API requests to Heroku. When the project is run locally, this results in cross origin calls from localhost to Heroku domain. Cross-origins calls are blocked due to a header that is in place to protect against XSS attacks. To run the code locally, you will need to change the API call url.
  • Open src/Components/GameBoard.js to edit/
  • Change const url = remote; with const url = local;. Code.
  1. Build the front-end:
  • npm run build
  1. Run from the root directory of the project:
  • python manage.py runserver and visit http://127.0.0.1:8000
  1. If you recieve security warnings resulting from Mimetype or cross-origin, run with below instead:
  • python manage.py runserver --insecure and visit http://127.0.0.1:8000

Developer Test Suites

  • Game Board API

    • Located at game_board/api/tests_api.py
    • Run from the root directory of the project with python manage.py test game_board.api.tests_api
  • Profile Page API

  • Homepage

    • Located at home_page/api/tests_api.py
    • Run from the root directory of the project with python manage.py test home_page.api.tests_api
  • Game Board Database

  • User Profile Database

  • Home Page Database

  • AVL Data Structure

    • Located at game_board/avl/test_avl.py
    • Run from the root directory of the project with python manage.py test game_board.avl.test_avl
  • Front-End Cypress Testing

    • Located at cypress/integration
    • Run using Cypress, which can be started with npx cypress open
    • Once Cypress is running, select any tests that the Cypress-generated GUI displays to run them
  • Front-end Text Diplay Tests:

    • Note: Developed to be run on Safari. In Safari under the Develop menu Allow Remote Automation. Then change the remote url variable to local in GameBoard.js. Build the project with npm run build, and run Django python manage.py runserver. Tests can be run from src/Tests.
    • Test 1: python -m unittest test_player_display_text.py
    • Test 2: python -m unittest test_node_text.py

See Wiki for details.

data-structures-game's People

Contributors

kulriz avatar maksimekin avatar naomi-albert avatar ryancb4 avatar solonick avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

data-structures-game's Issues

[8] Display a graph as a tree and allow drag and drop.

Integrate graph from react digraph library.

Created component for graph page to display the graph -Kulsoom
Routing for graph display component onto /game_page -Kulsoom
Configuring graph functions to reflect tree structure with API returns - Maksim

The current data structure should be able to change to another one while preserving the state of the nodes.

New data structures (DS) are introduced to the game as feature updates. When new DS added to the game, the gameplay will allow users to be able to choose a specific DS to play with, or enter a game where the DS changes every n minutes or turns. However, when the DS changes, we do not want to just create a new set of random nodes. Instead, the nodes should be retrieved from the current DS following the rules of the current DS, and inserted into the next DS follow the rules of the next DS.

The game should be able to form a random data structure at the start.

A random graph should be generated when the game starts. The pseudo-random state of this graph could be determined by the current time or using an external API to generate a true random state.

  • API should return a set of randomly generated edges and nodes that form a valid AVL tree.
  • This AVL tree should have points on each node, and a single golden node (+infinity points)
  • Front end should be able to parse this graph and visualize it as a tree.
  • There should be a max depth for this tree depending on the level of difficulty of the game selected.
  • The position of the golden node must be carefully selected to not allow a game that can end in only one or a few turns.

[3] API Calls to parse the data structure

This is a developer story for the user story #18. It refers to the implementation of the API functionality needed to allow the delivery of the generated data structure to the front-en from the AVL implementation and the database storage.

As a user, I should be able to choose the difficulty of the game. On a lower level difficulty, the data structures problems will have less nodes and maybe easier requires manipulations. By contrast, a higher level difficulty will have bigger data structures with more variability.

Users should be able to choose the difficulty level of the game. The difficulty level of the game will determine the depth of the data structure (DS). The deeper the DS is, the harder and longer it will become to complete that game. Also, the golden node should be placed carefully to ensure that it cannot be retrieved easily for a harder game.

As a user, I want to be able to sign-up for the game, log-in to my profile, and log-out when I am done playing the game.

The game will bring the user to the home screen oft the game, where they will be able to play a game without logging in, which will not save any ranking data, or they will be able to log in through a button on the top of the screen to be able to have their scores tracked. Once logged in, the user profile button, also on the top of the screen, will allow the user to go to their profile. The log out button will similarly be on the top of the screen. When clicked, the button will redirect users from whatever screen they are on to the home screen.

The game should be able to verify valid and invalid actions that are being performed.

When the user performs drag and drop for a specific data structure action, the game should be able to compare the user's solution to the correct solution. When a wrong action is being performed by the user, the game should point out the specific nodes that are incorrectly placed in the tree and place them in the correct location while deducting points from the player.

Users should be able to play with others.

Users will be able to create lobby's and join the lobby's of other users. They may choose to host the lobby and provide a key to their friends on which the game can be accessed. Alternatively, the user may want to find a game. They may then join a lobby generated by another user. The purpose of the data structures game is first and foremost to help reinforce data structures concepts in students. The students may be in class, working groups, or perhaps studying together for an exam. For both of these scenarios shared games are important aspect of group learning.

Mockup (4)

[5] Create UX for homepage

Kulsoom-added routing to the different front end urls to route to homepage '/'
Kulsoom - added components for the home page UI
Kulsoom - modal for login
Maksim- added background react particles

[5]AVL Data Structure Balancing Inconsistency

In certain cases, the AVL tree becomes unbalanced but is treated as balance by the game state

In sprint II I will hunt down this bug and create new AVL unit tests to verify the expected AVL behavior

As a user, I should be able to reset my password.

In the user's profile page, there will be a button to reset the password under the saved games. Resetting the password will ask the user for their current password, and if correct will allow the user to enter and save a new one.

[5] API calls for specific card actions and drag and drop update actions.

This is a developer story for the user story #14. Similar to the developer story #46, this developer story refers to the communication needed between the front end and the AVL implementation which is stored as a game board instance in the database. Differently, this developer story refers to the implementation of the actions that the front-end can request to take on the data structure, and how that action affects the state of the game board.

As a user, I should be able to search and add as friend other players in the game.

There will be a search bar in the bottom right of the screen for all screens. The search bar will allow players to search for usernames of people in-game, as well as people they meet IRL using the app. After a successful search, the user can select to follow the user (which will send a follow request to the other person). Allows for 1-way connections if one wants, while also prompting for a mutual connection.

As a user, I want to be able to share the state of the game with a friend, or export to be shared view other means.

There will be a save game button in gameplay that takes the current state of the data structure and saves it to the user's profile.
When downloaded from the profile, it creates a text file that the user chooses where to save on their computer. The file can then be sent to other players through whatever means of communication the player chooses. The file will be able to be loaded from the main menu of the game. See issue #10

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.