After seeing a couple of tutorials online for building twitter bots which looked simple enough and discovering the Dark Sky weather API, an idea popped into my head for a twitter bot which tweets the weather at the current time in a random city. The idea was also partly inspired by the fact that I have every city I've visited in the past few years in my weather app on my phone so I can always monitor them to satisfy my curiosity; so it's something I found interesting anyway.
The tutorial I ended up going with used Python, which meant using a language I'd never used before, but I felt confident the tutorial and help from Codebar Brighton would provide enough help with the syntax for me to be able to do it. The code itself ended up being surprisingly short, and was mostly developed during one 2-hour Codebar session.
The bot works by randomly choosing a line in a big file I have with every city in the world in it (3.2 million lines!) and plugging the latitude and longitude into the Dark Sky API to get a JSON file containing the weather information back. The tweet is then built with this information, and submitted using the Twitter API. I am currently in the process of putting the code on Heroku so I will no longer need to tweet manually using the commandline.
I'm super interested in space and a lot of my previous artistic work has been based around constellations and stars. With this in mind, when I discovered HTML5 canvas and procedural generation I decided it would be interesting to write a program that could generate new constellations. Eventually I would like this project to create a whole star map of a fictional sky somewhere containing many different constellations that perhaps even have procedurally generated fictional names as well.
So far the program generates one constellation every time the page is refreshed. Despite looking simple, the code required to generate something which actually looks like a real constellation and not just a collection of points and lines was surprisingly complicated. As I started writing the code I recognised the need for more and more rules, for example not allowing lines to intersect.
This code works by creating an array of star point and line objects. A star point is picked and then an angle off that point is picked and a new star point is placed at a random distance away and a line is drawn between them. This happens until 4-10 stars and lines joining them are contained in the arrays and those are then drawn to the canvas. At the moment the code sometimes breaks one of the rules if it cannot find any other way around and may intersect another line for example. I am working on these bugs before I then write rules to allow more than one constellation on the canvas and finalise the design to create a complete sky chart.