AuthorJack Concanon

Maze Solving with A* In Python

There was a new challenge at work to create a program that can solve 2D ascii mazes, for this challenge I implemented the A* search algorithm, this is a very fast algorithm that uses heuristics to determine whether or not a path is viable. It is very useful for something such as path finding in computer games as there may be different routes available but some routes are preferable to others.

The mazes look like this –

Here is a larger one –

Save the mazes into a file and pipe them into the program.

Java Create Relative Date

This is a small part of an Android application I’m working on; couldn’t find a simple Java relative date function so here’s one I made.

 

Finished: Batman Arkham Origins

An interesting third part to the Batman Arkham series, unfortunately it lacks the charm and interest of the first two games. It would have been more interesting to see the rise and origins of the various baddies of the series rather than just the Joker.

The combat is excellent as you would expect from a Batman game, the ability to flow together combos is something that never gets old and there is a healthy array of gadgets to help you.

The game has plenty of content and kept me going for around 30 hours. Unfortunately there were a couple of bugs that impacted the gameplay such as enemies becoming far too intimate with walls and various prompts not being displayed when they should have been.

Overall it’s a solid game in an excellent series.

Finished: Dawn of War 2: Chaos Rising

I actually preferred the base game over chaos rising, the Tyranids provide a real exciting and credible threat whereas the Chaos Space Marines come off as cartoonish and arrogant.

The overall length of the game was short and the character progression stops too soon, meaning that your main squads reach maximum level half way through the game!

The boss fights are basically bullet sponges with some annoying area of effect attacks.

Over all – stick to Dawn of War 2.

Landrover Mud Plugging

Python Port Tunneler

I needed to be able to remote debug a process that was hidden behind a middle server so I made a Python script that can create a ‘middle man’ port to allow for this.

Basically if you have server-B which is only accessible through server-A then the script creates a port on server-A that links to the desired remote debug port on server-B and provides a new port to forward all traffic through.

It’s probably possible to do this all with some cryptic SSH command but this works better for me, plus I got to do some more Python. It uses the gevent library, which is an extremely fast and efficient socket library and can be downloaded from any good repository.

The usage is quite simple –

The code –

 

Image Recognition Tool

As I’ve recently got quite into machine learning tools I’ve written a small GUI based tool that uses the PyBrains library to ‘learn’ a common theme from a folder of training data. To test new images, drag and drop them onto the tool to get a percentage of similarity to the test data.

The tool is written using Python, PyBrains, Glade2 and PyGTK so you need those libraries available.

The tool can be downloaded here – image_recognition_tool

A presentation I made for work that is an introduction to machine learning. Notes included with power point slides. Machine Learning

Image Recognition with PyBrains

After recently completing the Machine Learning course from Stanford University on Coursera I’ve been preparing to give a small introduction to machine learning at work. Part of that is showing some demos of machine learning tools.

I made a character recognition neural network using the PyBrains Python library, it’s a great library and very fast but the documentation is very poor and examples are hard to come across. With enough digging I managed to put together something very simple and short.

In this example it reads in small PNG files of letters, extracts all of the pixel values and creates a 1D array of the values, this is used to train the neural network through back propagation. I test the network on one of the inputs. Each input is classified with a number in the addSample function, this takes the flattened array and a number (unfortunately it does not take a string as a classification). If you run the application you will see that, for example when using b.png as a test, it will return a value close to 2.

You can download the images I used here – Machine Learning Training Characters.

 

Ceaser Cipher Cracker

Another programming challenge from work to solve Ceaser ciphered sentences and return the correct shift value. Automatic solving of the cypher is easy enough but the hard part comes to automatically detecting if the resulting shifted sentence is English. I have posted before about detecting English using ngrams and used a similar process here.

Here is the code which contains the four test cases.

Fitbit Flex Bluetooth Syncing with HTC One X

Finally got Bluetooth syncing from my One X to my Fitbit Flex, here’s how –

First ensure that your phone has at least Android 4.3 or higher, in my case I’m running Cyanogenmod 10.2, then head to this link to sign up for the Fitbit Beta – https://groups.google.com/forum/#%21forum/fitbit-android-sync-beta. Once you sign up to for beta access it may take around ten minutes for this to register with Google, then an update to the Fitbit application will be available on your phone.

After the update ensure that Bluetooth is active and enjoy your wireless syncing!

C# DateTimePicker in PropertyGrid

Property grids are great for quickly giving users an interface for interacting with objects in WPF but customising them is not obvious. Luckily it is possible by extending the UIEditor class to launch custom GUI controls.

In this example I wanted to customise the default DateTime handler of PropertyGrid to include hours, minutes and seconds as unfortunately it only shows the date by default. The following class shows how to extend UIEditor in order to launch a pop-up DateTimePicker when the user selects the item.

Then in order to add that to your property grid, add the following to the DateTime item in the class used by the PropertyGrid –

The key part here is the EditorAttribute.

Update

Here’s a great article explaining custom UITypeEditors in more detail – http://bobpowell.net/TypeEditors.aspx

© 2019 Acodemics

Theme by Anders NorénUp ↑