Category Archives: coding

Ranking Engine Update

I feel like I have been doing lots to this project this week with not much to show for it.

As you can see I’ve just edged over the 25% mark for the number of pairwise comparisons that I need to do for my game ranking of my collection.

I’m not going to bore you with another “look at my current top 10”. Instead I’m going to bore you with my top 10 worker placement games based on my current rankings of games. 

What this really show cases is the start of the next stage of my stats engine. After a bit of behind the scenes rewriting of code, I’ve started a gui front end (see below). It’s an ugly, not designed gui. I’ll sketch something out over the weekend. 

But basically I can select a game mechanic and find all the games in my collection that have that mechanic. 

It then takes those results, and finds out how I’ve ranked them, followed by printing out the top ten. 

So before I add categories, designers and publishers I need to sort out the gui. That’s the major effort. 

Once that’s been done I’ll expand the stats to look at the bgg hotlist, followed by the bgg all time top 100. 

I then have more stuff on the road map. Wait did I just type that? That almost makes me sound like professional and I’ve planned it. But in reality I haven’t and I’m not. I’m making things up as I go along. I have ideas that I really should write down before they are lost. In away these posts are acting as my dev notebook. Well hopefully gentle reminders. 

Hopefully you can see things are progressing both code wise and rankings wise. I also hope you are finding the verses posts interesting. Which were a surprise spin off from this project.

Anyway I’ll see you in my next post.

Ranking – Progress Update

So this may not look much. BUT I have a ranking engine for my game collection!

Yep I now have a python script that creates match ups from my collection, and records the results. As you can see the script also gives me the depressing information that in total I will have to do a lot of pairwise comparisons. 23005 to be exact, based on a game collection of 215 games (it’s a couple more than that now, but that updated list hasn’t been imported into the database yet). The formula I used to work this out was totalNumTests = N(N-1)/2.

So two thirds of the way there. I now need to create my lists/stats engine. Or get an initial version done. But considering how many pairwise comparisons I have to do, it’s going to be a while before you see the fruits of that labour. However you may see the odd post that discusses one of the pairwise comparisons. Why did I rank game A better than game B, and asking for which one you’d choose?

To Do List:

  • Update script for populating to database with games to allow updates to the collection.
  • Lists/Stats Engine
  • Long term: create a GUI front end

Boardgaming and Coding

This post has taken me a day or three to write. Hence why you haven’t been bored by me.

Plus my only other gaming has been the enrichment session for my students since the last post. Which I don’t talk too much about. But do remind you from time to time that I do. I will say about the one at the start of the week is that I introduced a student to Star Realms and deckbuilding. We spent the session playing that game. It was just “one more game” from the student at the end of each one. Plus when I told the student there was an app. They were going to go on Steam to buy it that evening. So I think that was a success. It’s nice to see a student enjoy a game so much they get it for themselves.

Now on with the post and the words I’ve been struggling to write…

Everyone, and I mean everyone whose anyone in the boardgame social media world has done their top 100 games of all time or their top ten this or top five that. From time to time you also get a similar thing on Instagram (see screen grab below).

I’ve tried those sort of posts myself the odd time in the past. I’m not a big fan of them in reality. I kinda see them as click bait. Which will mean this post and the project I’m going to talk about will not make much sense.

These “my top 100 games (insert year here)” lists kind of interest me. Mainly how do they come up with their list? What process do they use? Now that I have started recording my game plays could I produce a similar list based on the number of plays? Would that be a fair reflection of how much I like the game? Is that a good way to rank games I like? I can see flaws in doing it this way.

Just before Christmas there was a website that went up that tried to help you rank the games in your collection. You uploaded a csv (comma separated file) of your collection. Then it would start a series of random game match ups from your collection, where you decide which is the winner. Eventually after lots of these match ups it ranks the games in your collection.

That process is known as pairwise comparison. And allows you to determine a relative order for a group of items. Which in our case is board games.

So I’ve started a project to create my own little ranking program. I’m using Python 3 to write this little project. Mainly because it is quick to prototype with, has some great libraries for doing stuff like accessing a database, web scraping, reading csv files etc. Plus I need to keep my Python skills fresh.

My initial question for this whole project is “What are my top 100 favorite games?” After this has been completed I will then be able to ask other questions such as “What are my top 5 drafting games?” And I’m sure with the data in place other questions will be asked, and expanded on.

But what have I done so far for this project? Well we all know there are not enough hours in the day to do everything. You can’t be lazy, watch tv, play board games, write a blog, hold down a full time job and do other stuff! In other words I did nothing until recently.

Here is what I have done so far…

I started off with a csv file of my game collection downloaded from the bgg website. Which I then tidied up in Excel. This was mainly removing entries that weren’t games but expansions. In data science terminology I was cleaning my data!

I then wrote a Python program to read in the cleaned up data and put it into a sqlite3 database. For each game in the file the program uses the bgg api to get its details. The program then extracts from the returned results the missing information that I want to use later, such as genre, mechanic, designer, etc. Once it has done that the game is added to the sqlite3 database.

This means I now have an sqlite3 database that holds my game collection on a table with the extra info that I have always felt was missing from the csv bgg provide you with. I can now interrogate the sqlite3 database and get a list of all my dice games, or all the games I own by Eric Lang.

I am currently working on a new program in this project which is the the actual ranking engine.  So far this program connects to the sqlite3 database, finds out the number of games I have and generates two random numbers, and then pulls the games details matching those two numbers. You then get something like the following image:

At the moment I can type something in, and the program will keep coming up with new match ups. However at the moment I do nothing with the answer. That’s the next stage of this ranking engine. I need to store the result in a new table. I’m just getting my head round what the best way is to store the information. Because I am using a two dimensional array (well list in Python, although I might use the numpy library to give me a real array) to store the results, I think the best way to store that is with a blob field type. Which means I will have to serialize the data in the array before storing it in the database.

Once the ranking engine has been finished. It’s onto my data visualization engine. This will be the program that pulls off the results and give me like my top 100 games, or top 10 deckbuilders. I also plan to have it also be able to tell me how many of the bgg hotlist I have played or own.

The nice thing about this project is I can also share the badly written code with my students. So they will have examples of how to connect to a sqlite3 database, or read in a csv file, use a web api and use the xml libraries.

So now that I have bored you with an “overview” of my little project. I will threaten you with a more detailed write up once it is completed.