Thursday, 23 August 2012

Is this a blog post that I see before me?

This is a quick blog to share some awesome with you. I have spent the afternoon playing with my new macro, and have acquired a rather compulsive attitude towards 8-bit images.

Using Langton's Ants on Excel! Hmm, maybe it won't catch on.

Ah hem. You can expect the next few blog's to completely consist of 8-bit images I have stolen from the internet and coloured in using ants. And in case you have just joined the blog I am not pulverising a colony of ants from my back garden then using the resulting paste to defile a children's colouring-in book. They are digital ants. Which makes it okay. I think, I am yet to check this with the RSPCA. And so on to the images:


Do you get +1/2 life if you eat the first one?

It was when I was making the mushroom that I realised it would be much easier if I could use the same mechanism to colour in the edges as I do for selecting the colour of ants and adding the highlights. I also added the ability to make 'white' ants, which I needed for the face of the mushroom.


Pretty freakin' awesome

I got the pattern for this one off a blog. This is the coolest thing yet to come out of this project by a rather embarrassing amount. I have noticed a trend in my blog posts in that I very nearly never come back and do anything that I have put in a list. It is very probable that this list will suffer the same fate. This is a list of things I want to 8-bitanterize:

  • A world map. Mercator's projection naturally, although I could be persuaded to go Gnomonic.
  • Harry Potter.
  • A famous painting.
  • A random picture off of Facebook.

Those are in order of do-able but time consuming to impossible but I'll bloody well kill myself trying.

4159,

mathmo

Wednesday, 22 August 2012

Pikachu and Puns

"Hello project, it's been a while. I am sorry I haven't called (your macro) recently but things were getting a little intense and I needed a break; some time to play around with other programming languages y'know? There was this one I knew from university and things were going really great for a while. Then it started harping on about my soul and 'happiness', a little too religious for my liking. Anyway I am back for good now. mathmo"
Perhaps a little weird and probably highly confusing. There is a joke in there for the CompSci's, there is a joke in there for the Mathmo's, and there is a lot of confusion over the nature of my relationship with my computer for the rest of you. To put you at ease the above translates as "I have had to put my project aside for the last couple weeks to do university work, consisting of maths and programming in MatLab".

Moving swiftly onwards...

Pikachu, now with surprisingly small feet

Now, pick wisely:

  • If you came here solely for a brightly coloured picture of Pikachu, I recommend you now head here.
  • If you came here for an 8-bit technicolour image of Pikachu coloured in by 10 binary ants, keep scrolling.

At first this image seems like a fairly simple output. Just draw a black outline in Excel, then tell it what colour you want each section to be, and where you want each ant to start, and then you might as well tell it to put in highlights like the white's in Pikachu's eyes. Right. Simple.

I think my solution was pretty elegant; in my final version to get the above output you only needed to input:


Painting by letters, does this count as algebra?

Each lower-case letter is the starting point of an ant that has the colour indicated by the letter. Upper-case letters are the highlights, those colours are added on top of the ants' paths at the end of the computation. For instance the "y" indicates that a yellow ant should start from this position, and the "A" indicates that this cell should be coloured white at the end. I have also covered the possibility of you wanting to stack these, for example "yA" would be translated as "I want an ant with a yellow ant to start here and for this cell to be coloured white at the end". I have only included the primary and secondary hex colours (red, blue, green, yellow, pink, cyan) so far. The code for each colour is the first letter of the name of the colour; except for black and white, where black is "z" and white is "a". Damn you blue.

I also included the option for the user to alter the gradient of the colour. For example setting the gradient at 50 produced the block colours above, but setting it at 1 would give:


Nintendo came to regret zombie Pikachu

For this particular image the lower gradient doesn't really work, but sometimes it is quite a nice effect:


My next blog post will have many Pokeballs

In terms of the structure of the program I had to come up with a completely new set up. I completely scrapped the system where I stored the location of each ant each turn and then when it came to displaying only changing the colours where an ant stepped. Now each cell has a 'hit' counter, incrementing each time an ant lands on it and making the ant turn right if the counter is even and left if it is odd, as well as a variable which 'remembers' the colour of the last ant to land on that cell. The colours are only added when the result is outputted.

653,

mathmo

About Me

I am a mathmo (mathematician for anyone not familiar with Cambridge slang) studying at the University of Cambridge, and this is the blog of my summer project on Langton's Ant. This project was dreamt up one evening in the college bar when I was showing some of the compscis (computer scientists) my old visual basic excel macros and stumbled across a very basic Langton's Ant. What I showed them was just one boring black ant. By the time I left the bar that morning I had progressed to two coloured ants colliding with each other, the demo macro that most of this project is built from. Through this project I hope to expand my knowledge of visual basic, encourage others to mess around with maths on their computers, and to make a lot of pretty pictures. I will aim to keep my language fairly non-technical, but feel free to comment if you have a question or even a suggestion on how to improve my code. Here it goes...