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

possible issue with character and step count #89

Closed
MathFreak314 opened this issue Jul 18, 2024 · 3 comments
Closed

possible issue with character and step count #89

MathFreak314 opened this issue Jul 18, 2024 · 3 comments
Assignees
Labels
bug Something isn't working editor Code editor, error messages, control panel, etc. question Further information is requested

Comments

@MathFreak314
Copy link

I am going to write in such a was to try and avoid spoilers.

I am attempting to get all the star challenges and have ran into a possible issue for the challenges for Levels 4 and 22.

Level 4:
For this one we are supposed to get a character count of 84. The hint for character count says that whitespace like space/tab/newline and comments don't count. However by doing some testing I found that the following code gets a character count of 8 however if you count the actual characters there are only 7.
`fn f() {

}`
I am wondering if there is something causing the character counter to miscount when functions are involved.

Level 22:
for this one we are supposed to get a step count of 18 or fewer. However I noticed that when you run your code it starts are a step count of 1 so it seems like there may be an off by 1 error here.

@albrow
Copy link
Owner

albrow commented Jul 20, 2024

Hi @MathFreak314 thanks for your feedback and hope you are enjoying the game 😄

FYI for anyone looking at this in the future because the level numbers/names might change:

  • Level 4 is referring to the level called "All By Yourself"
  • Level 22 is referring to the level called "Malfunction Detected"

Level 4:

Okay this is going to be really in the weeds but bear with me. In most programming languages there is a difference between significant and insignificant whitespace.

  • Significant whitespace is space that is required for the code to run. For example, in Rhai, the language used for Elara, you need to have a space between the fn keyword and the name of the function. If you don't have this space, then your computer isn't able to tell what you are trying to do. You might see a syntax error or unexpected results.
  • Insignificant whitespace is space that is not required. An example of insignificant whitespace in Rhai is the newline after the opening curly bracket of a function ({). It is conventional to add a newline after the bracket but technically not required and the computer will still understand what you're trying to do if you omit it. Try it yourself! You can see the code runs just fine.

The way character counting works in Elara is that it uses the compact_script function provided by the Rhai crate. Since Elara is open source, you can actually see the code for this! The compact_script function eliminates insignificant whitespace but leaves significant whitespace in tact. That is why you are seeing the behavior you are seeing.

Now the question is... should character counts in the game work this way? The reason to not count insignificant whitespace and comments was that I wanted to make challenges fun and interesting. I want players to find creative ways to think outside the box and shorten their code. Incentivizing players to just remove newlines, tabs, and comments doesn't sound very fun to me. I think that still makes sense and insignificant whitespace should definitely not count.

Should significant whitespace count like how it does now? I'd need to think about that a bit. It might be less confusing since players could manually count the characters in their code without worrying about significant vs. insignificant whitespace. But since you can always look at the character count in the bottom right of the code editor, I'm not sure how many players are counting manually. Changing this would also have a possibly unintended side effect of incentivizing players to avoid using syntax that requires significant whitespace- e.g. functions, if statements, for loops.

Either way, you're right and something should change here! I will either change the way character counts work to include significant whitespace or update the in-game explanatory text to clarify that significant whitespace is counted.

Even with the way character counts work now, I promise there is a way to beat the challenge for level 4. Though to be fair, it is a little bit obscure and I'm considering removing or changing this particular challenge. If you want a clue, pay close attention to the data points in the final level of the game 😉 If you still can't figure it out from there, here is one final hint:

(Click to show challenge hint) There is a solution for every challenge in the source code. On every major release of the game, there is an automated process that tests these solutions to make sure they work. That way, I can be sure that all the levels and challenges in the game are beatable and I didn't break any of them.

Level 22:

You're absolutely right! I should change the step counter to be more intuitive.

Technically under the hood the first "step" of every level is just the initial state. The simulation that runs under the hood has to start somewhere, so that's why you're seeing what you're seeing.

But what I should do is change it so that this first "step" is called "step 0" instead of "step 1". That way if you count how many times G.R.O.V.E.R. moves or takes an action it will match the number of steps that you see on the screen. I think this will make the step counter more intuitive for players. I would also have to go back and adjust all the challenges accordingly.

But just like level 4, this challenge is definitely still beatable as-is. During playtesting, one player even surprised me by beating this level in just 14 steps! Just like with level 4, there is a clue for this challenge hidden in the data points on the final level of the game 😉

@albrow albrow self-assigned this Jul 20, 2024
@albrow albrow added bug Something isn't working question Further information is requested editor Code editor, error messages, control panel, etc. labels Jul 20, 2024
@MathFreak314
Copy link
Author

MathFreak314 commented Jul 20, 2024 via email

@albrow
Copy link
Owner

albrow commented Nov 11, 2024

Hi @MathFreak314 it took longer than I expected to find time to work on this, but both these issues are now fixed in the dev branch and will be included in version 0.8.0 of the game when that releases.

  • The step counter will start at 0 instead of 1. This means counting the number of steps is more intuitive.
  • I updated the tool tip that describes how code length is calculated to make it more correct (though opted not to delve into the technical details of significant vs. insignificant whitespace).

Cheers, and thanks again for sharing your feedback and reporting these issues 🙂.

@albrow albrow closed this as completed Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor Code editor, error messages, control panel, etc. question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants