iDotsBot is a simple Java application that plays Dots on your mobile phone for you in “Turns” mode.

What you see is what you get (there’s no user interaction at all,the java app is doing all that’s happening)

In its current form it does not use the powerups since i enjoy having a little extra credits from running the bot. But using powerups is very easy to implement after all, so if you want it, feel free to add them. It will reload the board until in finds a reasonably good starting szenario and will often deliver more than 300 points without powerups. Add some extra moves and you easily reach 400+.

I wanted to compare several strategies (like this one) to play Dots and especially test a ruleset generator on the game and check how well other people’s strategies work out. Since I’m too lazy too do that manually, I’ve decided to code an automatic system to do exactly that.

You can check out the source code here :

If somebody’s interested, i can also create an app from it an upload it to MacUpdate once it’s mature enough ;)

The bot captures the screen of my mac (or your java machine) and uses simulated mouse clicks on the UI to interact with dots. I like, recommend and use TeamViewer to bridge my computer to my phone. Check it out, it’s free for personal use and a great piece of software.

If you’re a developer and you’d like to contribute

The DotFigures class needs to be refactored and added. It basically plays like a human, it searches for “patterns” like “burgers” or “quads”, ranks them and executes on them. I think I’ll add a “virtual score” for them and integrate them with the normal depth first search if I find some time to do that.

Monitoring your internet connection

Half a year ago my DSL Connection started dropping every hour or so and is re-established after a minute. This was very annoying.

Since O2 ships this blautiful router which gives no information at all, how to document these connection losses?

What I have so far: (shell script)

echo "Date - Localhost - - LAN Printer -" > checkinternet.log
while true
date >> checkinternet.log
( while read ip; do ping -c1 -W1 -q $ip; done ) < ips | grep round >> checkinternet.log
sleep 10

ips (text file)


checkinternet.l (lex script)

#include <stdio.h>
[a-zA-Z]+[ ][a-zA-Z]+[ ][0-9]+[ ]     printf("\n"); /* printf("\n%s,", yytext); */
[0-9]+[\:][0-9]+[\:][0-9]+            printf("%s,", yytext);
CEST      /* ignore */
\n        /* ignore */
[ \t]     /* ignore */
round-trip /* ignore */
min      /* ignore */
avg      /* ignore */
max      /* ignore */
stddev      /* printf("CONNECT "); */
=        /* ignore */
[0-9]+\.[0-9]+                       printf("%s,", yytext);
\/       /* ignore */
ms      /* ignore */
[0-9]+ /* ignore year */

Compile with

lex checkinternet.l
cc lex.yy.c -o checkinternet -ll

Then run for a few hours, then

./checkinternet < checkinternet.log > checkinternet.csv
tail checkinternet.csv
open /Applications/Microsoft\ Office\ 2011/Microsoft\ checkinternet.csv

And plot rows 1,5,… screenshot and annotate with the Mac OS Preview

Works – but there is room for improvement. Comments are always welcome.

Snake Cube Puzzle Solver


In Octave / Matlab

I got this 4×4 “maximum” difficulty snake cube for christmas (with the solution removed from the package of course…) and decided it would be much faster to solve it by programming it than by hand…

So, if you’re searching for a solution, here is a general one

You will need GNU Octave, you can install it on OSX by running brew install octave assuming you have homebrew installed.

Run by creating the two files below, modify the Snake Vector S, start vector P and starting direction v to match your snake, run octave, start RunSnake

Script (RunSnake.m), edit your Cube here

# Octave Snake Code
# 31.12.2014 - 1.1.2015, Wolfram Teetz <>

global iter;
global maxdepth;
global maxmatrix;
global nulltime;
global lasttime;

iter = 0;         % Iteration
maxdepth = 0;     % Maximum solved depth so far
maxmatrix = 0;    % Best solution so far
nulltime=0;       % Start time in seconds
lasttime=0;       % Start time of last iteration in seconds

