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

No comments:

Post a Comment

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...