Change in boundary condition (line 87).#1
Open
jainayush362 wants to merge 1 commit intocoding-blocks-archives:masterfrom
jainayush362:patch-1
Open
Change in boundary condition (line 87).#1jainayush362 wants to merge 1 commit intocoding-blocks-archives:masterfrom jainayush362:patch-1
jainayush362 wants to merge 1 commit intocoding-blocks-archives:masterfrom
jainayush362:patch-1
Conversation
The last two OR ( || ) cases of 'if' condition at line 87 should have '>=" comparison instead of just '>' comparison. This is because, suppose the length of our snake is 5 boxes and we hit right boundary then as per '>' comparison then game gets over only when 1 box out of snake length (i.e. 5 boxes) crosses that boundary. But if we put '>=' comparison then the game gets over as soon as the snake touches the boundary. Similar case is with the bottom boundary. You can see it here: Snake represented by - ooooo ( length is 5) Case 1: If we use '>' Comparison |--------------| | oooo|o | | |_____________| This is how the game gets over using '>' comparison. Case 2: If we use '>=' comparison |-------------| | ooooo| | | | ____________| Same thing happens with bottom boundary. Please check it out because the snake can even change its direction near the boundary with '>' comparison.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The last two OR ( || ) cases of 'if' condition at line 87 should have '>=" comparison instead of just '>' comparison. This is because, suppose the length of our snake is 5 boxes and we hit right boundary then as per '>' comparison then game gets over only when 1 box out of snake length (i.e. 5 boxes) crosses that boundary. But if we put '>=' comparison then the game gets over as soon as the snake touches the boundary. Similar case is with the bottom boundary.
You can see it here: Snake represented by - ooooo ( length is 5)
Case 1: If we use '>' Comparison
OOOO|O
This is how the game gets over using '>' comparison.
Case 2: If we use '>=' comparison
OOOOO|
Same thing happens with bottom boundary.
Please check it out because the snake can even change its direction near the boundary with '>' comparison.