The Game of Go as a Complex Network

I wrote some code in Python to construct a Pagerank vector of moves in the game of Go. Georgeot and Giraud discuss this method in their paper but do not include any sample code, so I decided it would be fun to implement it myself and run it on some sample data from the K Go Server.

The code on my GitHub should be a good starting point if you’re looking to construct a network of moves in Go, although there are some differences in my implementation and the one used by Georgeot and Giraud – for example, I do not take into account all the symmetries of plaquettes that they do. Here is a comparison of the top ten moves for λ1.

Printing on Green Bar Style Paper

I like to look at code on green bar style paper, where alternating rows are different colors, because it’s easier to read. I don’t own actual paper to print it on but I found a neat command line tool here to export a program to a PostScript file with the appropriate styling. For example, using a2ps the following command will create a PostScript file that styles the program test.py .

1
a2ps --prologue=matrix -o test.ps test.py

Connecting to MS Access in Java

Java has stopped supporting the JDBC-ODBC Bridge with the release of JDK 8, so here is my (somewhat quick and dirty) way of working with MS Access.

There are various alternatives you can try out such as UCanAccess, PyPyODBC, or Easysoft’s API. I’ve messed around with a few of these and I feel that they aren’t quite as powerful as the bridge offered in previous versions of Java, and I don’t have the time right now to improve my C skills enough for the particular project I’m working on.

My solution, which seems to work fine so far, is to install Java 7 alongside Java 8, and use the built in JDBC-ODBC bridge. If portability is a concern for you then maybe this isn’t your best option, but for my purposes I’m fine with wrapping the code up in an executable.

If this is all you need to get set up, then great! I’m happy for you, I really am.

I had trouble connecting to the ODBC driver, though, because I’m using 32-bit MS Office on a 64-bit system. If this is a problem for you, too, then installing the Microsoft ACE OLEDB Provider as outlined here will help. Make sure you launch the installer from a command line with the “/passive” argument. Be wary that this might make Office behave strangely. I haven’t noticed anything too bad so far, except that it now takes a minute or two to launch Office.

Hope this helps. This is a bit of a quick fix to meet a time constraint, so there are probably better ways to do this. If you have suggestions please share them below!

Degrees of Separation in Movies

Here’s a fun fact for you: 91% of all movies are within six degrees of separation from each other.

According to IMDb, anyway.

I recently wrote a script in Python to search through a snapshot of IMDb for how many movies are within six degrees of separation from “The Wizard of Oz”. Any movie that shared an actor with “The Wizard of Oz” is degree 1, and any movie that shared an actor with a movie that shared an actor with “The Wizard of Oz” is degree 2, etc… The snapshot uses the following SQLite schema:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE TABLE Actor (
    aid INTEGER PRIMARY KEY AUTOINCREMENT,
    first TEXT DEFAULT '',
    last TEXT DEFAULT '',
    dob DATE DEFAULT '',
    gender TEXT DEFAULT '');

CREATE TABLE Movie (
    mid INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT DEFAULT '',
    year INTEGER DEFAULT 0,
    rating TEXT DEFAULT '');

CREATE TABLE Role (
    aid INTEGER REFERENCES Actor(aid),
    mid INTEGER REFERENCES Movie(mid),
    role TEXT DEFAULT '',
    billing INTEGER DEFAULT 0);

Here’s the percent of all movies within 6 degrees:

When I saw this I started to wonder what percent of movies is “The Wizard of Oz” connected to for any degree number? I ran the code again for 15 degrees this time, and it looks like it tops out at about 91%…

Well that’s cool I guess, but let’s look at other movies! I’m sure you’re all wondering how well connected Nicolas Cage is – I have a bit of a soft spot for Con Air.

After looking around at a few other movies, it seems like all of them top out at 91% after degree 4 or so. I guess this means that 9% of the movies on IMDb star actors who are not even remotely famous. You can find my code here, let me know if you find any other cool trends!