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

Support Multiple Turtles #16

Open
6 tasks
sunjay opened this issue Nov 8, 2017 · 1 comment
Open
6 tasks

Support Multiple Turtles #16

sunjay opened this issue Nov 8, 2017 · 1 comment

Comments

@sunjay
Copy link
Owner

sunjay commented Nov 8, 2017

Very low priority until all the drawing methods are completed. Postponed in order to keep the library's implementation as simple as possible while we are still figuring everything out. This will involve refactoring quite a bit of the behind the scenes code in the codebase. We'll have to plan out what those changes should be to meet all the requirements of this feature.

The idea is that we would have an API that looks something like this:

let mut window = TurtleWindow::new();

let turtle1 = window.add_turtle();
let turtle2 = window.add_turtle();
turtle1.forward(100.0);
turtle2.right(90.0);
turtle2.forward(100.0);

The animations would still occur sequentially in this example (one turtle would move at a time). Ideally we would like the turtles to be able to run in multiple threads so that multiple turtles can be drawing on the screen at once.

This feature is excellent for teaching parallel and concurrent programming.

  • Add reset() and clear() methods to Drawing that clear all of the drawings. The turtle reset() and clear() methods only clear that turtle's drawings
  • Are turtles cloneable? Would clone copy the drawings of the turtle or just its current state? (Position, angle, pen, etc.)
  • Does dropping a turtle delete its drawings? (Answer is probably no since each turtle is just a "handle" to data represented in the renderer but still worth considering)
  • Turtle needs to be Send in order for each turtle to be moved into a separate thread, having Turtle be Sync is probably not desirable
  • Add a examples/maze_multiple example that uses multiple turtles to draw the maze concurrently
  • Document that wait_for_click does not work for multiple turtles because it consumes events from the global event pipe

Note that this feature has nothing to do with async. There is a separate issue (#17) open for that.

@sunjay
Copy link
Owner Author

sunjay commented May 25, 2020

A large portion of the work for this issue was completed in #173. You can use multiple turtles if you compile turtle with the unstable feature. See the documentation for more information on how to do that.

Multiple turtle support is still largely experimental and has many bugs/performance issues that need to be worked out. Feel free to experiment and report back what you find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant