Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and correct bar logic #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tofof
Copy link

@tofof tofof commented May 10, 2022

Fun's printLevelVertical is doesn't ever display single bars, only double bars.
That's because its logic is bugged:
The first conditional checks barsOn-2*i+1 >=0 which means that when that's false, the second conditional is always false as well --- if it's not >=0 it certainly won't be >=1. In this logic, the second conditional needed to be -1.

Instead, I simplifed the logic so that the value being checked in the conditional corresponds directly to the number of bars to light (2 or 1). This solves the problem and has the benefits of reducing the terms in the conditional and making them directly relevant, all of which improves readability.

Closes #59.

Logic is intended to check how many bars to draw by examining 2 bar positions at a time.

Previous version the second conditional was always false (because if barsOn-2*i+1 is not >=0 in the first conditional it certainly won't be >=1 in the second. Instead of >=1, the second conditional needed to be >=-1 in the prior logic.

Simplifying the logic so that the value being checked in the conditional corresponds directly to the number of bars to light solves the problem and makes the flow much more directly understandable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

printLevelVertical only prints double bars, never single bars
1 participant