Coder Social home page Coder Social logo

snake's Introduction


Snake

Simple game of snake coded in static HTML, JavaScript, and CSS

Basics

  • Press space to start, pause, and restart.
  • Use the arrow keys and / or W A S D, to control directions.

Intended use

Used for a Neural Expected Sarsa Reinforcement Learning Agent to train. But it is also coded so that the game itself is playable by humans as well.

More information and repo of the training agent can be accessed here.

Dots bar

The line of dots above the main play grid is used for the AI agent to both calibrate the vision system and convey additional state information.

Calibration

The leftmost dot is the calibration dot, all subsequent locations for pixel readings are based on the calibartion dot.

State Info

The middle 4 dots indicate the direction of the snake. From left to right, each dot indicated, up, down, left, and right respectively.

The rightmost dot indicates whether if on that exact frame, the snake comes in contact with the orb. If so, the dot will flash a brighter shade of red.

Gallery

Dark Mode 11 x 11 Grid (default) 9 x 9 Grid
7 x 7 Grid Setting Menu
Light Mode 11 x 11 Grid Setting Menu

Game Settings

Game Speed

  1. Easy Mode
    • Frame Speed: 500 ms per frame
    • Score Multiplier: x0
  2. Normal Mode (default)
    • Frame Speed: 300 ms per frame
    • Score Multiplier: x1
  3. Hard Mode
    • Frame Speed: 100 ms per frame
    • Score Multiplier: x2
  4. Insane Mode (indented for AI Training)
    • Frame Speed: 50 ms per frame
    • Score Multiplier: x3

Grid Size

  1. 11 x 11 (default)
  2. 9 x 9
  3. 7 x 7

Score Keeping

When the snake eats an orb, a value (depending on difficulty) will be added to the total score. Score calculation has to components, the base score and the multiplied score. The base score is 50 and the multiplied score depends on the selected speed of the game.

Score Multipliers

The value of the score multiplier is 50, with a base score of 50, the multiplied speed of each difficulty is as follows

  • Easy: 50
  • Normal: 100
  • Hard: 150
  • Insane: 200

High Scores

For each difficulty and grid size, a separate high score is kept and stored in the browser's local storage

snake's People

Contributors

lochungtin avatar

Stargazers

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