Skip to content

A Twitter Bot that generates images using mathematic functions

Notifications You must be signed in to change notification settings

abrightmoore/TrigonometryBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TrigonometryBot

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

Sample output Sample output

How to build

  1. Copy the files into a new directory
  2. Install Python 2.7
  3. pip install pygame
  4. pip install pillow
  5. pip install TwitterAPI
  6. pip install imageio
  7. On windows, run the included .bat file which will create required subdirectories and start the bot.
  8. Over time, the image folders may become large. Monitor their size and rename them or archive them to re-initialise.

Dependencies

  1. [Jan 2018: No longer required] markovbot from @esdalmaijer. Use for witty conversation. Get it via: https://github.com/esdalmaijer/markovbot
  2. TwitterAPI by @boxnumber03. Wrapper to communicate via Twitter. Get it via: https://dev.twitter.com/resources/twitter-libraries
  3. PIL - use pip install Pillow or similar.
  4. There are some test harnesses in this project which use PyGame
  5. 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.
  6. 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.

How it works

  1. 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.
  2. ImageFactory.py is the image rendering router.
  3. 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".

Sample output

Generators

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:

  1. Gen_ConwayLife.py - Artificial Life in various flavours. Also an animated gif created in the local file system.
  2. Gen_Graph.py - An X-Y plane with points plotted from the Gen_Trigonometry methods.
  3. Gen_InterferenceImage.py - Like those ink-pictures you used to do in primary school to make book covers.
  4. Gen_InterferenceImageIterated.py - Lots of blended interferance images.
  5. Gen_IteratedFunctionSystem.py - Fractals that converge.
  6. Gen_Lyapunov.py - Chaotic attractors. Swirly things.
  7. Gen_Mandelbrot.py - THE Mandelbrot. This generator randomly selects a zoom level of detail on the edge of the set
  8. Gen_Maze.py - Amazing mazes
  9. Gen_Popcorn.py - fizzy fractal fields
  10. Gen_Stars.py - overexposed star-like clusters
  11. Gen_Trigonometry.py - Colourful canvases where each pixel is an iterated series of math functions driven by the pixel x/y coordinate values

To Do / Wish list

  1. Conversation management - who is the Bot interacting with, what is the conversation 'about' and what art is being iterated over.
  2. Memories - categorise images and their 'likes' so the best work can be extended over time
  3. 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.
  4. Mood - colourful dynamic art when happy, moody bleak art when feeling ignored by the community.
  5. Prevent conversation loops - at the moment I have to block conversation partners to stop a lengthy exchange.
  6. Automatically post to Instagram, where @TrigonometryBot also lives.
  7. Re-host in the cloud for a more reliable service with redundancy. This will require major work to optimise the code.
  8. Better interaction with online friends and their images.
  9. Animations.

About

A Twitter Bot that generates images using mathematic functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages