A Twitter Bot that generates artistic images using mathematic functions
Check its work on Twitter as https://twitter.com/TrigonometryBot/with_replies
TrigonometryBot is implemented in an extensible and modular fashion allowing new picture drawing functions to be added by creating a single new Python file that implements the 'draw(image)' method, where image is a PIL image.
Tweet text is modified from "College Geometry" by Carl Stitz, Ph.D. Jeff Zeager, Ph.D. available here: https://archive.org/stream/flooved3486/flooved3486_djvu.txt
- Copy the files into a new directory
- Install Python 2.7
- pip install pygame
- pip install pillow
- pip install TwitterAPI
- pip install imageio
- On windows, run the included .bat file which will create required subdirectories and start the bot.
- Over time, the image folders may become large. Monitor their size and rename them or archive them to re-initialise.
- [Jan 2018: No longer required] markovbot from @esdalmaijer. Use for witty conversation. Get it via: https://github.com/esdalmaijer/markovbot
- TwitterAPI by @boxnumber03. Wrapper to communicate via Twitter. Get it via: https://dev.twitter.com/resources/twitter-libraries
- PIL - use pip install Pillow or similar.
- There are some test harnesses in this project which use PyGame
- imageio is used for animated gifs. At the moment @TrigonometryBot will not post GIFs but I have them generated and it selects frames from the animation occasionally. You can see this in the Conway Life generator.
- I have not included my Twitter API keys. You put yours in a file called: AJB_TrigonometryBot_TwitterKeys.txt local to the script, with the order passed to the TwitterAPI constructor (basically the order on the form on Twitter's API form). Hit me up if you have issues.
- AJB_TrigonometryBot_vXX.py is the main module. It connects to Twitter and manages the work/sleep cycle. This bot is lazy so it doesn't get kicked by Twitter.
- ImageFactory.py is the image rendering router.
- test.py is a harness that generate local images for testing the image rendering methods before going live.
The main image routine is in 'beCreative()'. You can add more image renderers by placing them in the root directory where the program is running with a python filename of the form "Gen_{uniquename}.py".
Images are composed from different layers which are randomly invoked to lay down more pixels over the art work in progress. Here are some of the current generators:
- Gen_ConwayLife.py - Artificial Life in various flavours. Also an animated gif created in the local file system.
- Gen_Graph.py - An X-Y plane with points plotted from the Gen_Trigonometry methods.
- Gen_InterferenceImage.py - Like those ink-pictures you used to do in primary school to make book covers.
- Gen_InterferenceImageIterated.py - Lots of blended interferance images.
- Gen_IteratedFunctionSystem.py - Fractals that converge.
- Gen_Lyapunov.py - Chaotic attractors. Swirly things.
- Gen_Mandelbrot.py - THE Mandelbrot. This generator randomly selects a zoom level of detail on the edge of the set
- Gen_Maze.py - Amazing mazes
- Gen_Popcorn.py - fizzy fractal fields
- Gen_Stars.py - overexposed star-like clusters
- Gen_Trigonometry.py - Colourful canvases where each pixel is an iterated series of math functions driven by the pixel x/y coordinate values
- Conversation management - who is the Bot interacting with, what is the conversation 'about' and what art is being iterated over.
- Memories - categorise images and their 'likes' so the best work can be extended over time
- Seed based images. This used to be in the Bot but I took it out for reasons. I'd like to make the Bot deterministic again.
- Mood - colourful dynamic art when happy, moody bleak art when feeling ignored by the community.
- Prevent conversation loops - at the moment I have to block conversation partners to stop a lengthy exchange.
- Automatically post to Instagram, where @TrigonometryBot also lives.
- Re-host in the cloud for a more reliable service with redundancy. This will require major work to optimise the code.
- Better interaction with online friends and their images.
- Animations.