PROBABLE TRAIN
PROBABLE TRAIN

Flock/Shoal Simulation

The birds and the bees (and fish)

There are many animals that exhibit flocking behaviour, including humans. This is an attempt to recreate that behaviour using three simple rules:

  • Separation - avoid crowding neighbors (short range repulsion)
  • Alignment - steer towards average heading of neighbors
  • Cohesion - steer towards average position of neighbors (long range attraction)

Unfortunately, due to the nature of the problem this is an O(n^2) algorithm, as every fish/bird/thing has to check the position and velocity of every other entity (without doing special trickery like bin-lattice subdivision). Here's the link to the source code. If you're familiar with Java and LibGDX this should be pretty simple to run and modify. If not, it might be worth writing this in Javascript, I've seen some pretty successful examples online.

So what are the uses except for making pretty (but intensive) screensavers? Well I guess a similar, but probably more complex, simulation could be used to see how crowds of people react in certain situations. I can't for the life of me find the source, but I remember reading that putting a pillar in the middle of a doorway can speed up entry and exit of a tube station, as it forces commuters to line up. At present however, it just makes for a pretty video.

1

The New Blog!

Basically Wordpress but worse better..? worse

Welcome to the new blog. It's better than the old one.
Hey it's even got https. That's for me not you though, I don't want middle men snooping on my admin password.
Want one for yourself? Get the code on Github

Features:

  • Markdown. Look at these lovely bullet points
  • Online editor complete with live markdown preview and image uploads, no more SSHing/SFTPing ever!
  • Near-static auto-generated content. There's a wee bit of JQuery but that's all
  • Auto-generated unique urls for each post
  • Upvotes. These are unlimited because there are no user accounts and I'm scared of the GDPR police coming for me if I go down the cookies route
    • (Plus is it reaaally a problem having unlimited upvotes?)
      • Unless it gets upvoted so hard the int overflows and comes back round the other end
        • Probably should do something about that
  • Password-protected draft posts area
  • Pagination
  • Auto publish date
  • Custom urls
  • Tags

The nitty gritty

Flask backend, Jinja2 templates are a dream to use, Redis for upvote storage, plain old text file for posts storage (works fine, no real need to mess around with a database), JQuery for the actual upvoting. Find out more on Github
All posts are stored in one big file at the moment. The admin console effectively gives you free reign over editing the file, so you can change past posts, publish dates, post urls, at your leisure. Due to the potential for the utter destruction of all posts ever if you or some nefarious individual deletes everything, post backups are made every time the admin console is used.

As a neutral third party, I'd definitely recommend using this blogging engine.

4

Python Twitter Competition Bot

Python Twitter Competition Bot

I spent a short amount of time writing a fairly crude Twitter bot in Python, using Tweepy. It listens to a stream of tweets, looking for ones with keywords like 'win', 'RT', and 'fav'. After passing through a couple of filters to try and determine if this is a genuine competition tweet, it will follow, favourite, and retweet.

It's been running for just over a week now and I've won a few things, most of them digital so far, and all of them pretty much worthless. Included in my winngs are: A random Fortnite account, a cupcake from a stand in Manchester, Grave Danger for PS4, Fear the Wolves beta key on steam, the book 'Fliers' by Laura Mae, and an entire £0.05 sent to me on Paypal.

He said it was meant to be £0.10 but the Paypal fees were too large.

0