S = [4 2 4 2 2 2 2 3 2 2 2 2 2 3 2 4 2 3 3 4 2 3 2 2 2 2 2 2 2 2 2 4 2 4 2 4 4 4 3]; % My snake - length of all edges
S = fliplr(S);    % Solve backwards (optional)
W = zeros(4,4,4); % Cube volume
v = +1;           % Starting direction +1=Ascending in dimension 1 == x, -2 would be descending in y etc.
p = [2 1 1];      % Starting position x=2, y=1, z=1
nr = 1;           % Start with stone #1

disp ('Starting Search...');
nulltime = time;

The recusive main function (OctaveSnake.m)

function r = OctaveSnake(xS, xW, xv, xp, xnr, dispy)

    global iter;
    global maxdepth;
    global maxmatrix;
    global nulltime;
    global lasttime;

    iter = iter + 1;
    if (mod(iter,10000) == 0)
        disp("Iteration ");
        disp("Total Time");
        disp("Maxdepth ");
        disp("Max Matrix");

    if (dispy) disp("Try to continue from position"); endif;
    if (dispy) disp(xp); endif;
    if (dispy) disp("Direction"); endif;
    if (dispy) disp(xv); endif;

    for (i=2:xS(1))

        % Check state
        if (min(xp)<1)
            r = false;
            if (dispy) disp("  out of 4x4 -- abort"); endif;
            % out of bounds
        if (dispy) disp("  minok"); endif;

        if (max(xp)>4)
            r = false;
            if (dispy) disp("  out of 4x4 -- abort"); endif;
            % out of bounds
        if (dispy) disp("  maxok"); endif;

        if (xW(xp(1),xp(2),xp(3))!=0)
            r = false;
            if (dispy) disp("  collision -- abort"); endif;
            % collision, stone at this position already
        if (dispy) disp("  no collision"); endif;

        % Test, if there are enough free complete rows of 4 stones empty for remaining 4-rows
        if (i==2) % Only on the first iteration per call
            cremaining = length(find(xS==4));
            cfree = sum(sum( (sum(xW, 1)==0) ));
            cfree += sum(sum( (sum(xW, 2)==0) ));
            cfree += sum(sum( (sum(xW, 3)==0) ));
            if (cremaining>cfree)
                r = false;

        if (dispy) disp("  place length"); endif;
        if (dispy) disp(xS(1)); endif;

        if (dispy) disp("Set Stone #"); endif;
        if (dispy) disp(xnr); endif;

        xW(xp(1),xp(2),xp(3))=xnr; %  Set stone, prepare next stone
         % xW(xp) = xnr; % Keep in mind this gives an error in Octave

        xnr = xnr + 1;
        xp(abs(xv)) += sign(xv);

        if (dispy) disp("New Position"); endif;
        if (dispy) disp(xp); endif;

        % New maximum depth found
        if (xnr>maxdepth)
            maxdepth = xnr;
            maxmatrix = xW;

        if (xnr>63)
            disp("S O L U T I O N");
            disp(xW); % Display state
            r = true;

        % Move one field

    for (nV=[-3 -2 -1 1 2 3])
        if (abs(nV) != abs(xv)) % Orthogonal turn
            r = OctaveSnake(xS(2:length(xS)), xW, nV, xp, xnr,dispy); % Turn and enter recursion
            if (r) return; endif;


Your solution will be displayed like this :

ans(:,:,1) =

12   11   10    9
  24   25    8
2   27   26    7
3    4    5    6

ans(:,:,2) =

13   22   31   32
14   23   30   33
15   28   29   34
16   37   36   35

ans(:,:,3) =

20   21   50   51
19   48   49   52
18   47   54   53
17   38   55   56

ans(:,:,4) =

43   44   61   60
42   45   62   59
41   46   63   58
40   39    0   57

Meaning you should put the first stone (1) on the lowest level (:,:,1), stone 2 below, stone 3 below, stone 4 to the right, … , stone 12 to the left, stone 13 above #12, then 14 below 13 and so on…


