GithubHelp home page GithubHelp logo

snake's People

Contributors

spaceface16518 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

xsh0223

snake's Issues

Food spawn protection could cause infinite hang

This should never happen in practice because it implies that the snake is covering every single tile available. It is a possibility, however, and therefore should be tracked, if nothing else, as a low priority issue.

The real danger with this issue is that the spawn time of the food tile will increase as the number of tiles covered by the snake increase. This shouldn't be a problem besides if a bot or very skilled player advances to a level in which the lag from trying again and again to spawn a food tile makes it hard to play the game. Until that happens, this issue will remain a low priority one.

This issue was caused by code introduced in 89ea28c in order to mitigate #3.

Food can spawn in body

Since food spawning is completely random, it can easily spawn on the snake's body. This can be prevented by checking if a potential spawn location for the food overlaps with the snake's body. The downside to this is iterating over the snake an additional time every time we want to spawn a new piece of food.

Snake speed can reach infinity

This will probably never happen unless it's a bot playing or something, but it could theoretically happen, so this should be an endgame state as well
#6 (Endgame state)
#7 (Food should increase speed)

Snake can still go backwards

By quickly pressing two different keys, the player can move back into itself.

For example, quickly pressing Right and then Up while moving the direction Down will cause the player to move Up into itself and die.

This is caused by the key event state being out of sync with the update logic.

The issue could possibly be fixed by either storing an extra direction which would represent the actual direction that the snake is traveling or to remove redundancy, checking the snake's head's direction instead of an arbitrary state that is not actually attached to the snake. If the second route is chosen, GameState would retain its current state field input_direction which would be read by update when choosing a direction and written to by key_down_event, but key_down_event would read it's "state" by getting the direction from the snakes head (self.snake.head().direction() where self is an instance of GameState).

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.