Skip to main content

A python library for generating random turtles using a hash seed (and for generating seeds/colors)

Project description

SeededTurtle

SeededTurtle is a Python library that allows you to generate random turtles with various properties. It's a fun and creative way to explore the world of programming with Python's turtle graphics. The idea is that the randTurtle function takes a seed as input and produces a resulting "randomized" turtle graphic when you run the program.

The turtle graphic randomization is reproducable based on what the seed is, so if you enter in "iloveturtles" as the seed two seperate times, it will return the same turtle. The library also provides support for randomizing this seed, so you can call the function to get a random seed and use that as the seed for generating a random turtle.

Installation

To install RandTurtle, you can use pip:

pip install randturtle

Usage

The main function in the RandTurtle library is generateRandomTurtle(). This function generates a turtle with random properties based on the provided seed.

Here is an example of how to use it:

from randturtle import generateRandomTurtle

# Generate a random turtle
turtle = generateRandomTurtle("your_seed_here")

The generateRandomTurtle() function takes the following parameters:

  • seed: A string of 16 or more alphanumeric characters or special characters (!@#$%^&*()). This is used to seed the random number generator for the turtle's properties.

  • time (optional): The time in seconds that the turtle will be displayed for before doing anything else. Defaults to 0.

  • fill (optional): The fill color of the turtle. Can be "none", "random", or a string of three comma-separated integers in the format "R,G,B". Defaults to "none".

  • color (optional): The color of the turtle. Can be "random" or a string of three comma-separated integers in the format "R,G,B". Defaults to "random".

If invalid parameters are passed in, the function will raise a RandomTurtleValueError.

For seed randomization as well, simply do:

import seededturtle.randturtle as rt

# Generate a random turtle using a random seed
turtle = generateRandomTurtle(rt.generateRandomSeed())

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Dependencies

random, turtle, regex, and time.sleep().

Known Issues

The fill only works when there is enough iterations to make a complete loop for the shape. Otherwise, the turtle library cannot fill an incomplete shape because there is no closed object. This isn't exactly an issue, but more something that the user needs to understand before trying to enable filling for their random turtle.

Notes from the creator

This was my second python library deployed (I also created chainhashing), so I still have lots to learn. I know there are probably a few issues with the library/optimizations that could be made, but hopefully people looking to use this library still find use out of it! Any advice/change recommendations are greatly appreciated; feel free to email me at rt.kellar@gmail.com or open an issue on the GitHub page for this library, https://github.com/Ruxton07/SeededTurtle. Enjoy!

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seededturtle-1.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seededturtle-1.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file seededturtle-1.0.1.tar.gz.

File metadata

  • Download URL: seededturtle-1.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for seededturtle-1.0.1.tar.gz
Algorithm Hash digest
SHA256 950a59383465d805266c82e0ebad6ef5a1f087188d77f1e9763984ddab2ab7fe
MD5 b84762ec88c791e932bee004e1e93534
BLAKE2b-256 9c905269377f6a8cd9654005e121ced228fab900e05204cb5a732a75190a45e8

See more details on using hashes here.

File details

Details for the file seededturtle-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: seededturtle-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for seededturtle-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c9755613044dead61656a12091e38a4fc59be622f48ed6fa7d3b3df5b0fac59
MD5 a14fd3c7e8187ef670b72c2a26dfa29e
BLAKE2b-256 de2d5a2a0189be02900516f50af1e2a5da1bda642c6c872591a5696571494d66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page