Giter Club home page Giter Club logo

concurrent-implementation-of-j48-via-weka's Introduction

Online Snake Game

References:
Jenkins: 34.89.51.152:8080
Flask: 34.76.185.11:5001
Pytest-coverage: 34.76.185.11:5001/coverage
Trello-board: https://trello.com/b/Ek1HhDcU/individual-project-plan
Presentation: https://docs.google.com/presentation/d/1FVA6l7NiQrynJE3OerSMeHe9xMafuAoekVf3a9gu3Sg/edit?usp=sharing







Original Project Idea

Allow a user to register then login, play a snake game which would record their score and save onto a database, and allow the user to view his scores as well as the user with the highest score.

The snake game would involve user manipulating an entity on a arena, the user would be able to collect fruits which would increase the length of the snake entity, and increase the user's score. If the snake entity hit the edge of the arena, the game would be over.

Original ERD diagram

ERD diagram Player would have a one to many relationship with Scores.
Account details would have a one-to-one relationship with Player.


Original Use Case Diagram

use case diagram

What I got

The Use case and the functionality of the original project idea is essentially completely intact to that of what I had envisioned, however I have decided to change the database as I thought one of the tables was redundant.

New ERD diagram

ERD new diagram Now there are simply two tables with Account details filling the void of what Player table was doing previously.
Account details has a one-to-many relationship with Scores table.

Had to switch to websocket for game connection

During development, I used Ajax requests from the client to poll the python flask server for information on the state of the snake game. This, I later realised, proved to be flawed because if the server location happened to be too far away (e.g from Manchester to Finland), the Ajax requests would not be processed as the connections kept dropping at almost 100% of the time.
After thinking about the issue, I realised websockets would fix my problem and should also make the interaction between client and server smoother, so I went ahead and re-did the implementation of how the client would poll the server for information. It instead now uses a communicational system wherein after establishing a session, the client asks for information and waits for the server to respond, once the server responds, the client processes the information and sends another request for newer information.

Testing

Testing was done using pytest and a coverage has also been supplied. Look at References for the link to the coverage.

66% coverage was achieved.
11 tests total have been created and executed; 3 of which were used to test the snake game, and the rest were used to test the website and database functionality.
Coverage may further be increased if integration testing could be performed, such as using Selenium to test the more user-dependant functionalities such as being able to login, test the forms, test the jinja2 code, etc...

The snake game is an interesting creation. It is a simple application, however it is multi-threaded, meaning that conventional testing schemes such as Unit testing or Integration testing may not fully apply due to the nature of parallel systems. Ideally you would use a test package suited for multi-threaded testing, such as some sort of spec=flow analysis which would calculate all possible states each of the threads could be in to see whether a deadlock or a livelock has occured.
However, I have still included some minor tests for the snake game specifically by creating an instance of it and simply waiting to see what would happen. In theory, after a certain amount of time, the snake would hit the outer edges of the arena, thereby changing the game state variable which I would then be able to test.

Deployment Overview

techs used Made a webserver application using Python, MySQL, and Flask. Used git and github for version control whilst using Trello to organise myself. Github would submit requests to Jenkins to update, test using pytest, and redeploy the application. Finally, the cloud provide, GCP, was used to host the application.

Technologies used:
Python/Mysql/Flask
Git/Github
Trello
Jenkins
Pytest
GCP

The Future

Many things could be improved. For example, I am not really sure how multi-threading is done under the hood in Python, so whether my snake game is thread safe is unknown at this point, so more research would definitely help. In terms of looks, the website looks pretty barebones, perhaps integrating a front-end View framework such as Bootstrap would be a good idea.
Further expanding the game would be interesting, such as adding multi-player functionality wherein two snakes would be in the same arena, and the one that hits the others' tail loses.

For the snake game, the implementation of how it is streamed to the client is a bit cumbersome, currently the client asks for the entire grid information every request. I believe the best solution to this problem would be to implement the actual game on the client-side, and then simply hash the snake game source code and send it to the server every half a minute or so, the server would then verify the hash and if there was a difference, the score would not be submitted when the player finished playing. This would drastically reduce the load on the server, and make the game much smoother to play.

VM starter script

sudo adduser --disabled-password --gecos "" jenkins
sudo sed -i '21i jenkins ALL=(ALL:ALL) NOPASSWD:ALL ' /etc/sudoers
sudo su jenkins
sudo adduser --disabled-password --gecos "" pythonadm
sudo sed -i '4i export MYSQL_USER="root" ' /home/pythonadm/.bashrc
sudo sed -i '4i export MYSQL_PASSWORD="Pame121295" ' /home/pythonadm/.bashrc
sudo sed -i '4i export MYSQL_HOST="x.x.x.x" ' /home/pythonadm/.bashrc
sudo sed -i '4i export MYSQL_DB="proj" ' /home/pythonadm/.bashrc
sudo sed -i '4i export SECRET_KEY="qqwertyuiop[asdfghjklzxcvbnn4567" ' /home/pythonadm/.bashrc
sudo sed -i '4i export MYSQL_DB_TEST="proj_test" ' /home/pythonadm/.bashrc

cd ~/
mkdir .ssh/
cd .ssh/
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCos2iV15xPvHycVYSPIIHZ5cmBLRz83stLpENn1HmUzBgG4qscSAsS9/0tcN56KLYC6Ry0rqHYsko89LWWWKKv9RF1SjDDM+VbbQipxASVJD71LOfLgSplsZJg+KzFxdpiVkPNRIz9EmX4A/44rg3Gj2gy8XwJL30LvZkmkB3Lp78e3N07oeeyVcwJ1op9+Uw/zEmsTOrk3xvlxw9seB7Q9eurY53mLZN6C5J+ttPPUacFQMxkzmzNLP8UHoHfVA4PgNJYrc+RPk6PQ7DZ/AXiTcXjVFkTCC0eWfkRxEBkt86xo0dOq3NMYm9MYJ0lEpGEtqZRW/qZdozPRciPEXox jenkins@jenkins-proj2" > authorized_keys​

concurrent-implementation-of-j48-via-weka's People

Contributors

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