In this post I present my Christmas gift to the world: A multilayer perceptron written in C++11.
I mainly wrote this to get some practice with some of the new C++11 features such as variadic templates and lambda functions. It uses template metaprogramming to construct (but not train) the neural network at compile time. You can download the code from its github repository. It’s lacking proper documentation, but I’ve included two examples that should get you started: the xor problem and Fisher’s Iris data set.
A while ago I was looking for a simple lightweight c++ library that could produce some basic charts. I quickly found the PPlot library which is designed to easily integrate with different GUI toolkits and also comes with bindings for ruby and python. To make the library usable within different GUI frameworks the drawing part has been abstracted to a Painter class. For each GUI framework a different Painter class must be implemented. The library comes with ready made implementations for GUI toolkits like wxWidgets and QT. However, I wanted to use the PPlot library in a pure win32 application and had to implement my own Painter class. If you’re in a similar situation check out my source for an example.
I’ve always been interested in emulators and just finished my Chip-8/SCHIP emulator. Chip-8 is an interpreted programming language that was first used on some early homecomputers and later on the HP48 calculator. The emulator allows you to play some retro games like pong and invaders.
The emulator is written in C++ and is available for download here. Besides the program and source code I’ve also included some games that seem to work ok. The original machines that ran a chip-8 interpreter had a 16 key hex-keypad that looked like this:
1 2 3 C
4 5 6 D
7 8 9 E
A 0 B F
This keypad is emulated on the PC keyboard like this:
1 2 3 4
Q W E R
A S D F
Z X C V
Computer programs playing two-persons games like Chess, or Go usually use a search algorithm like minimax possibly with alpha-beta pruning. The simplicity of the game Tic-tac-toe however, makes a search algorithm unnecessary. The number of possible board situations is very limited and a better option in this case is to use a lookup table.
I started by generating all possible board situations and placing them all in a database. After that, calculating for every position the best possible move or moves that should follow to minimize the chance of losing and maximize the chance of winning was straightforward. I used the result to make a lookup table to be used in a C++ program that plays Tic-tac-toe perfectly. Because of the 8-fold symmetry of the board the lookup table does not include too many elements.