iMango 1.2 for Mac OS X


Click on the image to download the current version 1.2

iMango is a supplement of Spotlight. It finds files, folders or contents in any file and diplays the results in a tree view, so that you can browse through the folder structure of the results much quicker and more intuitively than in Spotlight.

It is donationware and you can freely download it here fully functional.

Drag files onto the window (e.g. one word file from your Desktop) to quickly get an overview which subfolders of your desktop contain word files. If you can find some similar files, try selecting 2 or more of them at once and dragging them onto iMango together. iMango will search the files that contain the largest common substring – e.g. for “Annual marketing report 2013.docx” and “Annual business report 2013.xlsx” it will search all files containing “report 2013.” automatically.

Finding your files real easy.

Version 1.2 is compatible with Mavericks. Confirmed to work on 10.6 – 10.9 and should work on 10.5

System requirements : Mac OS X

Windows and linux versions on request

Octave 3.6.4 Installation on Mac OS using Homebrew

A motivation article for those who are trying to install Octave on Mac OS using homebrew


I needed to interpolate some scattered 2d data today with a bit more sophistication than just using octave’s polyfit. I found that Chirokov’s RBF implementation works great out of the box for me. Shepard was also very easily implemented but already pretty slow for my 100×100 grid with the ‘naïve’ canonical code.

Taking a look at the PCA and LDA (See also, works out of the box), I discovered that I could to some pretty good guesses at a closed function form.

Remembering that there was an Octave Package called optim that contains a general fitting algorithm, I quickly decided to try that out.

In case someone wants to do the same – It’s straightforward but the optim toolbox only works with a current version of Octave.

Working on Mac OS, you need to build that yourself as the last ‘readily packaged’ version is really old.

I had already struggled with Aquaterm in the past, so I was aware this might take some time.

If you want to do the same, here’s a quick guide on the current pitfalls and fallacies.

I’m using homebrew as a manager. I’ve tried to add my experience to the Octave for Mac OS wiki page ( That’s a good point to start.

  • Install XCode via the Mac App Store.
    • Once installed, install the Command Line Tools from XCode’s Apple Menu > Preferences > Downloads.

I had Homebrew and Git installed but nothing worked. I tried a lot and finally gave up and cleaned up the house:

rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup


ruby -e “$(curl -fsSL”

brew doctor

brew install git –with-brewed-curl

  • Import the scientific computing packages, including Octave:

brew tap homebrew/science

brew update && brew upgrade brew install gfortran

Went fine

brew install hdf5

didn’t. Copy hdf5.rb from into /usr/local/Library/Formula. Currently as of Nov 13, 2013 you have to adjust the hdf5 version number to hdf5-1.8.12.tar.bz2 and remove the checksum line below.

 Brew install hdf5

 Went through then.

 Brew install octave failed, so I did

brew tap –repair

and repeated

brew install octave

 Which stalled at the fltk download. I tried to download the file manually which also failed.  Downloaded to /Library/Caches/Homebrew/fltk-1.3.2.tar.gz and resumed with brew install octave.

 Building octave crashed because of outdated autotools.

 I brew installed them both, after that “brew link automate”d them with –force and then symlinked them (e.g. /usr/local/bin/automake->/usr/local/bin/automake-1.14), for all autotool executabled.

 Octave still didn’t start and gave me some library errors.

 sudo cp /usr/X11/lib/libfontconfig.1.dylib /usr/lib/ 


sudo cp /usr/X11/lib/libfreetype.6.dylib /usr/lib/ 

 Finally gave me a working octave

 pkg install -forge general

pkg install -forge miscellaneous

pkg install -forge struct

pkg install -forge optim

went through smoothly.


Now googled up “Time for action – using leasqr” and, with the first hit,

scroll down to “Time for action – using leasqr”, things went through smoothly.


RDF Reference: Google for 

Scattered Data Interpolation and Approximation using Radial Base Functions

by Alex Chirokov on Matlab Central