Skip to content

How should the speed levels in the turtle crate work? #180

Open
@sunjay

Description

@sunjay

The Python turtle module has 10 speed levels. The turtle crate started with 10 speed levels, but after getting impatient with how slow many drawings were, I changed that to 25 speed levels.

Recently, while working on the new architecture in #173, I realized that because of physics (time = distance / speed) and because of IPC latency, there is a limit to how much increasing the speed can decrease the time it takes to draw an image:

speedtest_orig
Image generated with data collected from examples/speedtest.rs before the changes in #173

As you can see, after level 10, changing the speed impacts the time less and less. This is frustrating as a user because it means that 15 of the speed levels are pretty much useless. In #173, I rewrote the code so that changing the speed has a linear effect on the time:

speedtest
Image generated with data collected from examples/speedtest.rs after the changes in #173

I thought this would be better, but it turns out to be even worse because now there is barely any visible difference between speed levels. The difference is always the same, but that turns out to not be all that intuitive because I guess our brains expect the time = distance / speed equation from physics.

Proposals

Proposal 1: We should go back to having 10 speed levels, just like the Python turtle module. We should set the speed to increase linearly and go back to time = distance / speed. We can play with the graphs shown above until we get a curve that provides a reasonable distribution of different times. Having two speed levels that result in almost the same time isn't very useful.

Proposal 2: Instead of a hardcoded set of 10 levels, the speed should become an actual quantity in pixels / second (or some other unit). That way the user is free to set their speed to whatever they want and there will be no limits. I like this idea because of the flexibility it provides, but it will be breaking compatibility with the Python turtle module and other turtle implementations. (Compatibility isn't an explicit goal, but it is nice to have.) It's also important to note that the speed value is used for rotation too, so we may have to think about how to map a speed to both px / sec and rad / sec.

So far, I am leaning towards Proposal 2. I think it's better to make that kind of breaking change now and give users the most flexibility. We will still have the speed strings (e.g. "slow", "normal", etc.). That means that there is an easier to teach option in addition to all the flexibility. We may even be able to come up with something to make that proposal backwards compatible so we would have both the speed levels and the ability to specify an absolute speed in px / sec or rad / sec.

Thoughts on as well as alternative proposals for what we should do are welcome.

Questions

These are questions that need to be resolved by the end of this:

  • What are the speed levels (if any)?
  • What speeds in px / sec do the speed levels map to?
  • What speeds in rad / sec do the speed levels map to?
  • What speeds do "slow", "normal", "fast", "faster", etc. map to?

The code, examples, and documentation then need to be updated with what we decide.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions