question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Game crashes when snake fills up board

See original GitHub issue

When you beat the game you get:

Uncaught TypeError: Cannot set property '-1' of undefined
    at SNAKE.Food.me.randomlyPlaceFood (snake.js:541)
    at SNAKE.Board.me.foodEaten (snake.js:981)
    at SNAKE.Snake.me.eatFood (snake.js:365)
    at SNAKE.Snake.me.go (snake.js:334)
    at snake.js:335

In the console, and the game freezes.

edit: The line numbers are off since I was making changes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
patorjkcommented, Oct 2, 2019

Sure!

0reactions
Cotehcommented, Oct 18, 2019

Just reproduced with small board size, snakeSpeed of 500 (the higher the slower, interesting…), and growthIncr of 1. I get the following (removed absolute path from .js filename for brevity):

TypeError: playingBoard.grid[row] is undefined snake.js:535:56
    randomlyPlaceFood js/snake.js:535
    foodEaten js/snake.js:989
    eatFood js/snake.js:357
    go js/snake.js:326
    go js/snake.js:327

Will look into it further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apex Crash - Code:Snake/Leaf - Answers HQ
So yesterday after a few games my game began to crash leading with weird Code goes by Snake/Leaf After a few more tries,...
Read more >
Pygame seemingly crashes with no error message
I'm working on creating an AI to play the classic game Snake, and have implemented it somewhat successfully, ...
Read more >
Programming Projects for Advanced Beginners #5: Snake
In Snake, the player pilots a snake around a grid, trying to eat apples and avoid crashing into walls or their own tail....
Read more >
Game breaking bug/crash building snake year 2 - GameFAQs
So I'm at the beginning of Year 2 and to get to the next level I'm in Hogwarts and have to parseltongue a...
Read more >
Killing snakes makes game crash. - Green Hell
Killing snakes makes game crash. Every time i kill a snake it crashes my game. Tried to kill with axe, stone knife, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found